super-three 0.161.0 → 0.162.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +490 -393
- package/build/three.module.js +490 -391
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/DragControls.js +91 -30
- package/examples/jsm/controls/OrbitControls.js +32 -6
- package/examples/jsm/controls/TransformControls.js +6 -6
- package/examples/jsm/exporters/GLTFExporter.js +11 -1
- package/examples/jsm/interactive/InteractiveGroup.js +15 -25
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +32 -14
- package/examples/jsm/loaders/3DMLoader.js +13 -21
- package/examples/jsm/loaders/VOXLoader.js +9 -2
- package/examples/jsm/loaders/VRMLLoader.js +6 -2
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
- package/examples/jsm/nodes/Nodes.js +9 -7
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
- package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
- package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
- package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
- package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
- package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
- package/examples/jsm/nodes/code/CodeNode.js +6 -0
- package/examples/jsm/nodes/core/AssignNode.js +68 -12
- package/examples/jsm/nodes/core/Node.js +14 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +3 -9
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
- package/examples/jsm/nodes/materials/NodeMaterial.js +37 -6
- package/examples/jsm/nodes/math/CondNode.js +42 -7
- package/examples/jsm/nodes/math/MathNode.js +20 -0
- package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
- package/examples/jsm/nodes/utils/LoopNode.js +2 -0
- package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/ClippingContext.js +165 -0
- package/examples/jsm/renderers/common/RenderContext.js +2 -0
- package/examples/jsm/renderers/common/RenderContexts.js +2 -13
- package/examples/jsm/renderers/common/RenderObject.js +44 -1
- package/examples/jsm/renderers/common/RenderObjects.js +3 -1
- package/examples/jsm/renderers/common/Renderer.js +94 -37
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
- package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +3 -13
- package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
- package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +1 -0
- package/examples/jsm/renderers/webgl/WebGLBackend.js +26 -6
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +135 -10
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +7 -1
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +47 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +1 -0
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +13 -12
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +15 -40
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +7 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +2 -2
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -3
- package/examples/jsm/webxr/VRButton.js +13 -5
- package/examples/jsm/webxr/XRButton.js +0 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
- package/package.json +4 -3
- package/src/Three.Legacy.js +20 -0
- package/src/Three.js +0 -1
- package/src/constants.js +2 -5
- package/src/core/BufferAttribute.js +0 -11
- package/src/core/BufferGeometry.js +23 -29
- package/src/core/Object3D.js +11 -0
- package/src/core/Raycaster.js +18 -4
- package/src/core/RenderTarget.js +44 -21
- package/src/extras/PMREMGenerator.js +2 -0
- package/src/extras/curves/EllipseCurve.js +2 -2
- package/src/helpers/SpotLightHelper.js +18 -1
- package/src/loaders/DataTextureLoader.js +0 -4
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +2 -1
- package/src/materials/Material.js +2 -1
- package/src/materials/MeshBasicMaterial.js +3 -0
- package/src/materials/MeshLambertMaterial.js +3 -0
- package/src/materials/MeshPhongMaterial.js +3 -0
- package/src/materials/MeshStandardMaterial.js +3 -0
- package/src/math/Quaternion.js +13 -12
- package/src/math/Vector3.js +7 -7
- package/src/objects/InstancedMesh.js +53 -0
- package/src/objects/Mesh.js +0 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -10
- package/src/renderers/WebGLRenderer.js +15 -22
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/webgl/WebGLBackground.js +18 -0
- package/src/renderers/webgl/WebGLMaterials.js +24 -1
- package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
- package/src/renderers/webgl/WebGLProgram.js +12 -1
- package/src/renderers/webgl/WebGLPrograms.js +19 -16
- package/src/renderers/webgl/WebGLState.js +11 -21
- package/src/renderers/webgl/WebGLTextures.js +80 -50
- package/src/scenes/Scene.js +8 -0
- package/src/textures/Texture.js +1 -29
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
|
@@ -493,33 +493,19 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
493
493
|
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
|
|
496
|
+
const textures = renderTarget.textures;
|
|
497
497
|
|
|
498
|
-
|
|
498
|
+
if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
|
|
499
499
|
|
|
500
|
-
|
|
500
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
501
501
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
drawBuffers.length = textures.length;
|
|
509
|
-
|
|
510
|
-
needsUpdate = true;
|
|
502
|
+
drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
|
|
511
503
|
|
|
512
504
|
}
|
|
513
505
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
if ( drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
|
|
517
|
-
|
|
518
|
-
drawBuffers[ 0 ] = gl.COLOR_ATTACHMENT0;
|
|
506
|
+
drawBuffers.length = textures.length;
|
|
519
507
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
508
|
+
needsUpdate = true;
|
|
523
509
|
|
|
524
510
|
}
|
|
525
511
|
|
|
@@ -541,10 +527,14 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
541
527
|
|
|
542
528
|
gl.drawBuffers( drawBuffers );
|
|
543
529
|
|
|
544
|
-
} else {
|
|
530
|
+
} else if ( extensions.has( 'WEBGL_draw_buffers' ) === true ) {
|
|
545
531
|
|
|
546
532
|
extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
|
|
547
533
|
|
|
534
|
+
} else {
|
|
535
|
+
|
|
536
|
+
throw new Error( 'THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension' );
|
|
537
|
+
|
|
548
538
|
}
|
|
549
539
|
|
|
550
540
|
}
|
|
@@ -3,6 +3,7 @@ import * as MathUtils from '../../math/MathUtils.js';
|
|
|
3
3
|
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
4
4
|
import { createElementNS } from '../../utils.js';
|
|
5
5
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
6
7
|
|
|
7
8
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
8
9
|
|
|
@@ -11,6 +12,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11
12
|
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
12
13
|
const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
|
|
13
14
|
|
|
15
|
+
const _imageDimensions = new Vector2();
|
|
14
16
|
const _videoTextures = new WeakMap();
|
|
15
17
|
let _canvas;
|
|
16
18
|
|
|
@@ -51,11 +53,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
51
53
|
|
|
52
54
|
let scale = 1;
|
|
53
55
|
|
|
56
|
+
const dimensions = getDimensions( image );
|
|
57
|
+
|
|
54
58
|
// handle case if texture exceeds max size
|
|
55
59
|
|
|
56
|
-
if (
|
|
60
|
+
if ( dimensions.width > maxSize || dimensions.height > maxSize ) {
|
|
57
61
|
|
|
58
|
-
scale = maxSize / Math.max(
|
|
62
|
+
scale = maxSize / Math.max( dimensions.width, dimensions.height );
|
|
59
63
|
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -67,12 +71,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
67
71
|
|
|
68
72
|
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
69
73
|
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
70
|
-
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap )
|
|
74
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
|
|
75
|
+
( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) ) {
|
|
71
76
|
|
|
72
77
|
const floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;
|
|
73
78
|
|
|
74
|
-
const width = floor( scale *
|
|
75
|
-
const height = floor( scale *
|
|
79
|
+
const width = floor( scale * dimensions.width );
|
|
80
|
+
const height = floor( scale * dimensions.height );
|
|
76
81
|
|
|
77
82
|
if ( _canvas === undefined ) _canvas = createCanvas( width, height );
|
|
78
83
|
|
|
@@ -86,7 +91,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
86
91
|
const context = canvas.getContext( '2d' );
|
|
87
92
|
context.drawImage( image, 0, 0, width, height );
|
|
88
93
|
|
|
89
|
-
console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' +
|
|
94
|
+
console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + dimensions.width + 'x' + dimensions.height + ') to (' + width + 'x' + height + ').' );
|
|
90
95
|
|
|
91
96
|
return canvas;
|
|
92
97
|
|
|
@@ -94,7 +99,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
94
99
|
|
|
95
100
|
if ( 'data' in image ) {
|
|
96
101
|
|
|
97
|
-
console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' +
|
|
102
|
+
console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + dimensions.width + 'x' + dimensions.height + ').' );
|
|
98
103
|
|
|
99
104
|
}
|
|
100
105
|
|
|
@@ -110,7 +115,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
110
115
|
|
|
111
116
|
function isPowerOfTwo( image ) {
|
|
112
117
|
|
|
113
|
-
|
|
118
|
+
const dimensions = getDimensions( image );
|
|
119
|
+
|
|
120
|
+
return MathUtils.isPowerOfTwo( dimensions.width ) && MathUtils.isPowerOfTwo( dimensions.height );
|
|
114
121
|
|
|
115
122
|
}
|
|
116
123
|
|
|
@@ -177,6 +184,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
177
184
|
|
|
178
185
|
}
|
|
179
186
|
|
|
187
|
+
if ( glFormat === _gl.RG_INTEGER ) {
|
|
188
|
+
|
|
189
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8UI;
|
|
190
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RG16UI;
|
|
191
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RG32UI;
|
|
192
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.RG8I;
|
|
193
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.RG16I;
|
|
194
|
+
if ( glType === _gl.INT ) internalFormat = _gl.RG32I;
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
180
198
|
if ( glFormat === _gl.RGBA ) {
|
|
181
199
|
|
|
182
200
|
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
@@ -324,18 +342,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
324
342
|
|
|
325
343
|
function deallocateRenderTarget( renderTarget ) {
|
|
326
344
|
|
|
327
|
-
const texture = renderTarget.texture;
|
|
328
|
-
|
|
329
345
|
const renderTargetProperties = properties.get( renderTarget );
|
|
330
|
-
const textureProperties = properties.get( texture );
|
|
331
|
-
|
|
332
|
-
if ( textureProperties.__webglTexture !== undefined ) {
|
|
333
|
-
|
|
334
|
-
_gl.deleteTexture( textureProperties.__webglTexture );
|
|
335
|
-
|
|
336
|
-
info.memory.textures --;
|
|
337
|
-
|
|
338
|
-
}
|
|
339
346
|
|
|
340
347
|
if ( renderTarget.depthTexture ) {
|
|
341
348
|
|
|
@@ -390,27 +397,24 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
390
397
|
|
|
391
398
|
}
|
|
392
399
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
for ( let i = 0, il = texture.length; i < il; i ++ ) {
|
|
396
|
-
|
|
397
|
-
const attachmentProperties = properties.get( texture[ i ] );
|
|
400
|
+
const textures = renderTarget.textures;
|
|
398
401
|
|
|
399
|
-
|
|
402
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
400
403
|
|
|
401
|
-
|
|
404
|
+
const attachmentProperties = properties.get( textures[ i ] );
|
|
402
405
|
|
|
403
|
-
|
|
406
|
+
if ( attachmentProperties.__webglTexture ) {
|
|
404
407
|
|
|
405
|
-
|
|
408
|
+
_gl.deleteTexture( attachmentProperties.__webglTexture );
|
|
406
409
|
|
|
407
|
-
|
|
410
|
+
info.memory.textures --;
|
|
408
411
|
|
|
409
412
|
}
|
|
410
413
|
|
|
414
|
+
properties.remove( textures[ i ] );
|
|
415
|
+
|
|
411
416
|
}
|
|
412
417
|
|
|
413
|
-
properties.remove( texture );
|
|
414
418
|
properties.remove( renderTarget );
|
|
415
419
|
|
|
416
420
|
}
|
|
@@ -633,8 +637,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
633
637
|
|
|
634
638
|
if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
|
|
635
639
|
|
|
636
|
-
const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
637
|
-
|
|
638
640
|
if ( texture.magFilter === NearestFilter ) return;
|
|
639
641
|
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
640
642
|
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
|
|
@@ -642,6 +644,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
642
644
|
|
|
643
645
|
if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
|
|
644
646
|
|
|
647
|
+
const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
645
648
|
_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
|
|
646
649
|
properties.get( texture ).__currentAnisotropy = texture.anisotropy;
|
|
647
650
|
|
|
@@ -1162,7 +1165,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1162
1165
|
|
|
1163
1166
|
if ( useTexStorage && allocateMemory ) {
|
|
1164
1167
|
|
|
1165
|
-
|
|
1168
|
+
const dimensions = getDimensions( mipmaps[ 0 ] );
|
|
1169
|
+
|
|
1170
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, dimensions.width, dimensions.height );
|
|
1166
1171
|
|
|
1167
1172
|
}
|
|
1168
1173
|
|
|
@@ -1194,7 +1199,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1194
1199
|
|
|
1195
1200
|
if ( allocateMemory ) {
|
|
1196
1201
|
|
|
1197
|
-
|
|
1202
|
+
const dimensions = getDimensions( image );
|
|
1203
|
+
|
|
1204
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, dimensions.width, dimensions.height );
|
|
1198
1205
|
|
|
1199
1206
|
}
|
|
1200
1207
|
|
|
@@ -1365,7 +1372,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1365
1372
|
|
|
1366
1373
|
if ( mipmaps.length > 0 ) levels ++;
|
|
1367
1374
|
|
|
1368
|
-
|
|
1375
|
+
const dimensions = getDimensions( cubeImage[ 0 ] );
|
|
1376
|
+
|
|
1377
|
+
state.texStorage2D( _gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, dimensions.width, dimensions.height );
|
|
1369
1378
|
|
|
1370
1379
|
}
|
|
1371
1380
|
|
|
@@ -1655,7 +1664,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1655
1664
|
|
|
1656
1665
|
} else {
|
|
1657
1666
|
|
|
1658
|
-
const textures = renderTarget.
|
|
1667
|
+
const textures = renderTarget.textures;
|
|
1659
1668
|
|
|
1660
1669
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1661
1670
|
|
|
@@ -1867,7 +1876,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1867
1876
|
|
|
1868
1877
|
renderTarget.addEventListener( 'dispose', onRenderTargetDispose );
|
|
1869
1878
|
|
|
1870
|
-
|
|
1879
|
+
const textures = renderTarget.textures;
|
|
1880
|
+
|
|
1881
|
+
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1882
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
1883
|
+
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
1884
|
+
|
|
1885
|
+
if ( ! isMultipleRenderTargets ) {
|
|
1871
1886
|
|
|
1872
1887
|
if ( textureProperties.__webglTexture === undefined ) {
|
|
1873
1888
|
|
|
@@ -1880,10 +1895,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1880
1895
|
|
|
1881
1896
|
}
|
|
1882
1897
|
|
|
1883
|
-
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1884
|
-
const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
|
|
1885
|
-
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
1886
|
-
|
|
1887
1898
|
// Setup framebuffer
|
|
1888
1899
|
|
|
1889
1900
|
if ( isCube ) {
|
|
@@ -1932,8 +1943,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1932
1943
|
|
|
1933
1944
|
if ( capabilities.drawBuffers ) {
|
|
1934
1945
|
|
|
1935
|
-
const textures = renderTarget.texture;
|
|
1936
|
-
|
|
1937
1946
|
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1938
1947
|
|
|
1939
1948
|
const attachmentProperties = properties.get( textures[ i ] );
|
|
@@ -1958,8 +1967,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1958
1967
|
|
|
1959
1968
|
if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
1960
1969
|
|
|
1961
|
-
const textures = isMultipleRenderTargets ? texture : [ texture ];
|
|
1962
|
-
|
|
1963
1970
|
renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
|
|
1964
1971
|
renderTargetProperties.__webglColorRenderbuffer = [];
|
|
1965
1972
|
|
|
@@ -2032,8 +2039,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2032
2039
|
|
|
2033
2040
|
} else if ( isMultipleRenderTargets ) {
|
|
2034
2041
|
|
|
2035
|
-
const textures = renderTarget.texture;
|
|
2036
|
-
|
|
2037
2042
|
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
2038
2043
|
|
|
2039
2044
|
const attachment = textures[ i ];
|
|
@@ -2118,7 +2123,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2118
2123
|
|
|
2119
2124
|
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
2120
2125
|
|
|
2121
|
-
const textures = renderTarget.
|
|
2126
|
+
const textures = renderTarget.textures;
|
|
2122
2127
|
|
|
2123
2128
|
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
2124
2129
|
|
|
@@ -2143,14 +2148,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2143
2148
|
|
|
2144
2149
|
if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
2145
2150
|
|
|
2146
|
-
const textures = renderTarget.
|
|
2151
|
+
const textures = renderTarget.textures;
|
|
2147
2152
|
const width = renderTarget.width;
|
|
2148
2153
|
const height = renderTarget.height;
|
|
2149
2154
|
let mask = _gl.COLOR_BUFFER_BIT;
|
|
2150
2155
|
const invalidationArray = [];
|
|
2151
2156
|
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
2152
2157
|
const renderTargetProperties = properties.get( renderTarget );
|
|
2153
|
-
const isMultipleRenderTargets = (
|
|
2158
|
+
const isMultipleRenderTargets = ( textures.length > 1 );
|
|
2154
2159
|
|
|
2155
2160
|
// If MRT we need to remove FBO attachments
|
|
2156
2161
|
if ( isMultipleRenderTargets ) {
|
|
@@ -2334,6 +2339,31 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2334
2339
|
|
|
2335
2340
|
}
|
|
2336
2341
|
|
|
2342
|
+
function getDimensions( image ) {
|
|
2343
|
+
|
|
2344
|
+
if ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) {
|
|
2345
|
+
|
|
2346
|
+
// if intrinsic data are not available, fallback to width/height
|
|
2347
|
+
|
|
2348
|
+
_imageDimensions.width = image.naturalWidth || image.width;
|
|
2349
|
+
_imageDimensions.height = image.naturalHeight || image.height;
|
|
2350
|
+
|
|
2351
|
+
} else if ( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) {
|
|
2352
|
+
|
|
2353
|
+
_imageDimensions.width = image.displayWidth;
|
|
2354
|
+
_imageDimensions.height = image.displayHeight;
|
|
2355
|
+
|
|
2356
|
+
} else {
|
|
2357
|
+
|
|
2358
|
+
_imageDimensions.width = image.width;
|
|
2359
|
+
_imageDimensions.height = image.height;
|
|
2360
|
+
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
return _imageDimensions;
|
|
2364
|
+
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2337
2367
|
//
|
|
2338
2368
|
|
|
2339
2369
|
this.allocateTextureUnit = allocateTextureUnit;
|
package/src/scenes/Scene.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Object3D } from '../core/Object3D.js';
|
|
2
|
+
import { Euler } from '../math/Euler.js';
|
|
2
3
|
|
|
3
4
|
class Scene extends Object3D {
|
|
4
5
|
|
|
@@ -16,6 +17,8 @@ class Scene extends Object3D {
|
|
|
16
17
|
|
|
17
18
|
this.backgroundBlurriness = 0;
|
|
18
19
|
this.backgroundIntensity = 1;
|
|
20
|
+
this.backgroundRotation = new Euler();
|
|
21
|
+
this.environmentRotation = new Euler();
|
|
19
22
|
|
|
20
23
|
this.overrideMaterial = null;
|
|
21
24
|
|
|
@@ -37,6 +40,8 @@ class Scene extends Object3D {
|
|
|
37
40
|
|
|
38
41
|
this.backgroundBlurriness = source.backgroundBlurriness;
|
|
39
42
|
this.backgroundIntensity = source.backgroundIntensity;
|
|
43
|
+
this.backgroundRotation.copy( source.backgroundRotation );
|
|
44
|
+
this.environmentRotation.copy( source.environmentRotation );
|
|
40
45
|
|
|
41
46
|
if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
|
|
42
47
|
|
|
@@ -54,6 +59,9 @@ class Scene extends Object3D {
|
|
|
54
59
|
if ( this.backgroundBlurriness > 0 ) data.object.backgroundBlurriness = this.backgroundBlurriness;
|
|
55
60
|
if ( this.backgroundIntensity !== 1 ) data.object.backgroundIntensity = this.backgroundIntensity;
|
|
56
61
|
|
|
62
|
+
data.object.backgroundRotation = this.backgroundRotation.toArray();
|
|
63
|
+
data.object.environmentRotation = this.environmentRotation.toArray();
|
|
64
|
+
|
|
57
65
|
return data;
|
|
58
66
|
|
|
59
67
|
}
|
package/src/textures/Texture.js
CHANGED
|
@@ -8,16 +8,12 @@ import {
|
|
|
8
8
|
LinearMipmapLinearFilter,
|
|
9
9
|
LinearFilter,
|
|
10
10
|
UVMapping,
|
|
11
|
-
sRGBEncoding,
|
|
12
|
-
SRGBColorSpace,
|
|
13
11
|
NoColorSpace,
|
|
14
|
-
LinearEncoding
|
|
15
12
|
} from '../constants.js';
|
|
16
13
|
import * as MathUtils from '../math/MathUtils.js';
|
|
17
14
|
import { Vector2 } from '../math/Vector2.js';
|
|
18
15
|
import { Matrix3 } from '../math/Matrix3.js';
|
|
19
16
|
import { Source } from './Source.js';
|
|
20
|
-
import { warnOnce } from '../utils.js';
|
|
21
17
|
|
|
22
18
|
let _textureId = 0;
|
|
23
19
|
|
|
@@ -66,17 +62,7 @@ class Texture extends EventDispatcher {
|
|
|
66
62
|
this.flipY = true;
|
|
67
63
|
this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.colorSpace = colorSpace;
|
|
72
|
-
|
|
73
|
-
} else { // @deprecated, r152
|
|
74
|
-
|
|
75
|
-
warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
|
|
76
|
-
this.colorSpace = colorSpace === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
65
|
+
this.colorSpace = colorSpace;
|
|
80
66
|
|
|
81
67
|
this.userData = {};
|
|
82
68
|
|
|
@@ -315,20 +301,6 @@ class Texture extends EventDispatcher {
|
|
|
315
301
|
|
|
316
302
|
}
|
|
317
303
|
|
|
318
|
-
get encoding() { // @deprecated, r152
|
|
319
|
-
|
|
320
|
-
warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
|
|
321
|
-
return this.colorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
set encoding( encoding ) { // @deprecated, r152
|
|
326
|
-
|
|
327
|
-
warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
|
|
328
|
-
this.colorSpace = encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
304
|
}
|
|
333
305
|
|
|
334
306
|
Texture.DEFAULT_IMAGE = null;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import UniformNode from './UniformNode.js';
|
|
2
|
-
import { addNodeClass } from './Node.js';
|
|
3
|
-
|
|
4
|
-
class ArrayUniformNode extends UniformNode {
|
|
5
|
-
|
|
6
|
-
constructor( nodes = [] ) {
|
|
7
|
-
|
|
8
|
-
super();
|
|
9
|
-
|
|
10
|
-
this.isArrayUniformNode = true;
|
|
11
|
-
|
|
12
|
-
this.nodes = nodes;
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getNodeType( builder ) {
|
|
17
|
-
|
|
18
|
-
return this.nodes[ 0 ].getNodeType( builder );
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default ArrayUniformNode;
|
|
25
|
-
|
|
26
|
-
addNodeClass( 'ArrayUniformNode', ArrayUniformNode );
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { WebGLRenderTarget } from './WebGLRenderTarget.js';
|
|
2
|
-
|
|
3
|
-
class WebGLMultipleRenderTargets extends WebGLRenderTarget {
|
|
4
|
-
|
|
5
|
-
constructor( width = 1, height = 1, count = 1, options = {} ) {
|
|
6
|
-
|
|
7
|
-
super( width, height, options );
|
|
8
|
-
|
|
9
|
-
this.isWebGLMultipleRenderTargets = true;
|
|
10
|
-
|
|
11
|
-
const texture = this.texture;
|
|
12
|
-
|
|
13
|
-
this.texture = [];
|
|
14
|
-
|
|
15
|
-
for ( let i = 0; i < count; i ++ ) {
|
|
16
|
-
|
|
17
|
-
this.texture[ i ] = texture.clone();
|
|
18
|
-
this.texture[ i ].isRenderTargetTexture = true;
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
setSize( width, height, depth = 1 ) {
|
|
25
|
-
|
|
26
|
-
if ( this.width !== width || this.height !== height || this.depth !== depth ) {
|
|
27
|
-
|
|
28
|
-
this.width = width;
|
|
29
|
-
this.height = height;
|
|
30
|
-
this.depth = depth;
|
|
31
|
-
|
|
32
|
-
for ( let i = 0, il = this.texture.length; i < il; i ++ ) {
|
|
33
|
-
|
|
34
|
-
this.texture[ i ].image.width = width;
|
|
35
|
-
this.texture[ i ].image.height = height;
|
|
36
|
-
this.texture[ i ].image.depth = depth;
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.dispose();
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
this.viewport.set( 0, 0, width, height );
|
|
45
|
-
this.scissor.set( 0, 0, width, height );
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
copy( source ) {
|
|
50
|
-
|
|
51
|
-
this.dispose();
|
|
52
|
-
|
|
53
|
-
this.width = source.width;
|
|
54
|
-
this.height = source.height;
|
|
55
|
-
this.depth = source.depth;
|
|
56
|
-
|
|
57
|
-
this.scissor.copy( source.scissor );
|
|
58
|
-
this.scissorTest = source.scissorTest;
|
|
59
|
-
|
|
60
|
-
this.viewport.copy( source.viewport );
|
|
61
|
-
|
|
62
|
-
this.depthBuffer = source.depthBuffer;
|
|
63
|
-
this.stencilBuffer = source.stencilBuffer;
|
|
64
|
-
|
|
65
|
-
if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
|
|
66
|
-
|
|
67
|
-
this.texture.length = 0;
|
|
68
|
-
|
|
69
|
-
for ( let i = 0, il = source.texture.length; i < il; i ++ ) {
|
|
70
|
-
|
|
71
|
-
this.texture[ i ] = source.texture[ i ].clone();
|
|
72
|
-
this.texture[ i ].isRenderTargetTexture = true;
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return this;
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { WebGLMultipleRenderTargets };
|