super-three 0.154.1 → 0.156.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 +360 -160
  2. package/build/three.js +360 -160
  3. package/build/three.min.js +1 -1
  4. package/build/three.module.js +355 -161
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/controls/OrbitControls.js +155 -25
  7. package/examples/jsm/csm/CSMShader.js +35 -1
  8. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  9. package/examples/jsm/exporters/USDZExporter.js +1 -0
  10. package/examples/jsm/interactive/SelectionHelper.js +7 -0
  11. package/examples/jsm/libs/tween.module.js +790 -735
  12. package/examples/jsm/libs/utif.module.js +1644 -1558
  13. package/examples/jsm/loaders/DDSLoader.js +46 -3
  14. package/examples/jsm/loaders/EXRLoader.js +4 -4
  15. package/examples/jsm/loaders/FBXLoader.js +3 -1
  16. package/examples/jsm/loaders/GLTFLoader.js +25 -10
  17. package/examples/jsm/loaders/KTX2Loader.js +128 -79
  18. package/examples/jsm/loaders/LDrawLoader.js +1 -1
  19. package/examples/jsm/loaders/LogLuvLoader.js +2 -2
  20. package/examples/jsm/loaders/MMDLoader.js +10 -7
  21. package/examples/jsm/loaders/NRRDLoader.js +3 -3
  22. package/examples/jsm/loaders/PLYLoader.js +1 -1
  23. package/examples/jsm/loaders/RGBELoader.js +48 -66
  24. package/examples/jsm/loaders/STLLoader.js +7 -0
  25. package/examples/jsm/loaders/TGALoader.js +10 -10
  26. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  27. package/examples/jsm/misc/GPUComputationRenderer.js +0 -9
  28. package/examples/jsm/misc/Volume.js +4 -6
  29. package/examples/jsm/nodes/Nodes.js +8 -6
  30. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +29 -3
  31. package/examples/jsm/nodes/accessors/CubeTextureNode.js +20 -3
  32. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +15 -4
  33. package/examples/jsm/nodes/accessors/InstanceNode.js +8 -8
  34. package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
  35. package/examples/jsm/nodes/accessors/MaterialNode.js +73 -61
  36. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
  37. package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
  38. package/examples/jsm/nodes/accessors/SceneNode.js +6 -0
  39. package/examples/jsm/nodes/accessors/TextureNode.js +54 -9
  40. package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
  41. package/examples/jsm/nodes/core/AttributeNode.js +2 -2
  42. package/examples/jsm/nodes/core/LightingModel.js +7 -9
  43. package/examples/jsm/nodes/core/Node.js +28 -3
  44. package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
  45. package/examples/jsm/nodes/core/NodeUniform.js +1 -1
  46. package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
  47. package/examples/jsm/nodes/core/PropertyNode.js +6 -0
  48. package/examples/jsm/nodes/core/StackNode.js +4 -4
  49. package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
  50. package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
  51. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  52. package/examples/jsm/nodes/display/ViewportNode.js +19 -5
  53. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -2
  54. package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
  55. package/examples/jsm/nodes/functions/PhongLightingModel.js +53 -14
  56. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +236 -97
  57. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  58. package/examples/jsm/nodes/gpgpu/ComputeNode.js +13 -0
  59. package/examples/jsm/nodes/lighting/AONode.js +1 -1
  60. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +58 -20
  61. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +7 -10
  62. package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -12
  63. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +1 -1
  64. package/examples/jsm/nodes/lighting/LightingContextNode.js +12 -9
  65. package/examples/jsm/nodes/lighting/PointLightNode.js +7 -10
  66. package/examples/jsm/nodes/lighting/SpotLightNode.js +7 -10
  67. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
  68. package/examples/jsm/nodes/materials/Materials.js +2 -0
  69. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
  70. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -0
  71. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
  72. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +19 -2
  73. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +2 -2
  74. package/examples/jsm/nodes/materials/NodeMaterial.js +61 -26
  75. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  76. package/examples/jsm/nodes/math/HashNode.js +35 -0
  77. package/examples/jsm/nodes/shadernode/ShaderNode.js +6 -2
  78. package/examples/jsm/nodes/utils/SplitNode.js +1 -1
  79. package/examples/jsm/objects/Reflector.js +1 -9
  80. package/examples/jsm/objects/Refractor.js +0 -8
  81. package/examples/jsm/offscreen/scene.js +0 -1
  82. package/examples/jsm/postprocessing/FilmPass.js +3 -5
  83. package/examples/jsm/postprocessing/MaskPass.js +4 -1
  84. package/examples/jsm/postprocessing/OutputPass.js +33 -14
  85. package/examples/jsm/postprocessing/RenderPass.js +30 -12
  86. package/examples/jsm/postprocessing/SAOPass.js +23 -98
  87. package/examples/jsm/postprocessing/SSAOPass.js +10 -30
  88. package/examples/jsm/postprocessing/UnrealBloomPass.js +21 -17
  89. package/examples/jsm/renderers/common/Backend.js +11 -8
  90. package/examples/jsm/renderers/common/Background.js +22 -20
  91. package/examples/jsm/renderers/common/Binding.js +14 -0
  92. package/examples/jsm/renderers/common/Bindings.js +7 -10
  93. package/examples/jsm/renderers/common/Geometries.js +1 -1
  94. package/examples/jsm/renderers/common/Pipelines.js +96 -47
  95. package/examples/jsm/renderers/common/RenderContext.js +1 -0
  96. package/examples/jsm/renderers/common/RenderContexts.js +41 -5
  97. package/examples/jsm/renderers/common/RenderList.js +12 -4
  98. package/examples/jsm/renderers/common/RenderObject.js +26 -6
  99. package/examples/jsm/renderers/common/RenderObjects.js +10 -7
  100. package/examples/jsm/renderers/common/Renderer.js +82 -42
  101. package/examples/jsm/renderers/common/SampledTexture.js +2 -1
  102. package/examples/jsm/renderers/common/Sampler.js +1 -1
  103. package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
  104. package/examples/jsm/renderers/common/Textures.js +172 -20
  105. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
  106. package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
  107. package/examples/jsm/renderers/common/nodes/Nodes.js +58 -13
  108. package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
  109. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
  110. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
  111. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
  112. package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
  113. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
  114. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
  115. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
  116. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
  117. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +320 -84
  118. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
  119. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +120 -66
  120. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
  121. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +55 -36
  122. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +96 -5
  123. package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +24 -22
  124. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +117 -139
  125. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +60 -142
  126. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +7 -6
  127. package/examples/jsm/shaders/FilmShader.js +11 -54
  128. package/examples/jsm/shaders/OutputShader.js +19 -2
  129. package/examples/jsm/shaders/SAOShader.js +0 -13
  130. package/examples/jsm/shaders/SSAOShader.js +33 -26
  131. package/examples/jsm/utils/BufferGeometryUtils.js +13 -4
  132. package/examples/jsm/webxr/OculusHandPointerModel.js +2 -2
  133. package/package.json +2 -2
  134. package/src/Three.js +3 -0
  135. package/src/animation/PropertyBinding.js +1 -1
  136. package/src/audio/Audio.js +6 -0
  137. package/src/cameras/CubeCamera.js +1 -4
  138. package/src/constants.js +4 -1
  139. package/src/core/BufferAttribute.js +20 -0
  140. package/src/core/Object3D.js +2 -15
  141. package/src/core/RenderTarget.js +122 -0
  142. package/src/core/UniformsGroup.js +2 -2
  143. package/src/geometries/CapsuleGeometry.js +1 -1
  144. package/src/loaders/DataTextureLoader.js +19 -2
  145. package/src/materials/Material.js +2 -2
  146. package/src/math/Vector2.js +2 -2
  147. package/src/math/Vector3.js +3 -3
  148. package/src/math/Vector4.js +4 -4
  149. package/src/objects/Line.js +1 -1
  150. package/src/objects/Mesh.js +1 -1
  151. package/src/objects/Points.js +1 -1
  152. package/src/renderers/WebGLMultipleRenderTargets.js +0 -2
  153. package/src/renderers/WebGLRenderTarget.js +3 -110
  154. package/src/renderers/WebGLRenderer.js +83 -57
  155. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +1 -2
  156. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
  157. package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
  158. package/src/renderers/webgl/WebGLBackground.js +5 -14
  159. package/src/renderers/webgl/WebGLGeometries.js +5 -1
  160. package/src/renderers/webgl/WebGLMaterials.js +1 -1
  161. package/src/renderers/webgl/WebGLProgram.js +2 -0
  162. package/src/renderers/webgl/WebGLPrograms.js +19 -3
  163. package/src/renderers/webgl/WebGLTextures.js +101 -16
  164. package/src/renderers/webgl/WebGLUtils.js +27 -20
  165. package/src/textures/CompressedCubeTexture.js +19 -0
  166. package/src/textures/Texture.js +2 -2
  167. package/src/utils.js +9 -1
  168. package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
  169. package/examples/jsm/renderers/common/RenderTarget.js +0 -15
  170. package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
  171. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
  172. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
@@ -1229,14 +1229,21 @@ function mergeGroups( geometry ) {
1229
1229
  }
1230
1230
 
1231
1231
 
1232
- // Creates a new, non-indexed geometry with smooth normals everywhere except faces that meet at
1233
- // an angle greater than the crease angle.
1232
+ /**
1233
+ * Modifies the supplied geometry if it is non-indexed, otherwise creates a new,
1234
+ * non-indexed geometry. Returns the geometry with smooth normals everywhere except
1235
+ * faces that meet at an angle greater than the crease angle.
1236
+ *
1237
+ * @param {BufferGeometry} geometry
1238
+ * @param {number} [creaseAngle]
1239
+ * @return {BufferGeometry}
1240
+ */
1234
1241
  function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */ ) {
1235
1242
 
1236
1243
  const creaseDot = Math.cos( creaseAngle );
1237
1244
  const hashMultiplier = ( 1 + 1e-10 ) * 1e2;
1238
1245
 
1239
- // reusable vertors
1246
+ // reusable vectors
1240
1247
  const verts = [ new Vector3(), new Vector3(), new Vector3() ];
1241
1248
  const tempVec1 = new Vector3();
1242
1249
  const tempVec2 = new Vector3();
@@ -1253,7 +1260,9 @@ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */
1253
1260
 
1254
1261
  }
1255
1262
 
1256
- const resultGeometry = geometry.toNonIndexed();
1263
+ // BufferGeometry.toNonIndexed() warns if the geometry is non-indexed
1264
+ // and returns the original geometry
1265
+ const resultGeometry = geometry.index ? geometry.toNonIndexed() : geometry;
1257
1266
  const posAttr = resultGeometry.attributes.position;
1258
1267
  const vertexMap = {};
1259
1268
 
@@ -70,8 +70,8 @@ class OculusHandPointerModel extends THREE.Object3D {
70
70
  this.visible = false;
71
71
  this.xrInputSource = null;
72
72
 
73
- this.pointerGeometry.dispose();
74
- this.pointerMesh.material.dispose();
73
+ if ( this.pointerGeometry ) this.pointerGeometry.dispose();
74
+ if ( this.pointerMesh && this.pointerMesh.material ) this.pointerMesh.material.dispose();
75
75
 
76
76
  this.clear();
77
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.154.1",
3
+ "version": "0.156.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.js",
@@ -103,7 +103,7 @@
103
103
  "rollup": "^3.20.2",
104
104
  "rollup-plugin-filesize": "^10.0.0",
105
105
  "rollup-plugin-visualizer": "^5.9.0",
106
- "servez": "^1.14.2"
106
+ "servez": "^2.0.0"
107
107
  },
108
108
  "overrides": {
109
109
  "jpeg-js": "^0.4.4"
package/src/Three.js CHANGED
@@ -34,6 +34,7 @@ export { DataArrayTexture } from './textures/DataArrayTexture.js';
34
34
  export { Data3DTexture } from './textures/Data3DTexture.js';
35
35
  export { CompressedTexture } from './textures/CompressedTexture.js';
36
36
  export { CompressedArrayTexture } from './textures/CompressedArrayTexture.js';
37
+ export { CompressedCubeTexture } from './textures/CompressedCubeTexture.js';
37
38
  export { CubeTexture } from './textures/CubeTexture.js';
38
39
  export { CanvasTexture } from './textures/CanvasTexture.js';
39
40
  export { DepthTexture } from './textures/DepthTexture.js';
@@ -91,6 +92,7 @@ export { AnimationObjectGroup } from './animation/AnimationObjectGroup.js';
91
92
  export { AnimationMixer } from './animation/AnimationMixer.js';
92
93
  export { AnimationClip } from './animation/AnimationClip.js';
93
94
  export { AnimationAction } from './animation/AnimationAction.js';
95
+ export { RenderTarget } from './core/RenderTarget.js';
94
96
  export { Uniform } from './core/Uniform.js';
95
97
  export { UniformsGroup } from './core/UniformsGroup.js';
96
98
  export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
@@ -156,6 +158,7 @@ export { ImageUtils } from './extras/ImageUtils.js';
156
158
  export { ShapeUtils } from './extras/ShapeUtils.js';
157
159
  export { PMREMGenerator } from './extras/PMREMGenerator.js';
158
160
  export { WebGLUtils } from './renderers/webgl/WebGLUtils.js';
161
+ export { createCanvasElement } from './utils.js';
159
162
  export * from './constants.js';
160
163
  export * from './Three.Legacy.js';
161
164
 
@@ -436,7 +436,7 @@ class PropertyBinding {
436
436
  // ensure there is a value node
437
437
  if ( ! targetObject ) {
438
438
 
439
- console.error( 'THREE.PropertyBinding: Trying to update node for track: ' + this.path + ' but it wasn\'t found.' );
439
+ console.warn( 'THREE.PropertyBinding: No target node found for track: ' + this.path + '.' );
440
440
  return;
441
441
 
442
442
  }
@@ -210,6 +210,12 @@ class Audio extends Object3D {
210
210
 
211
211
  disconnect() {
212
212
 
213
+ if ( this._connected === false ) {
214
+
215
+ return;
216
+
217
+ }
218
+
213
219
  if ( this.filters.length > 0 ) {
214
220
 
215
221
  this.source.disconnect( this.filters[ 0 ] );
@@ -1,4 +1,4 @@
1
- import { NoToneMapping, WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../constants.js';
1
+ import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../constants.js';
2
2
  import { Object3D } from '../core/Object3D.js';
3
3
  import { PerspectiveCamera } from './PerspectiveCamera.js';
4
4
 
@@ -126,10 +126,8 @@ class CubeCamera extends Object3D {
126
126
 
127
127
  const currentRenderTarget = renderer.getRenderTarget();
128
128
 
129
- const currentToneMapping = renderer.toneMapping;
130
129
  const currentXrEnabled = renderer.xr.enabled;
131
130
 
132
- renderer.toneMapping = NoToneMapping;
133
131
  renderer.xr.enabled = false;
134
132
 
135
133
  const generateMipmaps = renderTarget.texture.generateMipmaps;
@@ -158,7 +156,6 @@ class CubeCamera extends Object3D {
158
156
 
159
157
  renderer.setRenderTarget( currentRenderTarget );
160
158
 
161
- renderer.toneMapping = currentToneMapping;
162
159
  renderer.xr.enabled = currentXrEnabled;
163
160
 
164
161
  renderTarget.texture.needsPMREMUpdate = true;
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '154';
1
+ export const REVISION = '156';
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 };
@@ -122,6 +122,8 @@ export const RGBA_ASTC_10x10_Format = 37819;
122
122
  export const RGBA_ASTC_12x10_Format = 37820;
123
123
  export const RGBA_ASTC_12x12_Format = 37821;
124
124
  export const RGBA_BPTC_Format = 36492;
125
+ export const RGB_BPTC_SIGNED_Format = 36494;
126
+ export const RGB_BPTC_UNSIGNED_Format = 36495;
125
127
  export const RED_RGTC1_Format = 36283;
126
128
  export const SIGNED_RED_RGTC1_Format = 36284;
127
129
  export const RED_GREEN_RGTC2_Format = 36285;
@@ -154,6 +156,7 @@ export const NoColorSpace = '';
154
156
  export const SRGBColorSpace = 'srgb';
155
157
  export const LinearSRGBColorSpace = 'srgb-linear';
156
158
  export const DisplayP3ColorSpace = 'display-p3';
159
+ export const LinearDisplayP3ColorSpace = 'display-p3-linear';
157
160
 
158
161
  export const ZeroStencilOp = 0;
159
162
  export const KeepStencilOp = 7680;
@@ -175,6 +175,26 @@ class BufferAttribute {
175
175
 
176
176
  }
177
177
 
178
+ getComponent( index, component ) {
179
+
180
+ let value = this.array[ index * this.itemSize + component ];
181
+
182
+ if ( this.normalized ) value = denormalize( value, this.array );
183
+
184
+ return value;
185
+
186
+ }
187
+
188
+ setComponent( index, component, value ) {
189
+
190
+ if ( this.normalized ) value = normalize( value, this.array );
191
+
192
+ this.array[ index * this.itemSize + component ] = value;
193
+
194
+ return this;
195
+
196
+ }
197
+
178
198
  getX( index ) {
179
199
 
180
200
  let x = this.array[ index * this.itemSize ];
@@ -392,20 +392,7 @@ class Object3D extends EventDispatcher {
392
392
 
393
393
  clear() {
394
394
 
395
- for ( let i = 0; i < this.children.length; i ++ ) {
396
-
397
- const object = this.children[ i ];
398
-
399
- object.parent = null;
400
-
401
- object.dispatchEvent( _removedEvent );
402
-
403
- }
404
-
405
- this.children.length = 0;
406
-
407
- return this;
408
-
395
+ return this.remove( ... this.children );
409
396
 
410
397
  }
411
398
 
@@ -945,7 +932,7 @@ class Object3D extends EventDispatcher {
945
932
  this.frustumCulled = source.frustumCulled;
946
933
  this.renderOrder = source.renderOrder;
947
934
 
948
- this.animations = source.animations;
935
+ this.animations = source.animations.slice();
949
936
 
950
937
  this.userData = JSON.parse( JSON.stringify( source.userData ) );
951
938
 
@@ -0,0 +1,122 @@
1
+ import { EventDispatcher } from './EventDispatcher.js';
2
+ import { Texture } from '../textures/Texture.js';
3
+ import { LinearFilter, NoColorSpace, SRGBColorSpace, sRGBEncoding } from '../constants.js';
4
+ import { Vector4 } from '../math/Vector4.js';
5
+ import { Source } from '../textures/Source.js';
6
+ import { warnOnce } from '../utils.js';
7
+
8
+ /*
9
+ In options, we can specify:
10
+ * Texture parameters for an auto-generated target texture
11
+ * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
12
+ */
13
+ class RenderTarget extends EventDispatcher {
14
+
15
+ constructor( width = 1, height = 1, options = {} ) {
16
+
17
+ super();
18
+
19
+ this.isRenderTarget = true;
20
+
21
+ this.width = width;
22
+ this.height = height;
23
+ this.depth = 1;
24
+
25
+ this.scissor = new Vector4( 0, 0, width, height );
26
+ this.scissorTest = false;
27
+
28
+ this.viewport = new Vector4( 0, 0, width, height );
29
+
30
+ const image = { width: width, height: height, depth: 1 };
31
+
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
+ this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
41
+ this.texture.isRenderTargetTexture = true;
42
+
43
+ this.texture.flipY = false;
44
+ this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
45
+ this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;
46
+ this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
47
+
48
+ this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
49
+ this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
50
+
51
+ this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
52
+
53
+ this.samples = options.samples !== undefined ? options.samples : 0;
54
+
55
+ }
56
+
57
+ setSize( width, height, depth = 1 ) {
58
+
59
+ if ( this.width !== width || this.height !== height || this.depth !== depth ) {
60
+
61
+ this.width = width;
62
+ this.height = height;
63
+ this.depth = depth;
64
+
65
+ this.texture.image.width = width;
66
+ this.texture.image.height = height;
67
+ this.texture.image.depth = depth;
68
+
69
+ this.dispose();
70
+
71
+ }
72
+
73
+ this.viewport.set( 0, 0, width, height );
74
+ this.scissor.set( 0, 0, width, height );
75
+
76
+ }
77
+
78
+ clone() {
79
+
80
+ return new this.constructor().copy( this );
81
+
82
+ }
83
+
84
+ copy( source ) {
85
+
86
+ this.width = source.width;
87
+ this.height = source.height;
88
+ this.depth = source.depth;
89
+
90
+ this.scissor.copy( source.scissor );
91
+ this.scissorTest = source.scissorTest;
92
+
93
+ this.viewport.copy( source.viewport );
94
+
95
+ this.texture = source.texture.clone();
96
+ this.texture.isRenderTargetTexture = true;
97
+
98
+ // ensure image object is not shared, see #20328
99
+
100
+ const image = Object.assign( {}, source.texture.image );
101
+ this.texture.source = new Source( image );
102
+
103
+ this.depthBuffer = source.depthBuffer;
104
+ this.stencilBuffer = source.stencilBuffer;
105
+
106
+ if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
107
+
108
+ this.samples = source.samples;
109
+
110
+ return this;
111
+
112
+ }
113
+
114
+ dispose() {
115
+
116
+ this.dispatchEvent( { type: 'dispose' } );
117
+
118
+ }
119
+
120
+ }
121
+
122
+ export { RenderTarget };
@@ -1,7 +1,7 @@
1
1
  import { EventDispatcher } from './EventDispatcher.js';
2
2
  import { StaticDrawUsage } from '../constants.js';
3
3
 
4
- let id = 0;
4
+ let _id = 0;
5
5
 
6
6
  class UniformsGroup extends EventDispatcher {
7
7
 
@@ -11,7 +11,7 @@ class UniformsGroup extends EventDispatcher {
11
11
 
12
12
  this.isUniformsGroup = true;
13
13
 
14
- Object.defineProperty( this, 'id', { value: id ++ } );
14
+ Object.defineProperty( this, 'id', { value: _id ++ } );
15
15
 
16
16
  this.name = '';
17
17
 
@@ -15,7 +15,7 @@ class CapsuleGeometry extends LatheGeometry {
15
15
 
16
16
  this.parameters = {
17
17
  radius: radius,
18
- height: length,
18
+ length: length,
19
19
  capSegments: capSegments,
20
20
  radialSegments: radialSegments,
21
21
  };
@@ -30,9 +30,26 @@ class DataTextureLoader extends Loader {
30
30
  loader.setWithCredentials( scope.withCredentials );
31
31
  loader.load( url, function ( buffer ) {
32
32
 
33
- const texData = scope.parse( buffer );
33
+ let texData;
34
34
 
35
- if ( ! texData ) return;
35
+ try {
36
+
37
+ texData = scope.parse( buffer );
38
+
39
+ } catch ( error ) {
40
+
41
+ if ( onError !== undefined ) {
42
+
43
+ onError( error );
44
+
45
+ } else {
46
+
47
+ console.error( error );
48
+ return;
49
+
50
+ }
51
+
52
+ }
36
53
 
37
54
  if ( texData.image !== undefined ) {
38
55
 
@@ -2,7 +2,7 @@ import { EventDispatcher } from '../core/EventDispatcher.js';
2
2
  import { FrontSide, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';
3
3
  import * as MathUtils from '../math/MathUtils.js';
4
4
 
5
- let materialId = 0;
5
+ let _materialId = 0;
6
6
 
7
7
  class Material extends EventDispatcher {
8
8
 
@@ -12,7 +12,7 @@ class Material extends EventDispatcher {
12
12
 
13
13
  this.isMaterial = true;
14
14
 
15
- Object.defineProperty( this, 'id', { value: materialId ++ } );
15
+ Object.defineProperty( this, 'id', { value: _materialId ++ } );
16
16
 
17
17
  this.uuid = MathUtils.generateUUID();
18
18
 
@@ -293,8 +293,8 @@ class Vector2 {
293
293
 
294
294
  roundToZero() {
295
295
 
296
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
297
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
296
+ this.x = Math.trunc( this.x );
297
+ this.y = Math.trunc( this.y );
298
298
 
299
299
  return this;
300
300
 
@@ -397,9 +397,9 @@ class Vector3 {
397
397
 
398
398
  roundToZero() {
399
399
 
400
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
401
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
402
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
400
+ this.x = Math.trunc( this.x );
401
+ this.y = Math.trunc( this.y );
402
+ this.z = Math.trunc( this.z );
403
403
 
404
404
  return this;
405
405
 
@@ -502,10 +502,10 @@ class Vector4 {
502
502
 
503
503
  roundToZero() {
504
504
 
505
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
506
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
507
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
508
- this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
505
+ this.x = Math.trunc( this.x );
506
+ this.y = Math.trunc( this.y );
507
+ this.z = Math.trunc( this.z );
508
+ this.w = Math.trunc( this.w );
509
509
 
510
510
  return this;
511
511
 
@@ -34,7 +34,7 @@ class Line extends Object3D {
34
34
 
35
35
  super.copy( source, recursive );
36
36
 
37
- this.material = source.material;
37
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
38
38
  this.geometry = source.geometry;
39
39
 
40
40
  return this;
@@ -65,7 +65,7 @@ class Mesh extends Object3D {
65
65
 
66
66
  }
67
67
 
68
- this.material = source.material;
68
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
69
69
  this.geometry = source.geometry;
70
70
 
71
71
  return this;
@@ -32,7 +32,7 @@ class Points extends Object3D {
32
32
 
33
33
  super.copy( source, recursive );
34
34
 
35
- this.material = source.material;
35
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
36
36
  this.geometry = source.geometry;
37
37
 
38
38
  return this;
@@ -44,8 +44,6 @@ class WebGLMultipleRenderTargets extends WebGLRenderTarget {
44
44
  this.viewport.set( 0, 0, width, height );
45
45
  this.scissor.set( 0, 0, width, height );
46
46
 
47
- return this;
48
-
49
47
  }
50
48
 
51
49
  copy( source ) {
@@ -1,120 +1,13 @@
1
- import { EventDispatcher } from '../core/EventDispatcher.js';
2
- import { Texture } from '../textures/Texture.js';
3
- import { LinearFilter, NoColorSpace, SRGBColorSpace, sRGBEncoding } from '../constants.js';
4
- import { Vector4 } from '../math/Vector4.js';
5
- import { Source } from '../textures/Source.js';
6
- import { warnOnce } from '../utils.js';
1
+ import { RenderTarget } from '../core/RenderTarget.js';
7
2
 
8
- /*
9
- In options, we can specify:
10
- * Texture parameters for an auto-generated target texture
11
- * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
12
- */
13
- class WebGLRenderTarget extends EventDispatcher {
3
+ class WebGLRenderTarget extends RenderTarget {
14
4
 
15
5
  constructor( width = 1, height = 1, options = {} ) {
16
6
 
17
- super();
7
+ super( width, height, options );
18
8
 
19
9
  this.isWebGLRenderTarget = true;
20
10
 
21
- this.width = width;
22
- this.height = height;
23
- this.depth = 1;
24
-
25
- this.scissor = new Vector4( 0, 0, width, height );
26
- this.scissorTest = false;
27
-
28
- this.viewport = new Vector4( 0, 0, width, height );
29
-
30
- const image = { width: width, height: height, depth: 1 };
31
-
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
- this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
41
- this.texture.isRenderTargetTexture = true;
42
-
43
- this.texture.flipY = false;
44
- this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
45
- this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;
46
- this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
47
-
48
- this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
49
- this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
50
-
51
- this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
52
-
53
- this.samples = options.samples !== undefined ? options.samples : 0;
54
-
55
- }
56
-
57
- setSize( width, height, depth = 1 ) {
58
-
59
- if ( this.width !== width || this.height !== height || this.depth !== depth ) {
60
-
61
- this.width = width;
62
- this.height = height;
63
- this.depth = depth;
64
-
65
- this.texture.image.width = width;
66
- this.texture.image.height = height;
67
- this.texture.image.depth = depth;
68
-
69
- this.dispose();
70
-
71
- }
72
-
73
- this.viewport.set( 0, 0, width, height );
74
- this.scissor.set( 0, 0, width, height );
75
-
76
- }
77
-
78
- clone() {
79
-
80
- return new this.constructor().copy( this );
81
-
82
- }
83
-
84
- copy( source ) {
85
-
86
- this.width = source.width;
87
- this.height = source.height;
88
- this.depth = source.depth;
89
-
90
- this.scissor.copy( source.scissor );
91
- this.scissorTest = source.scissorTest;
92
-
93
- this.viewport.copy( source.viewport );
94
-
95
- this.texture = source.texture.clone();
96
- this.texture.isRenderTargetTexture = true;
97
-
98
- // ensure image object is not shared, see #20328
99
-
100
- const image = Object.assign( {}, source.texture.image );
101
- this.texture.source = new Source( image );
102
-
103
- this.depthBuffer = source.depthBuffer;
104
- this.stencilBuffer = source.stencilBuffer;
105
-
106
- if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
107
-
108
- this.samples = source.samples;
109
-
110
- return this;
111
-
112
- }
113
-
114
- dispose() {
115
-
116
- this.dispatchEvent( { type: 'dispose' } );
117
-
118
11
  }
119
12
 
120
13
  }