super-three 0.161.0 → 0.163.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 (206) hide show
  1. package/build/three.cjs +822 -1332
  2. package/build/three.module.js +820 -1328
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/DragControls.js +91 -30
  5. package/examples/jsm/controls/OrbitControls.js +32 -6
  6. package/examples/jsm/controls/TransformControls.js +9 -9
  7. package/examples/jsm/exporters/GLTFExporter.js +30 -3
  8. package/examples/jsm/exporters/USDZExporter.js +15 -0
  9. package/examples/jsm/geometries/TextGeometry.js +10 -2
  10. package/examples/jsm/interactive/HTMLMesh.js +7 -9
  11. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  12. package/examples/jsm/libs/fflate.module.js +694 -496
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  14. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  15. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  16. package/examples/jsm/libs/tween.module.js +32 -14
  17. package/examples/jsm/lines/LineMaterial.js +0 -2
  18. package/examples/jsm/loaders/3DMLoader.js +13 -21
  19. package/examples/jsm/loaders/3MFLoader.js +2 -0
  20. package/examples/jsm/loaders/EXRLoader.js +89 -19
  21. package/examples/jsm/loaders/FBXLoader.js +1 -1
  22. package/examples/jsm/loaders/GLTFLoader.js +6 -0
  23. package/examples/jsm/loaders/KTX2Loader.js +2 -6
  24. package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
  25. package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
  26. package/examples/jsm/loaders/LUTImageLoader.js +0 -14
  27. package/examples/jsm/loaders/RGBMLoader.js +16 -0
  28. package/examples/jsm/loaders/VOXLoader.js +9 -2
  29. package/examples/jsm/loaders/VRMLLoader.js +6 -2
  30. package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
  31. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  32. package/examples/jsm/nodes/Nodes.js +15 -8
  33. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  34. package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
  35. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  36. package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
  37. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  38. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  39. package/examples/jsm/nodes/accessors/MorphNode.js +20 -10
  40. package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
  41. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  42. package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
  45. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  46. package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
  47. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  48. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  49. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  50. package/examples/jsm/nodes/core/Node.js +67 -6
  51. package/examples/jsm/nodes/core/NodeBuilder.js +23 -24
  52. package/examples/jsm/nodes/core/NodeFrame.js +8 -8
  53. package/examples/jsm/nodes/core/NodeUtils.js +2 -2
  54. package/examples/jsm/nodes/core/TempNode.js +1 -1
  55. package/examples/jsm/nodes/core/UniformNode.js +20 -0
  56. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  57. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  58. package/examples/jsm/nodes/display/PassNode.js +17 -1
  59. package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
  60. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
  61. package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
  62. package/examples/jsm/nodes/fog/FogNode.js +13 -3
  63. package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
  64. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  65. package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
  66. package/examples/jsm/nodes/materials/NodeMaterial.js +70 -17
  67. package/examples/jsm/nodes/math/CondNode.js +42 -7
  68. package/examples/jsm/nodes/math/MathNode.js +20 -0
  69. package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
  70. package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
  71. package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
  72. package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
  73. package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
  74. package/examples/jsm/nodes/utils/LoopNode.js +2 -0
  75. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  76. package/examples/jsm/objects/QuadMesh.js +7 -23
  77. package/examples/jsm/physics/RapierPhysics.js +4 -4
  78. package/examples/jsm/postprocessing/GlitchPass.js +0 -3
  79. package/examples/jsm/postprocessing/LUTPass.js +5 -71
  80. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  81. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  82. package/examples/jsm/postprocessing/SSAOPass.js +0 -3
  83. package/examples/jsm/renderers/common/Animation.js +3 -0
  84. package/examples/jsm/renderers/common/Background.js +3 -3
  85. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  86. package/examples/jsm/renderers/common/Info.js +11 -19
  87. package/examples/jsm/renderers/common/PostProcessing.js +12 -4
  88. package/examples/jsm/renderers/common/RenderContext.js +3 -1
  89. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  90. package/examples/jsm/renderers/common/RenderObject.js +46 -3
  91. package/examples/jsm/renderers/common/RenderObjects.js +2 -0
  92. package/examples/jsm/renderers/common/Renderer.js +113 -39
  93. package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
  94. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  95. package/examples/jsm/renderers/common/Textures.js +3 -13
  96. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  97. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
  98. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  99. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  100. package/examples/jsm/renderers/common/nodes/Nodes.js +6 -18
  101. package/examples/jsm/renderers/webgl/WebGLBackend.js +174 -30
  102. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
  103. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +136 -11
  104. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +8 -2
  105. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
  106. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +90 -0
  107. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -1
  108. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
  109. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
  110. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +67 -37
  111. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +20 -43
  112. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +32 -1
  113. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
  114. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +94 -20
  115. package/examples/jsm/shaders/OutputShader.js +4 -0
  116. package/examples/jsm/utils/GPUStatsPanel.js +10 -45
  117. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  118. package/examples/jsm/utils/TextureUtils.js +1 -1
  119. package/examples/jsm/webxr/VRButton.js +13 -5
  120. package/examples/jsm/webxr/XRButton.js +0 -1
  121. package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
  122. package/package.json +4 -3
  123. package/src/Three.Legacy.js +20 -0
  124. package/src/Three.js +0 -2
  125. package/src/animation/AnimationClip.js +1 -1
  126. package/src/constants.js +4 -7
  127. package/src/core/BufferAttribute.js +0 -11
  128. package/src/core/BufferGeometry.js +23 -29
  129. package/src/core/Object3D.js +21 -7
  130. package/src/core/Raycaster.js +18 -4
  131. package/src/core/RenderTarget.js +44 -21
  132. package/src/extras/PMREMGenerator.js +11 -0
  133. package/src/extras/curves/EllipseCurve.js +2 -2
  134. package/src/helpers/SpotLightHelper.js +18 -1
  135. package/src/loaders/DataTextureLoader.js +0 -4
  136. package/src/loaders/MaterialLoader.js +1 -0
  137. package/src/loaders/ObjectLoader.js +4 -1
  138. package/src/materials/Material.js +2 -1
  139. package/src/materials/MeshBasicMaterial.js +3 -0
  140. package/src/materials/MeshLambertMaterial.js +3 -0
  141. package/src/materials/MeshPhongMaterial.js +3 -0
  142. package/src/materials/MeshStandardMaterial.js +3 -0
  143. package/src/materials/ShaderMaterial.js +0 -4
  144. package/src/math/Quaternion.js +13 -12
  145. package/src/math/Spherical.js +4 -5
  146. package/src/math/Vector3.js +7 -7
  147. package/src/objects/BatchedMesh.js +4 -3
  148. package/src/objects/InstancedMesh.js +63 -0
  149. package/src/objects/Mesh.js +0 -1
  150. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  151. package/src/renderers/WebGLRenderer.js +70 -136
  152. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  153. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  154. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  155. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
  156. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  157. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
  158. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
  159. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  160. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  161. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  162. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
  163. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
  164. package/src/renderers/shaders/ShaderChunk.js +2 -0
  165. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  166. package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
  167. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
  168. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
  169. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
  170. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
  171. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
  172. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
  173. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
  174. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
  175. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
  176. package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
  177. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  178. package/src/renderers/shaders/ShaderLib.js +3 -2
  179. package/src/renderers/shaders/UniformsLib.js +1 -0
  180. package/src/renderers/shaders/UniformsUtils.js +10 -1
  181. package/src/renderers/webgl/WebGLAttributes.js +6 -33
  182. package/src/renderers/webgl/WebGLBackground.js +18 -0
  183. package/src/renderers/webgl/WebGLBindingStates.js +14 -51
  184. package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
  185. package/src/renderers/webgl/WebGLCapabilities.js +2 -12
  186. package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
  187. package/src/renderers/webgl/WebGLExtensions.js +4 -19
  188. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
  189. package/src/renderers/webgl/WebGLLights.js +6 -32
  190. package/src/renderers/webgl/WebGLMaterials.js +26 -4
  191. package/src/renderers/webgl/WebGLMorphtargets.js +79 -210
  192. package/src/renderers/webgl/WebGLProgram.js +30 -48
  193. package/src/renderers/webgl/WebGLPrograms.js +5 -14
  194. package/src/renderers/webgl/WebGLRenderStates.js +8 -6
  195. package/src/renderers/webgl/WebGLState.js +21 -75
  196. package/src/renderers/webgl/WebGLTextures.js +143 -275
  197. package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
  198. package/src/renderers/webgl/WebGLUtils.js +6 -57
  199. package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
  200. package/src/renderers/webxr/WebXRManager.js +2 -2
  201. package/src/scenes/Scene.js +14 -0
  202. package/src/textures/Texture.js +6 -24
  203. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  204. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
  205. package/src/renderers/WebGL1Renderer.js +0 -7
  206. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -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,11 +2,9 @@ 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';
9
- export { WebGL1Renderer } from './renderers/WebGL1Renderer.js';
10
8
  export { ShaderLib } from './renderers/shaders/ShaderLib.js';
11
9
  export { UniformsLib } from './renderers/shaders/UniformsLib.js';
12
10
  export { UniformsUtils } from './renderers/shaders/UniformsUtils.js';
@@ -11,7 +11,7 @@ import { NormalAnimationBlendMode } from '../constants.js';
11
11
 
12
12
  class AnimationClip {
13
13
 
14
- constructor( name, duration = - 1, tracks, blendMode = NormalAnimationBlendMode ) {
14
+ constructor( name = '', duration = - 1, tracks = [], blendMode = NormalAnimationBlendMode ) {
15
15
 
16
16
  this.name = name;
17
17
  this.tracks = tracks;
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '161';
1
+ export const REVISION = '163';
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 };
@@ -57,6 +57,7 @@ export const CineonToneMapping = 3;
57
57
  export const ACESFilmicToneMapping = 4;
58
58
  export const CustomToneMapping = 5;
59
59
  export const AgXToneMapping = 6;
60
+ export const NeutralToneMapping = 7;
60
61
  export const AttachedBindMode = 'attached';
61
62
  export const DetachedBindMode = 'detached';
62
63
 
@@ -90,7 +91,9 @@ export const HalfFloatType = 1016;
90
91
  export const UnsignedShort4444Type = 1017;
91
92
  export const UnsignedShort5551Type = 1018;
92
93
  export const UnsignedInt248Type = 1020;
94
+ export const UnsignedInt5999Type = 35902;
93
95
  export const AlphaFormat = 1021;
96
+ export const RGBFormat = 1022;
94
97
  export const RGBAFormat = 1023;
95
98
  export const LuminanceFormat = 1024;
96
99
  export const LuminanceAlphaFormat = 1025;
@@ -148,10 +151,6 @@ export const AdditiveAnimationBlendMode = 2501;
148
151
  export const TrianglesDrawMode = 0;
149
152
  export const TriangleStripDrawMode = 1;
150
153
  export const TriangleFanDrawMode = 2;
151
- /** @deprecated Use LinearSRGBColorSpace or NoColorSpace in three.js r152+. */
152
- export const LinearEncoding = 3000;
153
- /** @deprecated Use SRGBColorSpace in three.js r152+. */
154
- export const sRGBEncoding = 3001;
155
154
  export const BasicDepthPacking = 3200;
156
155
  export const RGBADepthPacking = 3201;
157
156
  export const TangentSpaceNormalMap = 0;
@@ -210,7 +209,5 @@ export const StreamCopyUsage = 35042;
210
209
  export const GLSL1 = '100';
211
210
  export const GLSL3 = '300 es';
212
211
 
213
- export const _SRGBAFormat = 1035; // fallback for WebGL 1
214
-
215
212
  export const WebGLCoordinateSystem = 2000;
216
213
  export const WebGPUCoordinateSystem = 2001;
@@ -623,20 +623,9 @@ class Float32BufferAttribute extends BufferAttribute {
623
623
 
624
624
  }
625
625
 
626
- class Float64BufferAttribute extends BufferAttribute {
627
-
628
- constructor( array, itemSize, normalized ) {
629
-
630
- super( new Float64Array( array ), itemSize, normalized );
631
-
632
- }
633
-
634
- }
635
-
636
626
  //
637
627
 
638
628
  export {
639
- Float64BufferAttribute,
640
629
  Float32BufferAttribute,
641
630
  Float16BufferAttribute,
642
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
 
@@ -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() {
@@ -330,17 +333,16 @@ class Object3D extends EventDispatcher {
330
333
 
331
334
  if ( object && object.isObject3D ) {
332
335
 
333
- if ( object.parent !== null ) {
334
-
335
- object.parent.remove( object );
336
-
337
- }
338
-
336
+ object.removeFromParent();
339
337
  object.parent = this;
340
338
  this.children.push( object );
341
339
 
342
340
  object.dispatchEvent( _addedEvent );
343
341
 
342
+ _childaddedEvent.child = object;
343
+ this.dispatchEvent( _childaddedEvent );
344
+ _childaddedEvent.child = null;
345
+
344
346
  } else {
345
347
 
346
348
  console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object );
@@ -374,6 +376,10 @@ class Object3D extends EventDispatcher {
374
376
 
375
377
  object.dispatchEvent( _removedEvent );
376
378
 
379
+ _childremovedEvent.child = object;
380
+ this.dispatchEvent( _childremovedEvent );
381
+ _childremovedEvent.child = null;
382
+
377
383
  }
378
384
 
379
385
  return this;
@@ -420,10 +426,18 @@ class Object3D extends EventDispatcher {
420
426
 
421
427
  object.applyMatrix4( _m1 );
422
428
 
423
- this.add( object );
429
+ object.removeFromParent();
430
+ object.parent = this;
431
+ this.children.push( object );
424
432
 
425
433
  object.updateWorldMatrix( false, true );
426
434
 
435
+ object.dispatchEvent( _addedEvent );
436
+
437
+ _childaddedEvent.child = object;
438
+ this.dispatchEvent( _childaddedEvent );
439
+ _childaddedEvent.child = null;
440
+
427
441
  return this;
428
442
 
429
443
  }
@@ -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
 
@@ -1,9 +1,8 @@
1
1
  import { EventDispatcher } from './EventDispatcher.js';
2
2
  import { Texture } from '../textures/Texture.js';
3
- import { LinearFilter, NoColorSpace, SRGBColorSpace, sRGBEncoding } from '../constants.js';
3
+ import { LinearFilter } from '../constants.js';
4
4
  import { Vector4 } from '../math/Vector4.js';
5
5
  import { Source } from '../textures/Source.js';
6
- import { warnOnce } from '../utils.js';
7
6
 
8
7
  /*
9
8
  In options, we can specify:
@@ -29,14 +28,6 @@ class RenderTarget extends EventDispatcher {
29
28
 
30
29
  const image = { width: width, height: height, depth: 1 };
31
30
 
32
- if ( options.encoding !== undefined ) {
33
-
34
- // @deprecated, r152
35
- warnOnce( 'THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace.' );
36
- options.colorSpace = options.encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
37
-
38
- }
39
-
40
31
  options = Object.assign( {
41
32
  generateMipmaps: false,
42
33
  internalFormat: null,
@@ -44,15 +35,25 @@ class RenderTarget extends EventDispatcher {
44
35
  depthBuffer: true,
45
36
  stencilBuffer: false,
46
37
  depthTexture: null,
47
- samples: 0
38
+ samples: 0,
39
+ count: 1
48
40
  }, options );
49
41
 
50
- this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
51
- this.texture.isRenderTargetTexture = true;
42
+ const texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
43
+
44
+ texture.flipY = false;
45
+ texture.generateMipmaps = options.generateMipmaps;
46
+ texture.internalFormat = options.internalFormat;
47
+
48
+ this.textures = [];
52
49
 
53
- this.texture.flipY = false;
54
- this.texture.generateMipmaps = options.generateMipmaps;
55
- this.texture.internalFormat = options.internalFormat;
50
+ const count = options.count;
51
+ for ( let i = 0; i < count; i ++ ) {
52
+
53
+ this.textures[ i ] = texture.clone();
54
+ this.textures[ i ].isRenderTargetTexture = true;
55
+
56
+ }
56
57
 
57
58
  this.depthBuffer = options.depthBuffer;
58
59
  this.stencilBuffer = options.stencilBuffer;
@@ -63,6 +64,18 @@ class RenderTarget extends EventDispatcher {
63
64
 
64
65
  }
65
66
 
67
+ get texture() {
68
+
69
+ return this.textures[ 0 ];
70
+
71
+ }
72
+
73
+ set texture( value ) {
74
+
75
+ this.textures[ 0 ] = value;
76
+
77
+ }
78
+
66
79
  setSize( width, height, depth = 1 ) {
67
80
 
68
81
  if ( this.width !== width || this.height !== height || this.depth !== depth ) {
@@ -71,9 +84,13 @@ class RenderTarget extends EventDispatcher {
71
84
  this.height = height;
72
85
  this.depth = depth;
73
86
 
74
- this.texture.image.width = width;
75
- this.texture.image.height = height;
76
- this.texture.image.depth = depth;
87
+ for ( let i = 0, il = this.textures.length; i < il; i ++ ) {
88
+
89
+ this.textures[ i ].image.width = width;
90
+ this.textures[ i ].image.height = height;
91
+ this.textures[ i ].image.depth = depth;
92
+
93
+ }
77
94
 
78
95
  this.dispose();
79
96
 
@@ -101,8 +118,14 @@ class RenderTarget extends EventDispatcher {
101
118
 
102
119
  this.viewport.copy( source.viewport );
103
120
 
104
- this.texture = source.texture.clone();
105
- this.texture.isRenderTargetTexture = true;
121
+ this.textures.length = 0;
122
+
123
+ for ( let i = 0, il = source.textures.length; i < il; i ++ ) {
124
+
125
+ this.textures[ i ] = source.textures[ i ].clone();
126
+ this.textures[ i ].isRenderTargetTexture = true;
127
+
128
+ }
106
129
 
107
130
  // ensure image object is not shared, see #20328
108
131
 
@@ -40,6 +40,7 @@ const _clearColor = /*@__PURE__*/ new Color();
40
40
  let _oldTarget = null;
41
41
  let _oldActiveCubeFace = 0;
42
42
  let _oldActiveMipmapLevel = 0;
43
+ let _oldXrEnabled = false;
43
44
 
44
45
  // Golden Ratio
45
46
  const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
@@ -107,6 +108,9 @@ class PMREMGenerator {
107
108
  _oldTarget = this._renderer.getRenderTarget();
108
109
  _oldActiveCubeFace = this._renderer.getActiveCubeFace();
109
110
  _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
111
+ _oldXrEnabled = this._renderer.xr.enabled;
112
+
113
+ this._renderer.xr.enabled = false;
110
114
 
111
115
  this._setSize( 256 );
112
116
 
@@ -132,6 +136,7 @@ class PMREMGenerator {
132
136
  * Generates a PMREM from an equirectangular texture, which can be either LDR
133
137
  * or HDR. The ideal input image size is 1k (1024 x 512),
134
138
  * as this matches best with the 256 x 256 cubemap output.
139
+ * The smallest supported equirectangular image size is 64 x 32.
135
140
  */
136
141
  fromEquirectangular( equirectangular, renderTarget = null ) {
137
142
 
@@ -143,6 +148,7 @@ class PMREMGenerator {
143
148
  * Generates a PMREM from an cubemap texture, which can be either LDR
144
149
  * or HDR. The ideal input cube size is 256 x 256,
145
150
  * as this matches best with the 256 x 256 cubemap output.
151
+ * The smallest supported cube size is 16 x 16.
146
152
  */
147
153
  fromCubemap( cubemap, renderTarget = null ) {
148
154
 
@@ -220,6 +226,8 @@ class PMREMGenerator {
220
226
  _cleanup( outputTarget ) {
221
227
 
222
228
  this._renderer.setRenderTarget( _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel );
229
+ this._renderer.xr.enabled = _oldXrEnabled;
230
+
223
231
  outputTarget.scissorTest = false;
224
232
  _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
225
233
 
@@ -240,6 +248,9 @@ class PMREMGenerator {
240
248
  _oldTarget = this._renderer.getRenderTarget();
241
249
  _oldActiveCubeFace = this._renderer.getActiveCubeFace();
242
250
  _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
251
+ _oldXrEnabled = this._renderer.xr.enabled;
252
+
253
+ this._renderer.xr.enabled = false;
243
254
 
244
255
  const cubeUVRenderTarget = renderTarget || this._allocateTargets();
245
256
  this._textureToCubeUV( texture, cubeUVRenderTarget );
@@ -26,9 +26,9 @@ class EllipseCurve extends Curve {
26
26
 
27
27
  }
28
28
 
29
- getPoint( t, optionalTarget ) {
29
+ getPoint( t, optionalTarget = new Vector2() ) {
30
30
 
31
- const point = optionalTarget || new Vector2();
31
+ const point = optionalTarget;
32
32
 
33
33
  const twoPi = Math.PI * 2;
34
34
  let deltaAngle = this.aEndAngle - this.aStartAngle;
@@ -15,7 +15,6 @@ class SpotLightHelper extends Object3D {
15
15
 
16
16
  this.light = light;
17
17
 
18
- this.matrix = light.matrixWorld;
19
18
  this.matrixAutoUpdate = false;
20
19
 
21
20
  this.color = color;
@@ -67,6 +66,24 @@ class SpotLightHelper extends Object3D {
67
66
  this.light.updateWorldMatrix( true, false );
68
67
  this.light.target.updateWorldMatrix( true, false );
69
68
 
69
+ // update the local matrix based on the parent and light target transforms
70
+ if ( this.parent ) {
71
+
72
+ this.parent.updateWorldMatrix( true );
73
+
74
+ this.matrix
75
+ .copy( this.parent.matrixWorld )
76
+ .invert()
77
+ .multiply( this.light.matrixWorld );
78
+
79
+ } else {
80
+
81
+ this.matrix.copy( this.light.matrixWorld );
82
+
83
+ }
84
+
85
+ this.matrixWorld.copy( this.light.matrixWorld );
86
+
70
87
  const coneLength = this.light.distance ? this.light.distance : 1000;
71
88
  const coneWidth = coneLength * Math.tan( this.light.angle );
72
89
 
@@ -75,10 +75,6 @@ class DataTextureLoader extends Loader {
75
75
 
76
76
  texture.colorSpace = texData.colorSpace;
77
77
 
78
- } else if ( texData.encoding !== undefined ) { // @deprecated, r152
79
-
80
- texture.encoding = texData.encoding;
81
-
82
78
  }
83
79
 
84
80
  if ( texData.flipY !== undefined ) {
@@ -300,6 +300,7 @@ class MaterialLoader extends Loader {
300
300
  if ( json.specularColorMap !== undefined ) material.specularColorMap = getTexture( json.specularColorMap );
301
301
 
302
302
  if ( json.envMap !== undefined ) material.envMap = getTexture( json.envMap );
303
+ if ( json.envMapRotation !== undefined ) material.envMapRotation.fromArray( json.envMapRotation );
303
304
  if ( json.envMapIntensity !== undefined ) material.envMapIntensity = json.envMapIntensity;
304
305
 
305
306
  if ( json.reflectivity !== undefined ) material.reflectivity = json.reflectivity;
@@ -674,7 +674,6 @@ class ObjectLoader extends Loader {
674
674
  if ( data.internalFormat !== undefined ) texture.internalFormat = data.internalFormat;
675
675
  if ( data.type !== undefined ) texture.type = data.type;
676
676
  if ( data.colorSpace !== undefined ) texture.colorSpace = data.colorSpace;
677
- if ( data.encoding !== undefined ) texture.encoding = data.encoding; // @deprecated, r152
678
677
 
679
678
  if ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter, TEXTURE_FILTER );
680
679
  if ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter, TEXTURE_FILTER );
@@ -813,6 +812,10 @@ class ObjectLoader extends Loader {
813
812
 
814
813
  if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
815
814
  if ( data.backgroundIntensity !== undefined ) object.backgroundIntensity = data.backgroundIntensity;
815
+ if ( data.backgroundRotation !== undefined ) object.backgroundRotation.fromArray( data.backgroundRotation );
816
+
817
+ if ( data.environmentIntensity !== undefined ) object.environmentIntensity = data.environmentIntensity;
818
+ if ( data.environmentRotation !== undefined ) object.environmentRotation.fromArray( data.environmentRotation );
816
819
 
817
820
  break;
818
821
 
@@ -190,7 +190,7 @@ class Material extends EventDispatcher {
190
190
  if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();
191
191
  if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;
192
192
  if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
193
- if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
193
+ if ( this.emissiveIntensity !== undefined && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
194
194
 
195
195
  if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
196
196
  if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;
@@ -300,6 +300,7 @@ class Material extends EventDispatcher {
300
300
 
301
301
  }
302
302
 
303
+ if ( this.envMapRotation !== undefined ) data.envMapRotation = this.envMapRotation.toArray();
303
304
  if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;
304
305
  if ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity;
305
306
  if ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio;
@@ -1,6 +1,7 @@
1
1
  import { Material } from './Material.js';
2
2
  import { MultiplyOperation } from '../constants.js';
3
3
  import { Color } from '../math/Color.js';
4
+ import { Euler } from '../math/Euler.js';
4
5
 
5
6
  class MeshBasicMaterial extends Material {
6
7
 
@@ -27,6 +28,7 @@ class MeshBasicMaterial extends Material {
27
28
  this.alphaMap = null;
28
29
 
29
30
  this.envMap = null;
31
+ this.envMapRotation = new Euler();
30
32
  this.combine = MultiplyOperation;
31
33
  this.reflectivity = 1;
32
34
  this.refractionRatio = 0.98;
@@ -61,6 +63,7 @@ class MeshBasicMaterial extends Material {
61
63
  this.alphaMap = source.alphaMap;
62
64
 
63
65
  this.envMap = source.envMap;
66
+ this.envMapRotation.copy( source.envMapRotation );
64
67
  this.combine = source.combine;
65
68
  this.reflectivity = source.reflectivity;
66
69
  this.refractionRatio = source.refractionRatio;
@@ -2,6 +2,7 @@ import { MultiplyOperation, TangentSpaceNormalMap } from '../constants.js';
2
2
  import { Material } from './Material.js';
3
3
  import { Vector2 } from '../math/Vector2.js';
4
4
  import { Color } from '../math/Color.js';
5
+ import { Euler } from '../math/Euler.js';
5
6
 
6
7
  class MeshLambertMaterial extends Material {
7
8
 
@@ -43,6 +44,7 @@ class MeshLambertMaterial extends Material {
43
44
  this.alphaMap = null;
44
45
 
45
46
  this.envMap = null;
47
+ this.envMapRotation = new Euler();
46
48
  this.combine = MultiplyOperation;
47
49
  this.reflectivity = 1;
48
50
  this.refractionRatio = 0.98;
@@ -94,6 +96,7 @@ class MeshLambertMaterial extends Material {
94
96
  this.alphaMap = source.alphaMap;
95
97
 
96
98
  this.envMap = source.envMap;
99
+ this.envMapRotation.copy( source.envMapRotation );
97
100
  this.combine = source.combine;
98
101
  this.reflectivity = source.reflectivity;
99
102
  this.refractionRatio = source.refractionRatio;