super-three 0.164.0 → 0.165.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/README.md +3 -3
- package/build/three.cjs +664 -217
- package/build/three.module.js +664 -217
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +6 -4
- package/examples/jsm/helpers/ViewHelper.js +32 -67
- package/examples/jsm/libs/tween.module.js +75 -64
- package/examples/jsm/lines/LineMaterial.js +1 -15
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/loaders/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/FBXLoader.js +24 -13
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/nodes/Nodes.js +12 -11
- package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -0
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
- package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
- package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
- package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
- package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
- package/examples/jsm/nodes/accessors/UVNode.js +2 -46
- package/examples/jsm/nodes/core/AttributeNode.js +15 -3
- package/examples/jsm/nodes/core/ContextNode.js +6 -0
- package/examples/jsm/nodes/core/Node.js +15 -2
- package/examples/jsm/nodes/core/NodeBuilder.js +20 -9
- package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +1 -5
- package/examples/jsm/nodes/core/PropertyNode.js +1 -0
- package/examples/jsm/nodes/core/VaryingNode.js +40 -9
- package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
- package/examples/jsm/nodes/display/PassNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportNode.js +1 -1
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +61 -17
- package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +17 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/Materials.js +3 -0
- package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +21 -4
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +13 -5
- package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/examples/jsm/nodes/math/HashNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +55 -33
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/common/Attributes.js +2 -0
- package/examples/jsm/renderers/common/Bindings.js +17 -0
- package/examples/jsm/renderers/common/ChainMap.js +18 -48
- package/examples/jsm/renderers/common/ClippingContext.js +4 -4
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderBundle.js +18 -0
- package/examples/jsm/renderers/common/RenderBundles.js +38 -0
- package/examples/jsm/renderers/common/RenderList.js +9 -0
- package/examples/jsm/renderers/common/RenderObject.js +6 -0
- package/examples/jsm/renderers/common/Renderer.js +139 -11
- package/examples/jsm/renderers/common/Uniform.js +1 -1
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +17 -5
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +93 -6
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +50 -4
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +69 -11
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/package.json +3 -2
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/constants.js +1 -1
- package/src/core/Object3D.js +2 -0
- package/src/core/Raycaster.js +6 -2
- package/src/loaders/FileLoader.js +4 -0
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/objects/BatchedMesh.js +91 -1
- package/src/renderers/WebGLRenderer.js +288 -57
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/webgl/WebGLBackground.js +6 -0
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +9 -12
- package/src/renderers/webgl/WebGLMaterials.js +1 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +2 -31
- package/src/renderers/webgl/WebGLPrograms.js +14 -14
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLTextures.js +139 -70
- package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +6 -2
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
class LoaderUtils {
|
|
2
2
|
|
|
3
|
-
static decodeText( array ) {
|
|
3
|
+
static decodeText( array ) { // @deprecated, r165
|
|
4
|
+
|
|
5
|
+
console.warn( 'THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.' );
|
|
4
6
|
|
|
5
7
|
if ( typeof TextDecoder !== 'undefined' ) {
|
|
6
8
|
|
|
@@ -961,6 +961,7 @@ class ObjectLoader extends Loader {
|
|
|
961
961
|
object._geometryCount = data.geometryCount;
|
|
962
962
|
|
|
963
963
|
object._matricesTexture = getTexture( data.matricesTexture.uuid );
|
|
964
|
+
if ( data.colorsTexture !== undefined ) object._colorsTexture = getTexture( data.colorsTexture.uuid );
|
|
964
965
|
|
|
965
966
|
break;
|
|
966
967
|
|
|
@@ -5,10 +5,12 @@ import { FloatType } from '../constants.js';
|
|
|
5
5
|
import { Matrix4 } from '../math/Matrix4.js';
|
|
6
6
|
import { Mesh } from './Mesh.js';
|
|
7
7
|
import { RGBAFormat } from '../constants.js';
|
|
8
|
+
import { ColorManagement } from '../math/ColorManagement.js';
|
|
8
9
|
import { Box3 } from '../math/Box3.js';
|
|
9
10
|
import { Sphere } from '../math/Sphere.js';
|
|
10
11
|
import { Frustum } from '../math/Frustum.js';
|
|
11
12
|
import { Vector3 } from '../math/Vector3.js';
|
|
13
|
+
import { Color } from '../math/Color.js';
|
|
12
14
|
|
|
13
15
|
function sortOpaque( a, b ) {
|
|
14
16
|
|
|
@@ -71,11 +73,14 @@ const ID_ATTR_NAME = 'batchId';
|
|
|
71
73
|
const _matrix = /*@__PURE__*/ new Matrix4();
|
|
72
74
|
const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
|
|
73
75
|
const _identityMatrix = /*@__PURE__*/ new Matrix4();
|
|
76
|
+
const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
|
|
74
77
|
const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
|
|
75
78
|
const _frustum = /*@__PURE__*/ new Frustum();
|
|
76
79
|
const _box = /*@__PURE__*/ new Box3();
|
|
77
80
|
const _sphere = /*@__PURE__*/ new Sphere();
|
|
78
81
|
const _vector = /*@__PURE__*/ new Vector3();
|
|
82
|
+
const _forward = /*@__PURE__*/ new Vector3();
|
|
83
|
+
const _temp = /*@__PURE__*/ new Vector3();
|
|
79
84
|
const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
|
|
80
85
|
const _mesh = /*@__PURE__*/ new Mesh();
|
|
81
86
|
const _batchIntersects = [];
|
|
@@ -160,6 +165,9 @@ class BatchedMesh extends Mesh {
|
|
|
160
165
|
|
|
161
166
|
this._initMatricesTexture();
|
|
162
167
|
|
|
168
|
+
// Local color per geometry by using data texture
|
|
169
|
+
this._colorsTexture = null;
|
|
170
|
+
|
|
163
171
|
}
|
|
164
172
|
|
|
165
173
|
_initMatricesTexture() {
|
|
@@ -182,6 +190,20 @@ class BatchedMesh extends Mesh {
|
|
|
182
190
|
|
|
183
191
|
}
|
|
184
192
|
|
|
193
|
+
_initColorsTexture() {
|
|
194
|
+
|
|
195
|
+
let size = Math.sqrt( this._maxGeometryCount );
|
|
196
|
+
size = Math.ceil( size );
|
|
197
|
+
|
|
198
|
+
// 4 floats per RGBA pixel initialized to white
|
|
199
|
+
const colorsArray = new Float32Array( size * size * 4 ).fill( 1 );
|
|
200
|
+
const colorsTexture = new DataTexture( colorsArray, size, size, RGBAFormat, FloatType );
|
|
201
|
+
colorsTexture.colorSpace = ColorManagement.workingColorSpace;
|
|
202
|
+
|
|
203
|
+
this._colorsTexture = colorsTexture;
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
185
207
|
_initializeGeometry( reference ) {
|
|
186
208
|
|
|
187
209
|
const geometry = this.geometry;
|
|
@@ -415,6 +437,7 @@ class BatchedMesh extends Mesh {
|
|
|
415
437
|
const active = this._active;
|
|
416
438
|
const matricesTexture = this._matricesTexture;
|
|
417
439
|
const matricesArray = this._matricesTexture.image.data;
|
|
440
|
+
const colorsTexture = this._colorsTexture;
|
|
418
441
|
|
|
419
442
|
// push new visibility states
|
|
420
443
|
visibility.push( true );
|
|
@@ -428,6 +451,14 @@ class BatchedMesh extends Mesh {
|
|
|
428
451
|
_identityMatrix.toArray( matricesArray, geometryId * 16 );
|
|
429
452
|
matricesTexture.needsUpdate = true;
|
|
430
453
|
|
|
454
|
+
// initialize the color to white
|
|
455
|
+
if ( colorsTexture !== null ) {
|
|
456
|
+
|
|
457
|
+
_whiteColor.toArray( colorsTexture.image.data, geometryId * 4 );
|
|
458
|
+
colorsTexture.needsUpdate = true;
|
|
459
|
+
|
|
460
|
+
}
|
|
461
|
+
|
|
431
462
|
// add the reserved range and draw range objects
|
|
432
463
|
reservedRanges.push( reservedRange );
|
|
433
464
|
drawRanges.push( {
|
|
@@ -746,6 +777,49 @@ class BatchedMesh extends Mesh {
|
|
|
746
777
|
|
|
747
778
|
}
|
|
748
779
|
|
|
780
|
+
setColorAt( geometryId, color ) {
|
|
781
|
+
|
|
782
|
+
if ( this._colorsTexture === null ) {
|
|
783
|
+
|
|
784
|
+
this._initColorsTexture();
|
|
785
|
+
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// @TODO: Map geometryId to index of the arrays because
|
|
789
|
+
// optimize() can make geometryId mismatch the index
|
|
790
|
+
|
|
791
|
+
const active = this._active;
|
|
792
|
+
const colorsTexture = this._colorsTexture;
|
|
793
|
+
const colorsArray = this._colorsTexture.image.data;
|
|
794
|
+
const geometryCount = this._geometryCount;
|
|
795
|
+
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
|
|
796
|
+
|
|
797
|
+
return this;
|
|
798
|
+
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
color.toArray( colorsArray, geometryId * 4 );
|
|
802
|
+
colorsTexture.needsUpdate = true;
|
|
803
|
+
|
|
804
|
+
return this;
|
|
805
|
+
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
getColorAt( geometryId, color ) {
|
|
809
|
+
|
|
810
|
+
const active = this._active;
|
|
811
|
+
const colorsArray = this._colorsTexture.image.data;
|
|
812
|
+
const geometryCount = this._geometryCount;
|
|
813
|
+
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
|
|
814
|
+
|
|
815
|
+
return null;
|
|
816
|
+
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
return color.fromArray( colorsArray, geometryId * 4 );
|
|
820
|
+
|
|
821
|
+
}
|
|
822
|
+
|
|
749
823
|
setVisibleAt( geometryId, value ) {
|
|
750
824
|
|
|
751
825
|
const visibility = this._visibility;
|
|
@@ -886,6 +960,13 @@ class BatchedMesh extends Mesh {
|
|
|
886
960
|
this._matricesTexture = source._matricesTexture.clone();
|
|
887
961
|
this._matricesTexture.image.data = this._matricesTexture.image.slice();
|
|
888
962
|
|
|
963
|
+
if ( this._colorsTexture !== null ) {
|
|
964
|
+
|
|
965
|
+
this._colorsTexture = source._colorsTexture.clone();
|
|
966
|
+
this._colorsTexture.image.data = this._colorsTexture.image.slice();
|
|
967
|
+
|
|
968
|
+
}
|
|
969
|
+
|
|
889
970
|
return this;
|
|
890
971
|
|
|
891
972
|
}
|
|
@@ -897,6 +978,14 @@ class BatchedMesh extends Mesh {
|
|
|
897
978
|
|
|
898
979
|
this._matricesTexture.dispose();
|
|
899
980
|
this._matricesTexture = null;
|
|
981
|
+
|
|
982
|
+
if ( this._colorsTexture !== null ) {
|
|
983
|
+
|
|
984
|
+
this._colorsTexture.dispose();
|
|
985
|
+
this._colorsTexture = null;
|
|
986
|
+
|
|
987
|
+
}
|
|
988
|
+
|
|
900
989
|
return this;
|
|
901
990
|
|
|
902
991
|
}
|
|
@@ -942,6 +1031,7 @@ class BatchedMesh extends Mesh {
|
|
|
942
1031
|
// get the camera position in the local frame
|
|
943
1032
|
_invMatrixWorld.copy( this.matrixWorld ).invert();
|
|
944
1033
|
_vector.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
|
|
1034
|
+
_forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );
|
|
945
1035
|
|
|
946
1036
|
for ( let i = 0, l = visibility.length; i < l; i ++ ) {
|
|
947
1037
|
|
|
@@ -962,7 +1052,7 @@ class BatchedMesh extends Mesh {
|
|
|
962
1052
|
if ( ! culled ) {
|
|
963
1053
|
|
|
964
1054
|
// get the distance from camera used for sorting
|
|
965
|
-
const z =
|
|
1055
|
+
const z = _temp.subVectors( _sphere.center, _vector ).dot( _forward );
|
|
966
1056
|
_renderList.push( drawRanges[ i ], z );
|
|
967
1057
|
|
|
968
1058
|
}
|