super-three 0.170.0 → 0.171.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 (172) hide show
  1. package/build/three.cjs +24410 -24422
  2. package/build/three.core.js +37002 -0
  3. package/build/three.core.min.js +6 -0
  4. package/build/three.module.js +10573 -47578
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +533 -0
  7. package/build/three.tsl.min.js +6 -0
  8. package/build/three.webgpu.js +2907 -37975
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2914 -37959
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/capabilities/WebGPU.js +1 -10
  13. package/examples/jsm/controls/ArcballControls.js +25 -21
  14. package/examples/jsm/controls/OrbitControls.js +41 -9
  15. package/examples/jsm/controls/PointerLockControls.js +2 -5
  16. package/examples/jsm/csm/CSMShadowNode.js +7 -5
  17. package/examples/jsm/geometries/DecalGeometry.js +5 -1
  18. package/examples/jsm/lighting/TiledLighting.js +1 -1
  19. package/examples/jsm/lines/LineGeometry.js +25 -0
  20. package/examples/jsm/lines/LineMaterial.js +1 -7
  21. package/examples/jsm/lines/webgpu/Line2.js +2 -1
  22. package/examples/jsm/lines/webgpu/LineSegments2.js +2 -1
  23. package/examples/jsm/lines/webgpu/Wireframe.js +2 -1
  24. package/examples/jsm/loaders/KTX2Loader.js +3 -0
  25. package/examples/jsm/loaders/MMDLoader.js +2 -6
  26. package/examples/jsm/loaders/MaterialXLoader.js +2 -2
  27. package/examples/jsm/materials/MeshGouraudMaterial.js +2 -6
  28. package/examples/jsm/misc/ProgressiveLightMapGPU.js +2 -2
  29. package/examples/jsm/objects/InstancedPoints.js +2 -4
  30. package/examples/jsm/objects/LensflareMesh.js +4 -2
  31. package/examples/jsm/objects/SkyMesh.js +5 -3
  32. package/examples/jsm/objects/Water2Mesh.js +7 -3
  33. package/examples/jsm/objects/WaterMesh.js +5 -3
  34. package/examples/jsm/transpiler/AST.js +2 -2
  35. package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
  36. package/examples/jsm/transpiler/TSLEncoder.js +11 -6
  37. package/examples/jsm/tsl/display/AfterImageNode.js +3 -3
  38. package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -2
  39. package/examples/jsm/tsl/display/AnamorphicNode.js +2 -2
  40. package/examples/jsm/tsl/display/BloomNode.js +3 -3
  41. package/examples/jsm/tsl/display/DenoiseNode.js +48 -12
  42. package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -2
  43. package/examples/jsm/tsl/display/DotScreenNode.js +2 -2
  44. package/examples/jsm/tsl/display/FXAANode.js +3 -3
  45. package/examples/jsm/tsl/display/FilmNode.js +3 -2
  46. package/examples/jsm/tsl/display/GTAONode.js +62 -27
  47. package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
  48. package/examples/jsm/tsl/display/LensflareNode.js +3 -3
  49. package/examples/jsm/tsl/display/Lut3DNode.js +3 -2
  50. package/examples/jsm/tsl/display/OutlineNode.js +2 -2
  51. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -1
  52. package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
  53. package/examples/jsm/tsl/display/RGBShiftNode.js +2 -1
  54. package/examples/jsm/tsl/display/SMAANode.js +3 -3
  55. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  56. package/examples/jsm/tsl/display/SSRNode.js +31 -8
  57. package/examples/jsm/tsl/display/SobelOperatorNode.js +3 -3
  58. package/examples/jsm/tsl/display/StereoCompositePassNode.js +4 -4
  59. package/examples/jsm/tsl/display/StereoPassNode.js +2 -2
  60. package/examples/jsm/tsl/display/TRAAPassNode.js +2 -2
  61. package/examples/jsm/tsl/display/TransitionNode.js +3 -2
  62. package/examples/jsm/tsl/lighting/TiledLightsNode.js +6 -9
  63. package/examples/jsm/utils/SceneOptimizer.js +410 -0
  64. package/examples/jsm/utils/UVsDebug.js +1 -1
  65. package/package.json +3 -3
  66. package/src/Three.Core.js +178 -0
  67. package/src/Three.TSL.js +526 -0
  68. package/src/Three.WebGPU.Nodes.js +5 -186
  69. package/src/Three.WebGPU.js +4 -186
  70. package/src/Three.js +1 -177
  71. package/src/animation/AnimationClip.js +2 -2
  72. package/src/animation/AnimationObjectGroup.js +2 -2
  73. package/src/audio/Audio.js +38 -0
  74. package/src/cameras/PerspectiveCamera.js +6 -6
  75. package/src/cameras/StereoCamera.js +2 -2
  76. package/src/constants.js +1 -1
  77. package/src/core/BufferGeometry.js +5 -3
  78. package/src/core/InterleavedBuffer.js +4 -4
  79. package/src/core/Object3D.js +2 -2
  80. package/src/extras/core/Curve.js +3 -3
  81. package/src/extras/core/Shape.js +2 -2
  82. package/src/geometries/EdgesGeometry.js +2 -2
  83. package/src/geometries/LatheGeometry.js +2 -2
  84. package/src/lights/SpotLightShadow.js +2 -2
  85. package/src/materials/LineBasicMaterial.js +2 -6
  86. package/src/materials/LineDashedMaterial.js +1 -6
  87. package/src/materials/Material.js +3 -16
  88. package/src/materials/MeshBasicMaterial.js +2 -6
  89. package/src/materials/MeshDepthMaterial.js +2 -6
  90. package/src/materials/MeshDistanceMaterial.js +2 -6
  91. package/src/materials/MeshLambertMaterial.js +2 -6
  92. package/src/materials/MeshMatcapMaterial.js +2 -6
  93. package/src/materials/MeshNormalMaterial.js +2 -6
  94. package/src/materials/MeshPhongMaterial.js +3 -7
  95. package/src/materials/MeshPhysicalMaterial.js +4 -8
  96. package/src/materials/MeshStandardMaterial.js +2 -6
  97. package/src/materials/MeshToonMaterial.js +2 -6
  98. package/src/materials/PointsMaterial.js +2 -6
  99. package/src/materials/RawShaderMaterial.js +2 -6
  100. package/src/materials/ShaderMaterial.js +2 -6
  101. package/src/materials/ShadowMaterial.js +2 -6
  102. package/src/materials/SpriteMaterial.js +2 -6
  103. package/src/materials/nodes/Line2NodeMaterial.js +32 -13
  104. package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
  105. package/src/materials/nodes/NodeMaterial.js +64 -16
  106. package/src/materials/nodes/manager/NodeMaterialObserver.js +13 -10
  107. package/src/math/ColorManagement.js +130 -122
  108. package/src/math/Line3.js +2 -2
  109. package/src/math/Quaternion.js +2 -2
  110. package/src/math/Spherical.js +3 -3
  111. package/src/math/Vector2.js +7 -7
  112. package/src/math/Vector3.js +9 -9
  113. package/src/math/Vector4.js +11 -9
  114. package/src/nodes/Nodes.js +1 -0
  115. package/src/nodes/TSL.js +3 -1
  116. package/src/nodes/accessors/Arrays.js +27 -0
  117. package/src/nodes/accessors/BuiltinNode.js +26 -0
  118. package/src/nodes/accessors/ClippingNode.js +76 -42
  119. package/src/nodes/accessors/InstanceNode.js +17 -20
  120. package/src/nodes/accessors/InstancedMeshNode.js +26 -0
  121. package/src/nodes/accessors/Lights.js +32 -0
  122. package/src/nodes/accessors/StorageBufferNode.js +29 -9
  123. package/src/nodes/accessors/StorageTextureNode.js +10 -4
  124. package/src/nodes/accessors/TextureNode.js +1 -1
  125. package/src/nodes/core/NodeBuilder.js +2 -9
  126. package/src/nodes/core/NodeUtils.js +28 -0
  127. package/src/nodes/core/constants.js +6 -0
  128. package/src/nodes/display/BlendModes.js +99 -0
  129. package/src/nodes/display/ToonOutlinePassNode.js +3 -3
  130. package/src/nodes/display/ViewportDepthNode.js +21 -6
  131. package/src/nodes/functions/material/getAlphaHashThreshold.js +13 -7
  132. package/src/nodes/functions/material/getParallaxCorrectNormal.js +1 -1
  133. package/src/nodes/lighting/AnalyticLightNode.js +12 -4
  134. package/src/nodes/lighting/PointLightNode.js +10 -1
  135. package/src/nodes/lighting/PointShadowNode.js +254 -0
  136. package/src/nodes/lighting/ShadowNode.js +176 -67
  137. package/src/nodes/lighting/SpotLightNode.js +14 -2
  138. package/src/nodes/utils/RTTNode.js +9 -1
  139. package/src/nodes/utils/StorageArrayElementNode.js +2 -2
  140. package/src/objects/BatchedMesh.js +54 -95
  141. package/src/objects/ClippingGroup.js +19 -0
  142. package/src/objects/Skeleton.js +2 -2
  143. package/src/renderers/WebGLRenderer.js +94 -23
  144. package/src/renderers/common/Animation.js +23 -11
  145. package/src/renderers/common/Background.js +1 -1
  146. package/src/renderers/common/Bindings.js +20 -4
  147. package/src/renderers/common/ClippingContext.js +77 -85
  148. package/src/renderers/common/RenderList.js +9 -6
  149. package/src/renderers/common/RenderObject.js +27 -27
  150. package/src/renderers/common/RenderObjects.js +12 -6
  151. package/src/renderers/common/Renderer.js +63 -57
  152. package/src/renderers/common/Textures.js +11 -3
  153. package/src/renderers/common/UniformsGroup.js +16 -4
  154. package/src/renderers/common/extras/PMREMGenerator.js +89 -13
  155. package/src/renderers/common/nodes/NodeLibrary.js +2 -2
  156. package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
  157. package/src/renderers/common/nodes/NodeUniform.js +42 -0
  158. package/src/renderers/webgl/WebGLBackground.js +20 -1
  159. package/src/renderers/webgl/WebGLGeometries.js +0 -28
  160. package/src/renderers/webgl-fallback/WebGLBackend.js +13 -6
  161. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
  162. package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
  163. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +4 -1
  164. package/src/renderers/webgpu/WebGPUBackend.js +47 -31
  165. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -26
  166. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +184 -74
  167. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
  168. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
  169. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -1
  170. package/src/textures/Source.js +2 -2
  171. package/src/textures/Texture.js +2 -2
  172. package/src/nodes/display/BlendMode.js +0 -54
@@ -328,6 +328,7 @@ class Audio extends Object3D {
328
328
  onEnded() {
329
329
 
330
330
  this.isPlaying = false;
331
+ this._progress = 0;
331
332
 
332
333
  }
333
334
 
@@ -395,6 +396,43 @@ class Audio extends Object3D {
395
396
 
396
397
  }
397
398
 
399
+ copy( source, recursive ) {
400
+
401
+ super.copy( source, recursive );
402
+
403
+ if ( source.sourceType !== 'buffer' ) {
404
+
405
+ console.warn( 'THREE.Audio: Audio source type cannot be copied.' );
406
+
407
+ return this;
408
+
409
+ }
410
+
411
+ this.autoplay = source.autoplay;
412
+
413
+ this.buffer = source.buffer;
414
+ this.detune = source.detune;
415
+ this.loop = source.loop;
416
+ this.loopStart = source.loopStart;
417
+ this.loopEnd = source.loopEnd;
418
+ this.offset = source.offset;
419
+ this.duration = source.duration;
420
+ this.playbackRate = source.playbackRate;
421
+ this.hasPlaybackControl = source.hasPlaybackControl;
422
+ this.sourceType = source.sourceType;
423
+
424
+ this.filters = source.filters.slice();
425
+
426
+ return this;
427
+
428
+ }
429
+
430
+ clone( recursive ) {
431
+
432
+ return new this.constructor( this.listener ).copy( this, recursive );
433
+
434
+ }
435
+
398
436
  }
399
437
 
400
438
  export { Audio };
@@ -1,5 +1,5 @@
1
1
  import { Camera } from './Camera.js';
2
- import * as MathUtils from '../math/MathUtils.js';
2
+ import { RAD2DEG, DEG2RAD } from '../math/MathUtils.js';
3
3
  import { Vector2 } from '../math/Vector2.js';
4
4
  import { Vector3 } from '../math/Vector3.js';
5
5
 
@@ -69,7 +69,7 @@ class PerspectiveCamera extends Camera {
69
69
  /** see {@link http://www.bobatkins.com/photography/technical/field_of_view.html} */
70
70
  const vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
71
71
 
72
- this.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope );
72
+ this.fov = RAD2DEG * 2 * Math.atan( vExtentSlope );
73
73
  this.updateProjectionMatrix();
74
74
 
75
75
  }
@@ -79,7 +79,7 @@ class PerspectiveCamera extends Camera {
79
79
  */
80
80
  getFocalLength() {
81
81
 
82
- const vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov );
82
+ const vExtentSlope = Math.tan( DEG2RAD * 0.5 * this.fov );
83
83
 
84
84
  return 0.5 * this.getFilmHeight() / vExtentSlope;
85
85
 
@@ -87,8 +87,8 @@ class PerspectiveCamera extends Camera {
87
87
 
88
88
  getEffectiveFOV() {
89
89
 
90
- return MathUtils.RAD2DEG * 2 * Math.atan(
91
- Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom );
90
+ return RAD2DEG * 2 * Math.atan(
91
+ Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom );
92
92
 
93
93
  }
94
94
 
@@ -214,7 +214,7 @@ class PerspectiveCamera extends Camera {
214
214
  updateProjectionMatrix() {
215
215
 
216
216
  const near = this.near;
217
- let top = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom;
217
+ let top = near * Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom;
218
218
  let height = 2 * top;
219
219
  let width = this.aspect * height;
220
220
  let left = - 0.5 * width;
@@ -1,5 +1,5 @@
1
1
  import { Matrix4 } from '../math/Matrix4.js';
2
- import * as MathUtils from '../math/MathUtils.js';
2
+ import { DEG2RAD } from '../math/MathUtils.js';
3
3
  import { PerspectiveCamera } from './PerspectiveCamera.js';
4
4
 
5
5
  const _eyeRight = /*@__PURE__*/ new Matrix4();
@@ -60,7 +60,7 @@ class StereoCamera {
60
60
  _projectionMatrix.copy( camera.projectionMatrix );
61
61
  const eyeSepHalf = cache.eyeSep / 2;
62
62
  const eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
63
- const ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;
63
+ const ymax = ( cache.near * Math.tan( DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;
64
64
  let xmin, xmax;
65
65
 
66
66
  // translate xOffset
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '170';
1
+ export const REVISION = '171';
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 };
@@ -7,7 +7,7 @@ import { Sphere } from '../math/Sphere.js';
7
7
  import { Object3D } from './Object3D.js';
8
8
  import { Matrix4 } from '../math/Matrix4.js';
9
9
  import { Matrix3 } from '../math/Matrix3.js';
10
- import * as MathUtils from '../math/MathUtils.js';
10
+ import { generateUUID } from '../math/MathUtils.js';
11
11
  import { arrayNeedsUint32 } from '../utils.js';
12
12
 
13
13
  let _id = 0;
@@ -29,7 +29,7 @@ class BufferGeometry extends EventDispatcher {
29
29
 
30
30
  Object.defineProperty( this, 'id', { value: _id ++ } );
31
31
 
32
- this.uuid = MathUtils.generateUUID();
32
+ this.uuid = generateUUID();
33
33
 
34
34
  this.name = '';
35
35
  this.type = 'BufferGeometry';
@@ -304,7 +304,9 @@ class BufferGeometry extends EventDispatcher {
304
304
 
305
305
  } else {
306
306
 
307
- for ( let i = 0, l = positionAttribute.count; i < l; i ++ ) {
307
+ const l = Math.min( points.length, positionAttribute.count ); // make sure data do not exceed buffer size
308
+
309
+ for ( let i = 0; i < l; i ++ ) {
308
310
 
309
311
  const point = points[ i ];
310
312
  positionAttribute.setXYZ( i, point.x, point.y, point.z || 0 );
@@ -1,4 +1,4 @@
1
- import * as MathUtils from '../math/MathUtils.js';
1
+ import { generateUUID } from '../math/MathUtils.js';
2
2
  import { StaticDrawUsage } from '../constants.js';
3
3
 
4
4
  class InterleavedBuffer {
@@ -16,7 +16,7 @@ class InterleavedBuffer {
16
16
 
17
17
  this.version = 0;
18
18
 
19
- this.uuid = MathUtils.generateUUID();
19
+ this.uuid = generateUUID();
20
20
 
21
21
  }
22
22
 
@@ -92,7 +92,7 @@ class InterleavedBuffer {
92
92
 
93
93
  if ( this.array.buffer._uuid === undefined ) {
94
94
 
95
- this.array.buffer._uuid = MathUtils.generateUUID();
95
+ this.array.buffer._uuid = generateUUID();
96
96
 
97
97
  }
98
98
 
@@ -131,7 +131,7 @@ class InterleavedBuffer {
131
131
 
132
132
  if ( this.array.buffer._uuid === undefined ) {
133
133
 
134
- this.array.buffer._uuid = MathUtils.generateUUID();
134
+ this.array.buffer._uuid = generateUUID();
135
135
 
136
136
  }
137
137
 
@@ -5,7 +5,7 @@ import { EventDispatcher } from './EventDispatcher.js';
5
5
  import { Euler } from '../math/Euler.js';
6
6
  import { Layers } from './Layers.js';
7
7
  import { Matrix3 } from '../math/Matrix3.js';
8
- import * as MathUtils from '../math/MathUtils.js';
8
+ import { generateUUID } from '../math/MathUtils.js';
9
9
 
10
10
  let _object3DId = 0;
11
11
 
@@ -38,7 +38,7 @@ class Object3D extends EventDispatcher {
38
38
 
39
39
  Object.defineProperty( this, 'id', { value: _object3DId ++ } );
40
40
 
41
- this.uuid = MathUtils.generateUUID();
41
+ this.uuid = generateUUID();
42
42
 
43
43
  this.name = '';
44
44
  this.type = 'Object3D';
@@ -1,4 +1,4 @@
1
- import * as MathUtils from '../../math/MathUtils.js';
1
+ import { clamp } from '../../math/MathUtils.js';
2
2
  import { Vector2 } from '../../math/Vector2.js';
3
3
  import { Vector3 } from '../../math/Vector3.js';
4
4
  import { Matrix4 } from '../../math/Matrix4.js';
@@ -330,7 +330,7 @@ class Curve {
330
330
 
331
331
  vec.normalize();
332
332
 
333
- const theta = Math.acos( MathUtils.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
333
+ const theta = Math.acos( clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
334
334
 
335
335
  normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
336
336
 
@@ -344,7 +344,7 @@ class Curve {
344
344
 
345
345
  if ( closed === true ) {
346
346
 
347
- let theta = Math.acos( MathUtils.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
347
+ let theta = Math.acos( clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
348
348
  theta /= segments;
349
349
 
350
350
  if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) {
@@ -1,5 +1,5 @@
1
1
  import { Path } from './Path.js';
2
- import * as MathUtils from '../../math/MathUtils.js';
2
+ import { generateUUID } from '../../math/MathUtils.js';
3
3
 
4
4
  class Shape extends Path {
5
5
 
@@ -7,7 +7,7 @@ class Shape extends Path {
7
7
 
8
8
  super( points );
9
9
 
10
- this.uuid = MathUtils.generateUUID();
10
+ this.uuid = generateUUID();
11
11
 
12
12
  this.type = 'Shape';
13
13
 
@@ -1,6 +1,6 @@
1
1
  import { BufferGeometry } from '../core/BufferGeometry.js';
2
2
  import { Float32BufferAttribute } from '../core/BufferAttribute.js';
3
- import * as MathUtils from '../math/MathUtils.js';
3
+ import { DEG2RAD } from '../math/MathUtils.js';
4
4
  import { Triangle } from '../math/Triangle.js';
5
5
  import { Vector3 } from '../math/Vector3.js';
6
6
 
@@ -26,7 +26,7 @@ class EdgesGeometry extends BufferGeometry {
26
26
 
27
27
  const precisionPoints = 4;
28
28
  const precision = Math.pow( 10, precisionPoints );
29
- const thresholdDot = Math.cos( MathUtils.DEG2RAD * thresholdAngle );
29
+ const thresholdDot = Math.cos( DEG2RAD * thresholdAngle );
30
30
 
31
31
  const indexAttr = geometry.getIndex();
32
32
  const positionAttr = geometry.getAttribute( 'position' );
@@ -2,7 +2,7 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
2
2
  import { BufferGeometry } from '../core/BufferGeometry.js';
3
3
  import { Vector3 } from '../math/Vector3.js';
4
4
  import { Vector2 } from '../math/Vector2.js';
5
- import * as MathUtils from '../math/MathUtils.js';
5
+ import { clamp } from '../math/MathUtils.js';
6
6
 
7
7
  class LatheGeometry extends BufferGeometry {
8
8
 
@@ -23,7 +23,7 @@ class LatheGeometry extends BufferGeometry {
23
23
 
24
24
  // clamp phiLength so it's in range of [ 0, 2PI ]
25
25
 
26
- phiLength = MathUtils.clamp( phiLength, 0, Math.PI * 2 );
26
+ phiLength = clamp( phiLength, 0, Math.PI * 2 );
27
27
 
28
28
  // buffers
29
29
 
@@ -1,5 +1,5 @@
1
1
  import { LightShadow } from './LightShadow.js';
2
- import * as MathUtils from '../math/MathUtils.js';
2
+ import { RAD2DEG } from '../math/MathUtils.js';
3
3
  import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
4
4
 
5
5
  class SpotLightShadow extends LightShadow {
@@ -18,7 +18,7 @@ class SpotLightShadow extends LightShadow {
18
18
 
19
19
  const camera = this.camera;
20
20
 
21
- const fov = MathUtils.RAD2DEG * 2 * light.angle * this.focus;
21
+ const fov = RAD2DEG * 2 * light.angle * this.focus;
22
22
  const aspect = this.mapSize.width / this.mapSize.height;
23
23
  const far = light.distance || camera.far;
24
24
 
@@ -3,18 +3,14 @@ import { Color } from '../math/Color.js';
3
3
 
4
4
  class LineBasicMaterial extends Material {
5
5
 
6
- static get type() {
7
-
8
- return 'LineBasicMaterial';
9
-
10
- }
11
-
12
6
  constructor( parameters ) {
13
7
 
14
8
  super();
15
9
 
16
10
  this.isLineBasicMaterial = true;
17
11
 
12
+ this.type = 'LineBasicMaterial';
13
+
18
14
  this.color = new Color( 0xffffff );
19
15
 
20
16
  this.map = null;
@@ -2,17 +2,12 @@ import { LineBasicMaterial } from './LineBasicMaterial.js';
2
2
 
3
3
  class LineDashedMaterial extends LineBasicMaterial {
4
4
 
5
- static get type() {
6
-
7
- return 'LineDashedMaterial';
8
-
9
- }
10
-
11
5
  constructor( parameters ) {
12
6
 
13
7
  super();
14
8
 
15
9
  this.isLineDashedMaterial = true;
10
+ this.type = 'LineDashedMaterial';
16
11
 
17
12
  this.scale = 1;
18
13
  this.dashSize = 3;
@@ -1,26 +1,12 @@
1
1
  import { Color } from '../math/Color.js';
2
2
  import { EventDispatcher } from '../core/EventDispatcher.js';
3
3
  import { FrontSide, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';
4
- import * as MathUtils from '../math/MathUtils.js';
4
+ import { generateUUID } from '../math/MathUtils.js';
5
5
 
6
6
  let _materialId = 0;
7
7
 
8
8
  class Material extends EventDispatcher {
9
9
 
10
- static get type() {
11
-
12
- return 'Material';
13
-
14
- }
15
-
16
- get type() {
17
-
18
- return this.constructor.type;
19
-
20
- }
21
-
22
- set type( _value ) { /* */ }
23
-
24
10
  constructor() {
25
11
 
26
12
  super();
@@ -29,9 +15,10 @@ class Material extends EventDispatcher {
29
15
 
30
16
  Object.defineProperty( this, 'id', { value: _materialId ++ } );
31
17
 
32
- this.uuid = MathUtils.generateUUID();
18
+ this.uuid = generateUUID();
33
19
 
34
20
  this.name = '';
21
+ this.type = 'Material';
35
22
 
36
23
  this.blending = NormalBlending;
37
24
  this.side = FrontSide;
@@ -5,18 +5,14 @@ import { Euler } from '../math/Euler.js';
5
5
 
6
6
  class MeshBasicMaterial extends Material {
7
7
 
8
- static get type() {
9
-
10
- return 'MeshBasicMaterial';
11
-
12
- }
13
-
14
8
  constructor( parameters ) {
15
9
 
16
10
  super();
17
11
 
18
12
  this.isMeshBasicMaterial = true;
19
13
 
14
+ this.type = 'MeshBasicMaterial';
15
+
20
16
  this.color = new Color( 0xffffff ); // emissive
21
17
 
22
18
  this.map = null;
@@ -3,18 +3,14 @@ import { BasicDepthPacking } from '../constants.js';
3
3
 
4
4
  class MeshDepthMaterial extends Material {
5
5
 
6
- static get type() {
7
-
8
- return 'MeshDepthMaterial';
9
-
10
- }
11
-
12
6
  constructor( parameters ) {
13
7
 
14
8
  super();
15
9
 
16
10
  this.isMeshDepthMaterial = true;
17
11
 
12
+ this.type = 'MeshDepthMaterial';
13
+
18
14
  this.depthPacking = BasicDepthPacking;
19
15
 
20
16
  this.map = null;
@@ -2,18 +2,14 @@ import { Material } from './Material.js';
2
2
 
3
3
  class MeshDistanceMaterial extends Material {
4
4
 
5
- static get type() {
6
-
7
- return 'MeshDistanceMaterial';
8
-
9
- }
10
-
11
5
  constructor( parameters ) {
12
6
 
13
7
  super();
14
8
 
15
9
  this.isMeshDistanceMaterial = true;
16
10
 
11
+ this.type = 'MeshDistanceMaterial';
12
+
17
13
  this.map = null;
18
14
 
19
15
  this.alphaMap = null;
@@ -6,18 +6,14 @@ import { Euler } from '../math/Euler.js';
6
6
 
7
7
  class MeshLambertMaterial extends Material {
8
8
 
9
- static get type() {
10
-
11
- return 'MeshLambertMaterial';
12
-
13
- }
14
-
15
9
  constructor( parameters ) {
16
10
 
17
11
  super();
18
12
 
19
13
  this.isMeshLambertMaterial = true;
20
14
 
15
+ this.type = 'MeshLambertMaterial';
16
+
21
17
  this.color = new Color( 0xffffff ); // diffuse
22
18
 
23
19
  this.map = null;
@@ -5,12 +5,6 @@ import { Color } from '../math/Color.js';
5
5
 
6
6
  class MeshMatcapMaterial extends Material {
7
7
 
8
- static get type() {
9
-
10
- return 'MeshMatcapMaterial';
11
-
12
- }
13
-
14
8
  constructor( parameters ) {
15
9
 
16
10
  super();
@@ -19,6 +13,8 @@ class MeshMatcapMaterial extends Material {
19
13
 
20
14
  this.defines = { 'MATCAP': '' };
21
15
 
16
+ this.type = 'MeshMatcapMaterial';
17
+
22
18
  this.color = new Color( 0xffffff ); // diffuse
23
19
 
24
20
  this.matcap = null;
@@ -4,18 +4,14 @@ import { Vector2 } from '../math/Vector2.js';
4
4
 
5
5
  class MeshNormalMaterial extends Material {
6
6
 
7
- static get type() {
8
-
9
- return 'MeshNormalMaterial';
10
-
11
- }
12
-
13
7
  constructor( parameters ) {
14
8
 
15
9
  super();
16
10
 
17
11
  this.isMeshNormalMaterial = true;
18
12
 
13
+ this.type = 'MeshNormalMaterial';
14
+
19
15
  this.bumpMap = null;
20
16
  this.bumpScale = 1;
21
17
 
@@ -3,21 +3,16 @@ import { Material } from './Material.js';
3
3
  import { Vector2 } from '../math/Vector2.js';
4
4
  import { Color } from '../math/Color.js';
5
5
  import { Euler } from '../math/Euler.js';
6
-
7
6
  class MeshPhongMaterial extends Material {
8
7
 
9
- static get type() {
10
-
11
- return 'MeshPhongMaterial';
12
-
13
- }
14
-
15
8
  constructor( parameters ) {
16
9
 
17
10
  super();
18
11
 
19
12
  this.isMeshPhongMaterial = true;
20
13
 
14
+ this.type = 'MeshPhongMaterial';
15
+
21
16
  this.color = new Color( 0xffffff ); // diffuse
22
17
  this.specular = new Color( 0x111111 );
23
18
  this.shininess = 30;
@@ -51,6 +46,7 @@ class MeshPhongMaterial extends Material {
51
46
 
52
47
  this.envMap = null;
53
48
  this.envMapRotation = new Euler();
49
+
54
50
  this.combine = MultiplyOperation;
55
51
  this.reflectivity = 1;
56
52
  this.refractionRatio = 0.98;
@@ -1,16 +1,10 @@
1
1
  import { Vector2 } from '../math/Vector2.js';
2
2
  import { MeshStandardMaterial } from './MeshStandardMaterial.js';
3
3
  import { Color } from '../math/Color.js';
4
- import * as MathUtils from '../math/MathUtils.js';
4
+ import { clamp } from '../math/MathUtils.js';
5
5
 
6
6
  class MeshPhysicalMaterial extends MeshStandardMaterial {
7
7
 
8
- static get type() {
9
-
10
- return 'MeshPhysicalMaterial';
11
-
12
- }
13
-
14
8
  constructor( parameters ) {
15
9
 
16
10
  super();
@@ -24,6 +18,8 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
24
18
 
25
19
  };
26
20
 
21
+ this.type = 'MeshPhysicalMaterial';
22
+
27
23
  this.anisotropyRotation = 0;
28
24
  this.anisotropyMap = null;
29
25
 
@@ -38,7 +34,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
38
34
  Object.defineProperty( this, 'reflectivity', {
39
35
  get: function () {
40
36
 
41
- return ( MathUtils.clamp( 2.5 * ( this.ior - 1 ) / ( this.ior + 1 ), 0, 1 ) );
37
+ return ( clamp( 2.5 * ( this.ior - 1 ) / ( this.ior + 1 ), 0, 1 ) );
42
38
 
43
39
  },
44
40
  set: function ( reflectivity ) {
@@ -6,18 +6,14 @@ import { Euler } from '../math/Euler.js';
6
6
 
7
7
  class MeshStandardMaterial extends Material {
8
8
 
9
- static get type() {
10
-
11
- return 'MeshStandardMaterial';
12
-
13
- }
14
-
15
9
  constructor( parameters ) {
16
10
 
17
11
  super();
18
12
 
19
13
  this.isMeshStandardMaterial = true;
20
14
 
15
+ this.type = 'MeshStandardMaterial';
16
+
21
17
  this.defines = { 'STANDARD': '' };
22
18
 
23
19
  this.color = new Color( 0xffffff ); // diffuse
@@ -5,12 +5,6 @@ import { Color } from '../math/Color.js';
5
5
 
6
6
  class MeshToonMaterial extends Material {
7
7
 
8
- static get type() {
9
-
10
- return 'MeshToonMaterial';
11
-
12
- }
13
-
14
8
  constructor( parameters ) {
15
9
 
16
10
  super();
@@ -19,6 +13,8 @@ class MeshToonMaterial extends Material {
19
13
 
20
14
  this.defines = { 'TOON': '' };
21
15
 
16
+ this.type = 'MeshToonMaterial';
17
+
22
18
  this.color = new Color( 0xffffff );
23
19
 
24
20
  this.map = null;
@@ -3,18 +3,14 @@ import { Color } from '../math/Color.js';
3
3
 
4
4
  class PointsMaterial extends Material {
5
5
 
6
- static get type() {
7
-
8
- return 'PointsMaterial';
9
-
10
- }
11
-
12
6
  constructor( parameters ) {
13
7
 
14
8
  super();
15
9
 
16
10
  this.isPointsMaterial = true;
17
11
 
12
+ this.type = 'PointsMaterial';
13
+
18
14
  this.color = new Color( 0xffffff );
19
15
 
20
16
  this.map = null;
@@ -2,18 +2,14 @@ import { ShaderMaterial } from './ShaderMaterial.js';
2
2
 
3
3
  class RawShaderMaterial extends ShaderMaterial {
4
4
 
5
- static get type() {
6
-
7
- return 'RawShaderMaterial';
8
-
9
- }
10
-
11
5
  constructor( parameters ) {
12
6
 
13
7
  super( parameters );
14
8
 
15
9
  this.isRawShaderMaterial = true;
16
10
 
11
+ this.type = 'RawShaderMaterial';
12
+
17
13
  }
18
14
 
19
15
  }