super-three 0.169.0 → 0.170.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 +989 -1131
- package/build/three.module.js +990 -1128
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +8398 -9842
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +8398 -9842
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +435 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +65 -20
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineMaterial.js +7 -2
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +0 -15
- package/examples/jsm/lines/webgpu/Wireframe.js +56 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +140 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +9 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/materials/MeshGouraudMaterial.js +6 -2
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/WaterMesh.js +8 -8
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +17 -20
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +11 -40
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +18 -41
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +2 -8
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +30 -70
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +74 -36
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +1 -4
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +1 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +3 -15
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +1 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +343 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +3 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +1 -6
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +392 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +4 -0
- package/src/Three.WebGPU.js +4 -0
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +44 -6
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/materials/LineBasicMaterial.js +6 -2
- package/src/materials/LineDashedMaterial.js +6 -2
- package/src/materials/Material.js +14 -1
- package/src/materials/MeshBasicMaterial.js +6 -2
- package/src/materials/MeshDepthMaterial.js +6 -2
- package/src/materials/MeshDistanceMaterial.js +6 -2
- package/src/materials/MeshLambertMaterial.js +6 -2
- package/src/materials/MeshMatcapMaterial.js +6 -2
- package/src/materials/MeshNormalMaterial.js +6 -2
- package/src/materials/MeshPhongMaterial.js +6 -2
- package/src/materials/MeshPhysicalMaterial.js +6 -2
- package/src/materials/MeshStandardMaterial.js +6 -2
- package/src/materials/MeshToonMaterial.js +6 -2
- package/src/materials/PointsMaterial.js +6 -2
- package/src/materials/RawShaderMaterial.js +6 -2
- package/src/materials/ShaderMaterial.js +6 -2
- package/src/materials/ShadowMaterial.js +6 -2
- package/src/materials/SpriteMaterial.js +6 -2
- package/src/materials/nodes/NodeMaterial.js +31 -9
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +111 -2
- package/src/math/ColorManagement.js +118 -85
- package/src/math/Vector4.js +11 -0
- package/src/nodes/Nodes.js +1 -21
- package/src/nodes/TSL.js +6 -24
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +32 -10
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +29 -5
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ViewportDepthNode.js +33 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +64 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +12 -416
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +36 -26
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +484 -0
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +458 -241
- package/src/renderers/WebGLRenderer.js +121 -126
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +14 -4
- package/src/renderers/common/Bindings.js +3 -2
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +39 -11
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +18 -1
- package/src/renderers/common/Renderer.js +165 -26
- package/src/renderers/common/Textures.js +30 -14
- package/src/renderers/common/nodes/NodeLibrary.js +1 -14
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +98 -31
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +33 -8
- package/src/renderers/webgpu/WebGPUBackend.js +105 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +10 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +24 -6
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/renderers/webvr/WebVRManager.js +0 -495
- package/src/renderers/webvr/WebVRUtils.js +0 -66
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -35,6 +35,7 @@ class BufferGeometry extends EventDispatcher {
|
|
|
35
35
|
this.type = 'BufferGeometry';
|
|
36
36
|
|
|
37
37
|
this.index = null;
|
|
38
|
+
this.indirect = null;
|
|
38
39
|
this.attributes = {};
|
|
39
40
|
|
|
40
41
|
this.morphAttributes = {};
|
|
@@ -73,6 +74,20 @@ class BufferGeometry extends EventDispatcher {
|
|
|
73
74
|
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
setIndirect( indirect ) {
|
|
78
|
+
|
|
79
|
+
this.indirect = indirect;
|
|
80
|
+
|
|
81
|
+
return this;
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getIndirect() {
|
|
86
|
+
|
|
87
|
+
return this.indirect;
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
76
91
|
getAttribute( name ) {
|
|
77
92
|
|
|
78
93
|
return this.attributes[ name ];
|
|
@@ -272,16 +287,39 @@ class BufferGeometry extends EventDispatcher {
|
|
|
272
287
|
|
|
273
288
|
setFromPoints( points ) {
|
|
274
289
|
|
|
275
|
-
const
|
|
290
|
+
const positionAttribute = this.getAttribute( 'position' );
|
|
276
291
|
|
|
277
|
-
|
|
292
|
+
if ( positionAttribute === undefined ) {
|
|
278
293
|
|
|
279
|
-
const
|
|
280
|
-
position.push( point.x, point.y, point.z || 0 );
|
|
294
|
+
const position = [];
|
|
281
295
|
|
|
282
|
-
|
|
296
|
+
for ( let i = 0, l = points.length; i < l; i ++ ) {
|
|
297
|
+
|
|
298
|
+
const point = points[ i ];
|
|
299
|
+
position.push( point.x, point.y, point.z || 0 );
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
|
|
304
|
+
|
|
305
|
+
} else {
|
|
306
|
+
|
|
307
|
+
for ( let i = 0, l = positionAttribute.count; i < l; i ++ ) {
|
|
308
|
+
|
|
309
|
+
const point = points[ i ];
|
|
310
|
+
positionAttribute.setXYZ( i, point.x, point.y, point.z || 0 );
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if ( points.length > positionAttribute.count ) {
|
|
283
315
|
|
|
284
|
-
|
|
316
|
+
console.warn( 'THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.' );
|
|
317
|
+
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
positionAttribute.needsUpdate = true;
|
|
321
|
+
|
|
322
|
+
}
|
|
285
323
|
|
|
286
324
|
return this;
|
|
287
325
|
|
|
@@ -133,14 +133,14 @@ class CylinderGeometry extends BufferGeometry {
|
|
|
133
133
|
|
|
134
134
|
// faces
|
|
135
135
|
|
|
136
|
-
if ( radiusTop > 0 ) {
|
|
136
|
+
if ( radiusTop > 0 || y !== 0 ) {
|
|
137
137
|
|
|
138
138
|
indices.push( a, b, d );
|
|
139
139
|
groupCount += 3;
|
|
140
140
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
if ( radiusBottom > 0 ) {
|
|
143
|
+
if ( radiusBottom > 0 || y !== heightSegments - 1 ) {
|
|
144
144
|
|
|
145
145
|
indices.push( b, c, d );
|
|
146
146
|
groupCount += 3;
|
|
@@ -3,14 +3,18 @@ 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
|
+
|
|
6
12
|
constructor( parameters ) {
|
|
7
13
|
|
|
8
14
|
super();
|
|
9
15
|
|
|
10
16
|
this.isLineBasicMaterial = true;
|
|
11
17
|
|
|
12
|
-
this.type = 'LineBasicMaterial';
|
|
13
|
-
|
|
14
18
|
this.color = new Color( 0xffffff );
|
|
15
19
|
|
|
16
20
|
this.map = null;
|
|
@@ -2,14 +2,18 @@ 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
|
+
|
|
5
11
|
constructor( parameters ) {
|
|
6
12
|
|
|
7
13
|
super();
|
|
8
14
|
|
|
9
15
|
this.isLineDashedMaterial = true;
|
|
10
16
|
|
|
11
|
-
this.type = 'LineDashedMaterial';
|
|
12
|
-
|
|
13
17
|
this.scale = 1;
|
|
14
18
|
this.dashSize = 3;
|
|
15
19
|
this.gapSize = 1;
|
|
@@ -7,6 +7,20 @@ 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
|
+
|
|
10
24
|
constructor() {
|
|
11
25
|
|
|
12
26
|
super();
|
|
@@ -18,7 +32,6 @@ class Material extends EventDispatcher {
|
|
|
18
32
|
this.uuid = MathUtils.generateUUID();
|
|
19
33
|
|
|
20
34
|
this.name = '';
|
|
21
|
-
this.type = 'Material';
|
|
22
35
|
|
|
23
36
|
this.blending = NormalBlending;
|
|
24
37
|
this.side = FrontSide;
|
|
@@ -5,14 +5,18 @@ 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
|
+
|
|
8
14
|
constructor( parameters ) {
|
|
9
15
|
|
|
10
16
|
super();
|
|
11
17
|
|
|
12
18
|
this.isMeshBasicMaterial = true;
|
|
13
19
|
|
|
14
|
-
this.type = 'MeshBasicMaterial';
|
|
15
|
-
|
|
16
20
|
this.color = new Color( 0xffffff ); // emissive
|
|
17
21
|
|
|
18
22
|
this.map = null;
|
|
@@ -3,14 +3,18 @@ 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
|
+
|
|
6
12
|
constructor( parameters ) {
|
|
7
13
|
|
|
8
14
|
super();
|
|
9
15
|
|
|
10
16
|
this.isMeshDepthMaterial = true;
|
|
11
17
|
|
|
12
|
-
this.type = 'MeshDepthMaterial';
|
|
13
|
-
|
|
14
18
|
this.depthPacking = BasicDepthPacking;
|
|
15
19
|
|
|
16
20
|
this.map = null;
|
|
@@ -2,14 +2,18 @@ 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
|
+
|
|
5
11
|
constructor( parameters ) {
|
|
6
12
|
|
|
7
13
|
super();
|
|
8
14
|
|
|
9
15
|
this.isMeshDistanceMaterial = true;
|
|
10
16
|
|
|
11
|
-
this.type = 'MeshDistanceMaterial';
|
|
12
|
-
|
|
13
17
|
this.map = null;
|
|
14
18
|
|
|
15
19
|
this.alphaMap = null;
|
|
@@ -6,14 +6,18 @@ 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
|
+
|
|
9
15
|
constructor( parameters ) {
|
|
10
16
|
|
|
11
17
|
super();
|
|
12
18
|
|
|
13
19
|
this.isMeshLambertMaterial = true;
|
|
14
20
|
|
|
15
|
-
this.type = 'MeshLambertMaterial';
|
|
16
|
-
|
|
17
21
|
this.color = new Color( 0xffffff ); // diffuse
|
|
18
22
|
|
|
19
23
|
this.map = null;
|
|
@@ -5,6 +5,12 @@ 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
|
+
|
|
8
14
|
constructor( parameters ) {
|
|
9
15
|
|
|
10
16
|
super();
|
|
@@ -13,8 +19,6 @@ class MeshMatcapMaterial extends Material {
|
|
|
13
19
|
|
|
14
20
|
this.defines = { 'MATCAP': '' };
|
|
15
21
|
|
|
16
|
-
this.type = 'MeshMatcapMaterial';
|
|
17
|
-
|
|
18
22
|
this.color = new Color( 0xffffff ); // diffuse
|
|
19
23
|
|
|
20
24
|
this.matcap = null;
|
|
@@ -4,14 +4,18 @@ 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
|
+
|
|
7
13
|
constructor( parameters ) {
|
|
8
14
|
|
|
9
15
|
super();
|
|
10
16
|
|
|
11
17
|
this.isMeshNormalMaterial = true;
|
|
12
18
|
|
|
13
|
-
this.type = 'MeshNormalMaterial';
|
|
14
|
-
|
|
15
19
|
this.bumpMap = null;
|
|
16
20
|
this.bumpScale = 1;
|
|
17
21
|
|
|
@@ -6,14 +6,18 @@ import { Euler } from '../math/Euler.js';
|
|
|
6
6
|
|
|
7
7
|
class MeshPhongMaterial extends Material {
|
|
8
8
|
|
|
9
|
+
static get type() {
|
|
10
|
+
|
|
11
|
+
return 'MeshPhongMaterial';
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
constructor( parameters ) {
|
|
10
16
|
|
|
11
17
|
super();
|
|
12
18
|
|
|
13
19
|
this.isMeshPhongMaterial = true;
|
|
14
20
|
|
|
15
|
-
this.type = 'MeshPhongMaterial';
|
|
16
|
-
|
|
17
21
|
this.color = new Color( 0xffffff ); // diffuse
|
|
18
22
|
this.specular = new Color( 0x111111 );
|
|
19
23
|
this.shininess = 30;
|
|
@@ -5,6 +5,12 @@ import * as MathUtils 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
|
+
|
|
8
14
|
constructor( parameters ) {
|
|
9
15
|
|
|
10
16
|
super();
|
|
@@ -18,8 +24,6 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
18
24
|
|
|
19
25
|
};
|
|
20
26
|
|
|
21
|
-
this.type = 'MeshPhysicalMaterial';
|
|
22
|
-
|
|
23
27
|
this.anisotropyRotation = 0;
|
|
24
28
|
this.anisotropyMap = null;
|
|
25
29
|
|
|
@@ -6,6 +6,12 @@ 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
|
+
|
|
9
15
|
constructor( parameters ) {
|
|
10
16
|
|
|
11
17
|
super();
|
|
@@ -14,8 +20,6 @@ class MeshStandardMaterial extends Material {
|
|
|
14
20
|
|
|
15
21
|
this.defines = { 'STANDARD': '' };
|
|
16
22
|
|
|
17
|
-
this.type = 'MeshStandardMaterial';
|
|
18
|
-
|
|
19
23
|
this.color = new Color( 0xffffff ); // diffuse
|
|
20
24
|
this.roughness = 1.0;
|
|
21
25
|
this.metalness = 0.0;
|
|
@@ -5,6 +5,12 @@ 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
|
+
|
|
8
14
|
constructor( parameters ) {
|
|
9
15
|
|
|
10
16
|
super();
|
|
@@ -13,8 +19,6 @@ class MeshToonMaterial extends Material {
|
|
|
13
19
|
|
|
14
20
|
this.defines = { 'TOON': '' };
|
|
15
21
|
|
|
16
|
-
this.type = 'MeshToonMaterial';
|
|
17
|
-
|
|
18
22
|
this.color = new Color( 0xffffff );
|
|
19
23
|
|
|
20
24
|
this.map = null;
|
|
@@ -3,14 +3,18 @@ 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
|
+
|
|
6
12
|
constructor( parameters ) {
|
|
7
13
|
|
|
8
14
|
super();
|
|
9
15
|
|
|
10
16
|
this.isPointsMaterial = true;
|
|
11
17
|
|
|
12
|
-
this.type = 'PointsMaterial';
|
|
13
|
-
|
|
14
18
|
this.color = new Color( 0xffffff );
|
|
15
19
|
|
|
16
20
|
this.map = null;
|
|
@@ -2,14 +2,18 @@ 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
|
+
|
|
5
11
|
constructor( parameters ) {
|
|
6
12
|
|
|
7
13
|
super( parameters );
|
|
8
14
|
|
|
9
15
|
this.isRawShaderMaterial = true;
|
|
10
16
|
|
|
11
|
-
this.type = 'RawShaderMaterial';
|
|
12
|
-
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
}
|
|
@@ -6,14 +6,18 @@ import default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.
|
|
|
6
6
|
|
|
7
7
|
class ShaderMaterial extends Material {
|
|
8
8
|
|
|
9
|
+
static get type() {
|
|
10
|
+
|
|
11
|
+
return 'ShaderMaterial';
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
constructor( parameters ) {
|
|
10
16
|
|
|
11
17
|
super();
|
|
12
18
|
|
|
13
19
|
this.isShaderMaterial = true;
|
|
14
20
|
|
|
15
|
-
this.type = 'ShaderMaterial';
|
|
16
|
-
|
|
17
21
|
this.defines = {};
|
|
18
22
|
this.uniforms = {};
|
|
19
23
|
this.uniformsGroups = [];
|
|
@@ -3,14 +3,18 @@ import { Color } from '../math/Color.js';
|
|
|
3
3
|
|
|
4
4
|
class ShadowMaterial extends Material {
|
|
5
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'ShadowMaterial';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
constructor( parameters ) {
|
|
7
13
|
|
|
8
14
|
super();
|
|
9
15
|
|
|
10
16
|
this.isShadowMaterial = true;
|
|
11
17
|
|
|
12
|
-
this.type = 'ShadowMaterial';
|
|
13
|
-
|
|
14
18
|
this.color = new Color( 0x000000 );
|
|
15
19
|
this.transparent = true;
|
|
16
20
|
|
|
@@ -3,14 +3,18 @@ import { Color } from '../math/Color.js';
|
|
|
3
3
|
|
|
4
4
|
class SpriteMaterial extends Material {
|
|
5
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'SpriteMaterial';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
constructor( parameters ) {
|
|
7
13
|
|
|
8
14
|
super();
|
|
9
15
|
|
|
10
16
|
this.isSpriteMaterial = true;
|
|
11
17
|
|
|
12
|
-
this.type = 'SpriteMaterial';
|
|
13
|
-
|
|
14
18
|
this.color = new Color( 0xffffff );
|
|
15
19
|
|
|
16
20
|
this.map = null;
|
|
@@ -10,19 +10,19 @@ import { normalLocal } from '../../nodes/accessors/Normal.js';
|
|
|
10
10
|
import { instance } from '../../nodes/accessors/InstanceNode.js';
|
|
11
11
|
import { batch } from '../../nodes/accessors/BatchNode.js';
|
|
12
12
|
import { materialReference } from '../../nodes/accessors/MaterialReferenceNode.js';
|
|
13
|
-
import { positionLocal } from '../../nodes/accessors/Position.js';
|
|
13
|
+
import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
|
|
14
14
|
import { skinningReference } from '../../nodes/accessors/SkinningNode.js';
|
|
15
15
|
import { morphReference } from '../../nodes/accessors/MorphNode.js';
|
|
16
|
-
import { lights } from '../../nodes/lighting/LightsNode.js';
|
|
17
16
|
import { mix } from '../../nodes/math/MathNode.js';
|
|
18
17
|
import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
19
18
|
import AONode from '../../nodes/lighting/AONode.js';
|
|
20
19
|
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
21
20
|
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
|
|
22
|
-
import { depth } from '../../nodes/display/ViewportDepthNode.js';
|
|
23
|
-
import {
|
|
21
|
+
import { depth, perspectiveDepthToLogarithmicDepth, viewZToOrthographicDepth } from '../../nodes/display/ViewportDepthNode.js';
|
|
22
|
+
import { cameraFar, cameraNear } from '../../nodes/accessors/Camera.js';
|
|
24
23
|
import { clipping, clippingAlpha } from '../../nodes/accessors/ClippingNode.js';
|
|
25
24
|
import NodeMaterialObserver from './manager/NodeMaterialObserver.js';
|
|
25
|
+
import getAlphaHashThreshold from '../../nodes/functions/material/getAlphaHashThreshold.js';
|
|
26
26
|
|
|
27
27
|
class NodeMaterial extends Material {
|
|
28
28
|
|
|
@@ -57,6 +57,7 @@ class NodeMaterial extends Material {
|
|
|
57
57
|
this.alphaTestNode = null;
|
|
58
58
|
|
|
59
59
|
this.positionNode = null;
|
|
60
|
+
this.geometryNode = null;
|
|
60
61
|
|
|
61
62
|
this.depthNode = null;
|
|
62
63
|
this.shadowNode = null;
|
|
@@ -98,6 +99,12 @@ class NodeMaterial extends Material {
|
|
|
98
99
|
|
|
99
100
|
builder.stack.outputNode = this.vertexNode || this.setupPosition( builder );
|
|
100
101
|
|
|
102
|
+
if ( this.geometryNode !== null ) {
|
|
103
|
+
|
|
104
|
+
builder.stack.outputNode = builder.stack.outputNode.bypass( this.geometryNode );
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
101
108
|
builder.addFlow( 'vertex', builder.removeStack() );
|
|
102
109
|
|
|
103
110
|
// < FRAGMENT STAGE >
|
|
@@ -215,7 +222,7 @@ class NodeMaterial extends Material {
|
|
|
215
222
|
|
|
216
223
|
setupDepth( builder ) {
|
|
217
224
|
|
|
218
|
-
const { renderer } = builder;
|
|
225
|
+
const { renderer, camera } = builder;
|
|
219
226
|
|
|
220
227
|
// Depth
|
|
221
228
|
|
|
@@ -231,9 +238,15 @@ class NodeMaterial extends Material {
|
|
|
231
238
|
|
|
232
239
|
} else if ( renderer.logarithmicDepthBuffer === true ) {
|
|
233
240
|
|
|
234
|
-
|
|
241
|
+
if ( camera.isPerspectiveCamera ) {
|
|
235
242
|
|
|
236
|
-
|
|
243
|
+
depthNode = perspectiveDepthToLogarithmicDepth( modelViewProjection().w, cameraNear, cameraFar );
|
|
244
|
+
|
|
245
|
+
} else {
|
|
246
|
+
|
|
247
|
+
depthNode = viewZToOrthographicDepth( positionView.z, cameraNear, cameraFar );
|
|
248
|
+
|
|
249
|
+
}
|
|
237
250
|
|
|
238
251
|
}
|
|
239
252
|
|
|
@@ -355,6 +368,14 @@ class NodeMaterial extends Material {
|
|
|
355
368
|
|
|
356
369
|
}
|
|
357
370
|
|
|
371
|
+
// ALPHA HASH
|
|
372
|
+
|
|
373
|
+
if ( this.alphaHash === true ) {
|
|
374
|
+
|
|
375
|
+
diffuseColor.a.lessThan( getAlphaHashThreshold( positionLocal ) ).discard();
|
|
376
|
+
|
|
377
|
+
}
|
|
378
|
+
|
|
358
379
|
if ( this.transparent === false && this.blending === NormalBlending && this.alphaToCoverage === false ) {
|
|
359
380
|
|
|
360
381
|
diffuseColor.a.assign( 1.0 );
|
|
@@ -447,7 +468,7 @@ class NodeMaterial extends Material {
|
|
|
447
468
|
|
|
448
469
|
if ( materialLightsNode.length > 0 ) {
|
|
449
470
|
|
|
450
|
-
lightsN =
|
|
471
|
+
lightsN = builder.renderer.lighting.createNode( [ ...lightsN.getLights(), ...materialLightsNode ] );
|
|
451
472
|
|
|
452
473
|
}
|
|
453
474
|
|
|
@@ -474,7 +495,7 @@ class NodeMaterial extends Material {
|
|
|
474
495
|
|
|
475
496
|
let outgoingLightNode = this.setupOutgoingLight( builder );
|
|
476
497
|
|
|
477
|
-
if ( lightsNode && lightsNode.getScope().
|
|
498
|
+
if ( lightsNode && lightsNode.getScope().hasLights ) {
|
|
478
499
|
|
|
479
500
|
const lightingModel = this.setupLightingModel( builder );
|
|
480
501
|
|
|
@@ -622,6 +643,7 @@ class NodeMaterial extends Material {
|
|
|
622
643
|
this.alphaTestNode = source.alphaTestNode;
|
|
623
644
|
|
|
624
645
|
this.positionNode = source.positionNode;
|
|
646
|
+
this.geometryNode = source.geometryNode;
|
|
625
647
|
|
|
626
648
|
this.depthNode = source.depthNode;
|
|
627
649
|
this.shadowNode = source.shadowNode;
|
|
@@ -59,9 +59,18 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
if ( ! sizeAttenuation
|
|
62
|
+
if ( ! sizeAttenuation ) {
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
if ( camera.isPerspectiveCamera ) {
|
|
65
|
+
|
|
66
|
+
scale = scale.mul( mvPosition.z.negate() );
|
|
67
|
+
|
|
68
|
+
} else {
|
|
69
|
+
|
|
70
|
+
const orthoScale = float( 2.0 ).div( cameraProjectionMatrix.element( 1 ).element( 1 ) );
|
|
71
|
+
scale = scale.mul( orthoScale.mul( 2 ) );
|
|
72
|
+
|
|
73
|
+
}
|
|
65
74
|
|
|
66
75
|
}
|
|
67
76
|
|