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
|
@@ -10,10 +10,7 @@ import {
|
|
|
10
10
|
Matrix4,
|
|
11
11
|
Mesh,
|
|
12
12
|
MeshStandardMaterial,
|
|
13
|
-
ShaderMaterial,
|
|
14
13
|
SRGBColorSpace,
|
|
15
|
-
UniformsLib,
|
|
16
|
-
UniformsUtils,
|
|
17
14
|
Vector3,
|
|
18
15
|
Ray
|
|
19
16
|
} from 'three';
|
|
@@ -45,134 +42,6 @@ const COLOR_SPACE_LDRAW = SRGBColorSpace;
|
|
|
45
42
|
const _tempVec0 = new Vector3();
|
|
46
43
|
const _tempVec1 = new Vector3();
|
|
47
44
|
|
|
48
|
-
class LDrawConditionalLineMaterial extends ShaderMaterial {
|
|
49
|
-
|
|
50
|
-
constructor( parameters ) {
|
|
51
|
-
|
|
52
|
-
super( {
|
|
53
|
-
|
|
54
|
-
uniforms: UniformsUtils.merge( [
|
|
55
|
-
UniformsLib.fog,
|
|
56
|
-
{
|
|
57
|
-
diffuse: {
|
|
58
|
-
value: new Color()
|
|
59
|
-
},
|
|
60
|
-
opacity: {
|
|
61
|
-
value: 1.0
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
] ),
|
|
65
|
-
|
|
66
|
-
vertexShader: /* glsl */`
|
|
67
|
-
attribute vec3 control0;
|
|
68
|
-
attribute vec3 control1;
|
|
69
|
-
attribute vec3 direction;
|
|
70
|
-
varying float discardFlag;
|
|
71
|
-
|
|
72
|
-
#include <common>
|
|
73
|
-
#include <color_pars_vertex>
|
|
74
|
-
#include <fog_pars_vertex>
|
|
75
|
-
#include <logdepthbuf_pars_vertex>
|
|
76
|
-
#include <clipping_planes_pars_vertex>
|
|
77
|
-
void main() {
|
|
78
|
-
#include <color_vertex>
|
|
79
|
-
|
|
80
|
-
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
81
|
-
gl_Position = projectionMatrix * mvPosition;
|
|
82
|
-
|
|
83
|
-
// Transform the line segment ends and control points into camera clip space
|
|
84
|
-
vec4 c0 = projectionMatrix * modelViewMatrix * vec4( control0, 1.0 );
|
|
85
|
-
vec4 c1 = projectionMatrix * modelViewMatrix * vec4( control1, 1.0 );
|
|
86
|
-
vec4 p0 = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
87
|
-
vec4 p1 = projectionMatrix * modelViewMatrix * vec4( position + direction, 1.0 );
|
|
88
|
-
|
|
89
|
-
c0.xy /= c0.w;
|
|
90
|
-
c1.xy /= c1.w;
|
|
91
|
-
p0.xy /= p0.w;
|
|
92
|
-
p1.xy /= p1.w;
|
|
93
|
-
|
|
94
|
-
// Get the direction of the segment and an orthogonal vector
|
|
95
|
-
vec2 dir = p1.xy - p0.xy;
|
|
96
|
-
vec2 norm = vec2( -dir.y, dir.x );
|
|
97
|
-
|
|
98
|
-
// Get control point directions from the line
|
|
99
|
-
vec2 c0dir = c0.xy - p1.xy;
|
|
100
|
-
vec2 c1dir = c1.xy - p1.xy;
|
|
101
|
-
|
|
102
|
-
// If the vectors to the controls points are pointed in different directions away
|
|
103
|
-
// from the line segment then the line should not be drawn.
|
|
104
|
-
float d0 = dot( normalize( norm ), normalize( c0dir ) );
|
|
105
|
-
float d1 = dot( normalize( norm ), normalize( c1dir ) );
|
|
106
|
-
discardFlag = float( sign( d0 ) != sign( d1 ) );
|
|
107
|
-
|
|
108
|
-
#include <logdepthbuf_vertex>
|
|
109
|
-
#include <clipping_planes_vertex>
|
|
110
|
-
#include <fog_vertex>
|
|
111
|
-
}
|
|
112
|
-
`,
|
|
113
|
-
|
|
114
|
-
fragmentShader: /* glsl */`
|
|
115
|
-
uniform vec3 diffuse;
|
|
116
|
-
uniform float opacity;
|
|
117
|
-
varying float discardFlag;
|
|
118
|
-
|
|
119
|
-
#include <common>
|
|
120
|
-
#include <color_pars_fragment>
|
|
121
|
-
#include <fog_pars_fragment>
|
|
122
|
-
#include <logdepthbuf_pars_fragment>
|
|
123
|
-
#include <clipping_planes_pars_fragment>
|
|
124
|
-
void main() {
|
|
125
|
-
|
|
126
|
-
if ( discardFlag > 0.5 ) discard;
|
|
127
|
-
|
|
128
|
-
#include <clipping_planes_fragment>
|
|
129
|
-
vec3 outgoingLight = vec3( 0.0 );
|
|
130
|
-
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
131
|
-
#include <logdepthbuf_fragment>
|
|
132
|
-
#include <color_fragment>
|
|
133
|
-
outgoingLight = diffuseColor.rgb; // simple shader
|
|
134
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
|
135
|
-
#include <tonemapping_fragment>
|
|
136
|
-
#include <colorspace_fragment>
|
|
137
|
-
#include <fog_fragment>
|
|
138
|
-
#include <premultiplied_alpha_fragment>
|
|
139
|
-
}
|
|
140
|
-
`,
|
|
141
|
-
|
|
142
|
-
} );
|
|
143
|
-
|
|
144
|
-
Object.defineProperties( this, {
|
|
145
|
-
|
|
146
|
-
opacity: {
|
|
147
|
-
get: function () {
|
|
148
|
-
|
|
149
|
-
return this.uniforms.opacity.value;
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
set: function ( value ) {
|
|
154
|
-
|
|
155
|
-
this.uniforms.opacity.value = value;
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
color: {
|
|
161
|
-
get: function () {
|
|
162
|
-
|
|
163
|
-
return this.uniforms.diffuse.value;
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
} );
|
|
169
|
-
|
|
170
|
-
this.setValues( parameters );
|
|
171
|
-
this.isLDrawConditionalLineMaterial = true;
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
}
|
|
176
45
|
|
|
177
46
|
class ConditionalLineSegments extends LineSegments {
|
|
178
47
|
|
|
@@ -1897,19 +1766,19 @@ class LDrawLoader extends Loader {
|
|
|
1897
1766
|
// This object is a map from file names to paths. It agilizes the paths search. If it is not set then files will be searched by trial and error.
|
|
1898
1767
|
this.fileMap = {};
|
|
1899
1768
|
|
|
1900
|
-
// Initializes the materials library with default materials
|
|
1901
|
-
this.setMaterials( [] );
|
|
1902
|
-
|
|
1903
1769
|
// If this flag is set to true the vertex normals will be smoothed.
|
|
1904
1770
|
this.smoothNormals = true;
|
|
1905
1771
|
|
|
1906
1772
|
// The path to load parts from the LDraw parts library from.
|
|
1907
1773
|
this.partsLibraryPath = '';
|
|
1908
1774
|
|
|
1775
|
+
// this material type must be injected via setConditionalLineMaterial()
|
|
1776
|
+
this.ConditionalLineMaterial = null;
|
|
1777
|
+
|
|
1909
1778
|
// Material assigned to not available colors for meshes and edges
|
|
1910
1779
|
this.missingColorMaterial = new MeshStandardMaterial( { name: Loader.DEFAULT_MATERIAL_NAME, color: 0xFF00FF, roughness: 0.3, metalness: 0 } );
|
|
1911
1780
|
this.missingEdgeColorMaterial = new LineBasicMaterial( { name: Loader.DEFAULT_MATERIAL_NAME, color: 0xFF00FF } );
|
|
1912
|
-
this.missingConditionalEdgeColorMaterial =
|
|
1781
|
+
this.missingConditionalEdgeColorMaterial = null;
|
|
1913
1782
|
this.edgeMaterialCache.set( this.missingColorMaterial, this.missingEdgeColorMaterial );
|
|
1914
1783
|
this.conditionalEdgeMaterialCache.set( this.missingEdgeColorMaterial, this.missingConditionalEdgeColorMaterial );
|
|
1915
1784
|
|
|
@@ -1922,6 +1791,14 @@ class LDrawLoader extends Loader {
|
|
|
1922
1791
|
|
|
1923
1792
|
}
|
|
1924
1793
|
|
|
1794
|
+
setConditionalLineMaterial( type ) {
|
|
1795
|
+
|
|
1796
|
+
this.ConditionalLineMaterial = type;
|
|
1797
|
+
this.missingConditionalEdgeColorMaterial = new this.ConditionalLineMaterial( { name: Loader.DEFAULT_MATERIAL_NAME, fog: true, color: 0xFF00FF } );
|
|
1798
|
+
return this;
|
|
1799
|
+
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1925
1802
|
async preloadMaterials( url ) {
|
|
1926
1803
|
|
|
1927
1804
|
const fileLoader = new FileLoader( this.manager );
|
|
@@ -1958,6 +1835,9 @@ class LDrawLoader extends Loader {
|
|
|
1958
1835
|
fileLoader.setWithCredentials( this.withCredentials );
|
|
1959
1836
|
fileLoader.load( url, text => {
|
|
1960
1837
|
|
|
1838
|
+
// Initializes the materials library with default materials
|
|
1839
|
+
this.setMaterials( [] );
|
|
1840
|
+
|
|
1961
1841
|
this.partsCache
|
|
1962
1842
|
.parseModel( text, this.materialLibrary )
|
|
1963
1843
|
.then( group => {
|
|
@@ -2384,8 +2264,14 @@ class LDrawLoader extends Loader {
|
|
|
2384
2264
|
edgeMaterial.userData.code = code;
|
|
2385
2265
|
edgeMaterial.name = name + ' - Edge';
|
|
2386
2266
|
|
|
2267
|
+
if ( this.ConditionalLineMaterial === null ) {
|
|
2268
|
+
|
|
2269
|
+
throw new Error( 'THREE.LDrawLoader: ConditionalLineMaterial type must be specificed via .setConditionalLineMaterial().' );
|
|
2270
|
+
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2387
2273
|
// This is the material used for conditional edges
|
|
2388
|
-
const conditionalEdgeMaterial = new
|
|
2274
|
+
const conditionalEdgeMaterial = new this.ConditionalLineMaterial( {
|
|
2389
2275
|
|
|
2390
2276
|
fog: true,
|
|
2391
2277
|
transparent: isTransparent,
|
|
@@ -86,6 +86,8 @@ class MMDLoader extends Loader {
|
|
|
86
86
|
this.meshBuilder = new MeshBuilder( this.manager );
|
|
87
87
|
this.animationBuilder = new AnimationBuilder();
|
|
88
88
|
|
|
89
|
+
console.warn( 'THREE.MMDLoader: The module has been deprecated and will be removed with r172. Please migrate to https://github.com/takahirox/three-mmd-loader instead.' );
|
|
90
|
+
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
/**
|
|
@@ -1467,6 +1469,7 @@ class MaterialBuilder {
|
|
|
1467
1469
|
|
|
1468
1470
|
t.magFilter = NearestFilter;
|
|
1469
1471
|
t.minFilter = NearestFilter;
|
|
1472
|
+
t.generateMipmaps = false;
|
|
1470
1473
|
|
|
1471
1474
|
}
|
|
1472
1475
|
|
|
@@ -2128,14 +2131,18 @@ class CubicBezierInterpolation extends Interpolant {
|
|
|
2128
2131
|
|
|
2129
2132
|
class MMDToonMaterial extends ShaderMaterial {
|
|
2130
2133
|
|
|
2134
|
+
static get type() {
|
|
2135
|
+
|
|
2136
|
+
return 'MMDToonMaterial';
|
|
2137
|
+
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2131
2140
|
constructor( parameters ) {
|
|
2132
2141
|
|
|
2133
2142
|
super();
|
|
2134
2143
|
|
|
2135
2144
|
this.isMMDToonMaterial = true;
|
|
2136
2145
|
|
|
2137
|
-
this.type = 'MMDToonMaterial';
|
|
2138
|
-
|
|
2139
2146
|
this._matcapCombine = AddOperation;
|
|
2140
2147
|
this.emissiveIntensity = 1.0;
|
|
2141
2148
|
this.normalMapType = TangentSpaceNormalMap;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
ShaderMaterial,
|
|
4
|
+
UniformsLib,
|
|
5
|
+
UniformsUtils,
|
|
6
|
+
} from 'three';
|
|
7
|
+
|
|
8
|
+
class LDrawConditionalLineMaterial extends ShaderMaterial {
|
|
9
|
+
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'LDrawConditionalLineMaterial';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
constructor( parameters ) {
|
|
17
|
+
|
|
18
|
+
super( {
|
|
19
|
+
|
|
20
|
+
uniforms: UniformsUtils.merge( [
|
|
21
|
+
UniformsLib.fog,
|
|
22
|
+
{
|
|
23
|
+
diffuse: {
|
|
24
|
+
value: new Color()
|
|
25
|
+
},
|
|
26
|
+
opacity: {
|
|
27
|
+
value: 1.0
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
] ),
|
|
31
|
+
|
|
32
|
+
vertexShader: /* glsl */`
|
|
33
|
+
attribute vec3 control0;
|
|
34
|
+
attribute vec3 control1;
|
|
35
|
+
attribute vec3 direction;
|
|
36
|
+
varying float discardFlag;
|
|
37
|
+
|
|
38
|
+
#include <common>
|
|
39
|
+
#include <color_pars_vertex>
|
|
40
|
+
#include <fog_pars_vertex>
|
|
41
|
+
#include <logdepthbuf_pars_vertex>
|
|
42
|
+
#include <clipping_planes_pars_vertex>
|
|
43
|
+
void main() {
|
|
44
|
+
#include <color_vertex>
|
|
45
|
+
|
|
46
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
47
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
48
|
+
|
|
49
|
+
// Transform the line segment ends and control points into camera clip space
|
|
50
|
+
vec4 c0 = projectionMatrix * modelViewMatrix * vec4( control0, 1.0 );
|
|
51
|
+
vec4 c1 = projectionMatrix * modelViewMatrix * vec4( control1, 1.0 );
|
|
52
|
+
vec4 p0 = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
53
|
+
vec4 p1 = projectionMatrix * modelViewMatrix * vec4( position + direction, 1.0 );
|
|
54
|
+
|
|
55
|
+
c0.xy /= c0.w;
|
|
56
|
+
c1.xy /= c1.w;
|
|
57
|
+
p0.xy /= p0.w;
|
|
58
|
+
p1.xy /= p1.w;
|
|
59
|
+
|
|
60
|
+
// Get the direction of the segment and an orthogonal vector
|
|
61
|
+
vec2 dir = p1.xy - p0.xy;
|
|
62
|
+
vec2 norm = vec2( -dir.y, dir.x );
|
|
63
|
+
|
|
64
|
+
// Get control point directions from the line
|
|
65
|
+
vec2 c0dir = c0.xy - p1.xy;
|
|
66
|
+
vec2 c1dir = c1.xy - p1.xy;
|
|
67
|
+
|
|
68
|
+
// If the vectors to the controls points are pointed in different directions away
|
|
69
|
+
// from the line segment then the line should not be drawn.
|
|
70
|
+
float d0 = dot( normalize( norm ), normalize( c0dir ) );
|
|
71
|
+
float d1 = dot( normalize( norm ), normalize( c1dir ) );
|
|
72
|
+
discardFlag = float( sign( d0 ) != sign( d1 ) );
|
|
73
|
+
|
|
74
|
+
#include <logdepthbuf_vertex>
|
|
75
|
+
#include <clipping_planes_vertex>
|
|
76
|
+
#include <fog_vertex>
|
|
77
|
+
}
|
|
78
|
+
`,
|
|
79
|
+
|
|
80
|
+
fragmentShader: /* glsl */`
|
|
81
|
+
uniform vec3 diffuse;
|
|
82
|
+
uniform float opacity;
|
|
83
|
+
varying float discardFlag;
|
|
84
|
+
|
|
85
|
+
#include <common>
|
|
86
|
+
#include <color_pars_fragment>
|
|
87
|
+
#include <fog_pars_fragment>
|
|
88
|
+
#include <logdepthbuf_pars_fragment>
|
|
89
|
+
#include <clipping_planes_pars_fragment>
|
|
90
|
+
void main() {
|
|
91
|
+
|
|
92
|
+
if ( discardFlag > 0.5 ) discard;
|
|
93
|
+
|
|
94
|
+
#include <clipping_planes_fragment>
|
|
95
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
96
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
97
|
+
#include <logdepthbuf_fragment>
|
|
98
|
+
#include <color_fragment>
|
|
99
|
+
outgoingLight = diffuseColor.rgb; // simple shader
|
|
100
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
|
101
|
+
#include <tonemapping_fragment>
|
|
102
|
+
#include <colorspace_fragment>
|
|
103
|
+
#include <fog_fragment>
|
|
104
|
+
#include <premultiplied_alpha_fragment>
|
|
105
|
+
}
|
|
106
|
+
`,
|
|
107
|
+
|
|
108
|
+
} );
|
|
109
|
+
|
|
110
|
+
Object.defineProperties( this, {
|
|
111
|
+
|
|
112
|
+
opacity: {
|
|
113
|
+
get: function () {
|
|
114
|
+
|
|
115
|
+
return this.uniforms.opacity.value;
|
|
116
|
+
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
set: function ( value ) {
|
|
120
|
+
|
|
121
|
+
this.uniforms.opacity.value = value;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
color: {
|
|
127
|
+
get: function () {
|
|
128
|
+
|
|
129
|
+
return this.uniforms.diffuse.value;
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
} );
|
|
135
|
+
|
|
136
|
+
this.setValues( parameters );
|
|
137
|
+
this.isLDrawConditionalLineMaterial = true;
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { LDrawConditionalLineMaterial };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Color } from 'three';
|
|
2
|
+
import { attribute, cameraProjectionMatrix, dot, float, Fn, modelViewMatrix, modelViewProjection, NodeMaterial, normalize, positionGeometry, sign, uniform, varyingProperty, vec2, vec4 } from 'three/tsl';
|
|
3
|
+
|
|
4
|
+
class LDrawConditionalLineMaterial extends NodeMaterial {
|
|
5
|
+
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'LDrawConditionalLineMaterial';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor( parameters ) {
|
|
13
|
+
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
const vertexNode = /*@__PURE__*/ Fn( () => {
|
|
17
|
+
|
|
18
|
+
const control0 = attribute( 'control0', 'vec3' );
|
|
19
|
+
const control1 = attribute( 'control1', 'vec3' );
|
|
20
|
+
const direction = attribute( 'direction', 'vec3' );
|
|
21
|
+
|
|
22
|
+
const mvp = cameraProjectionMatrix.mul( modelViewMatrix );
|
|
23
|
+
|
|
24
|
+
// Transform the line segment ends and control points into camera clip space
|
|
25
|
+
|
|
26
|
+
const c0 = mvp.mul( vec4( control0, 1 ) ).toVar();
|
|
27
|
+
const c1 = mvp.mul( vec4( control1, 1 ) ).toVar();
|
|
28
|
+
const p0 = mvp.mul( vec4( positionGeometry, 1 ) ).toVar();
|
|
29
|
+
const p1 = mvp.mul( vec4( positionGeometry.add( direction ), 1 ) ).toVar();
|
|
30
|
+
|
|
31
|
+
c0.xy.divAssign( c0.w );
|
|
32
|
+
c1.xy.divAssign( c1.w );
|
|
33
|
+
p0.xy.divAssign( p0.w );
|
|
34
|
+
p1.xy.divAssign( p1.w );
|
|
35
|
+
|
|
36
|
+
// Get the direction of the segment and an orthogonal vector
|
|
37
|
+
|
|
38
|
+
const dir = p1.xy.sub( p0.xy ).toVar();
|
|
39
|
+
const norm = vec2( dir.y.negate(), dir.x ).toVar();
|
|
40
|
+
|
|
41
|
+
// Get control point directions from the line
|
|
42
|
+
const c0dir = c0.xy.sub( p1.xy ).toVar();
|
|
43
|
+
const c1dir = c1.xy.sub( p1.xy ).toVar();
|
|
44
|
+
|
|
45
|
+
// If the vectors to the controls points are pointed in different directions away
|
|
46
|
+
// from the line segment then the line should not be drawn.
|
|
47
|
+
const d0 = dot( normalize( norm ), normalize( c0dir ) ).toVar();
|
|
48
|
+
const d1 = dot( normalize( norm ), normalize( c1dir ) ).toVar();
|
|
49
|
+
const discardFlag = sign( d0 ).notEqual( sign( d1 ) ).select( float( 1 ), float( 0 ) );
|
|
50
|
+
|
|
51
|
+
varyingProperty( 'float', 'discardFlag' ).assign( discardFlag );
|
|
52
|
+
|
|
53
|
+
return modelViewProjection();
|
|
54
|
+
|
|
55
|
+
} )();
|
|
56
|
+
|
|
57
|
+
const fragmentNode = /*@__PURE__*/ Fn( () => {
|
|
58
|
+
|
|
59
|
+
const discardFlag = varyingProperty( 'float', 'discardFlag' );
|
|
60
|
+
|
|
61
|
+
discardFlag.greaterThan( float( 0.5 ) ).discard();
|
|
62
|
+
|
|
63
|
+
return vec4( this._diffuseUniform, this._opacityUniform );
|
|
64
|
+
|
|
65
|
+
} )();
|
|
66
|
+
|
|
67
|
+
this.vertexNode = vertexNode;
|
|
68
|
+
this.fragmentNode = fragmentNode;
|
|
69
|
+
|
|
70
|
+
this._diffuseUniform = uniform( new Color() );
|
|
71
|
+
this._opacityUniform = uniform( 1 );
|
|
72
|
+
|
|
73
|
+
//
|
|
74
|
+
|
|
75
|
+
Object.defineProperties( this, {
|
|
76
|
+
|
|
77
|
+
opacity: {
|
|
78
|
+
get: function () {
|
|
79
|
+
|
|
80
|
+
return this._opacityUniform.value;
|
|
81
|
+
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
set: function ( value ) {
|
|
85
|
+
|
|
86
|
+
this._opacityUniform.value = value;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
color: {
|
|
92
|
+
get: function () {
|
|
93
|
+
|
|
94
|
+
return this._diffuseUniform.value;
|
|
95
|
+
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
set: function ( value ) {
|
|
99
|
+
|
|
100
|
+
this._diffuseUniform.value.copy( value );
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
} );
|
|
106
|
+
|
|
107
|
+
this.setValues( parameters );
|
|
108
|
+
this.isLDrawConditionalLineMaterial = true;
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { LDrawConditionalLineMaterial };
|
|
@@ -315,14 +315,18 @@ const GouraudShader = {
|
|
|
315
315
|
|
|
316
316
|
class MeshGouraudMaterial extends ShaderMaterial {
|
|
317
317
|
|
|
318
|
+
static get type() {
|
|
319
|
+
|
|
320
|
+
return 'MeshGouraudMaterial';
|
|
321
|
+
|
|
322
|
+
}
|
|
323
|
+
|
|
318
324
|
constructor( parameters ) {
|
|
319
325
|
|
|
320
326
|
super();
|
|
321
327
|
|
|
322
328
|
this.isMeshGouraudMaterial = true;
|
|
323
329
|
|
|
324
|
-
this.type = 'MeshGouraudMaterial';
|
|
325
|
-
|
|
326
330
|
//this.color = new THREE.Color( 0xffffff ); // diffuse
|
|
327
331
|
|
|
328
332
|
//this.map = null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { LinearTransfer, Matrix3, SRGBTransfer } from 'three';
|
|
2
|
+
|
|
3
|
+
// Reference: http://www.russellcottrell.com/photo/matrixCalculator.htm
|
|
4
|
+
|
|
5
|
+
const P3_PRIMARIES = [ 0.680, 0.320, 0.265, 0.690, 0.150, 0.060 ];
|
|
6
|
+
const P3_LUMINANCE_COEFFICIENTS = [ 0.2289, 0.6917, 0.0793 ];
|
|
7
|
+
const REC2020_PRIMARIES = [ 0.708, 0.292, 0.170, 0.797, 0.131, 0.046 ];
|
|
8
|
+
const REC2020_LUMINANCE_COEFFICIENTS = [ 0.2627, 0.6780, 0.0593 ];
|
|
9
|
+
const D65 = [ 0.3127, 0.3290 ];
|
|
10
|
+
|
|
11
|
+
/******************************************************************************
|
|
12
|
+
* Display P3 definitions
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const LINEAR_DISPLAY_P3_TO_XYZ = /*@__PURE__*/ new Matrix3().set(
|
|
16
|
+
0.4865709, 0.2656677, 0.1982173,
|
|
17
|
+
0.2289746, 0.6917385, 0.0792869,
|
|
18
|
+
0.0000000, 0.0451134, 1.0439444
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const XYZ_TO_LINEAR_DISPLAY_P3 = /*@__PURE__*/ new Matrix3().set(
|
|
22
|
+
2.4934969, - 0.9313836, - 0.4027108,
|
|
23
|
+
- 0.8294890, 1.7626641, 0.0236247,
|
|
24
|
+
0.0358458, - 0.0761724, 0.9568845
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const DisplayP3ColorSpace = 'display-p3';
|
|
28
|
+
export const LinearDisplayP3ColorSpace = 'display-p3-linear';
|
|
29
|
+
|
|
30
|
+
export const DisplayP3ColorSpaceImpl = {
|
|
31
|
+
primaries: P3_PRIMARIES,
|
|
32
|
+
whitePoint: D65,
|
|
33
|
+
transfer: SRGBTransfer,
|
|
34
|
+
toXYZ: LINEAR_DISPLAY_P3_TO_XYZ,
|
|
35
|
+
fromXYZ: XYZ_TO_LINEAR_DISPLAY_P3,
|
|
36
|
+
luminanceCoefficients: P3_LUMINANCE_COEFFICIENTS,
|
|
37
|
+
outputColorSpaceConfig: { drawingBufferColorSpace: DisplayP3ColorSpace }
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const LinearDisplayP3ColorSpaceImpl = {
|
|
41
|
+
primaries: P3_PRIMARIES,
|
|
42
|
+
whitePoint: D65,
|
|
43
|
+
transfer: LinearTransfer,
|
|
44
|
+
toXYZ: LINEAR_DISPLAY_P3_TO_XYZ,
|
|
45
|
+
fromXYZ: XYZ_TO_LINEAR_DISPLAY_P3,
|
|
46
|
+
luminanceCoefficients: P3_LUMINANCE_COEFFICIENTS,
|
|
47
|
+
workingColorSpaceConfig: { unpackColorSpace: DisplayP3ColorSpace },
|
|
48
|
+
outputColorSpaceConfig: { drawingBufferColorSpace: DisplayP3ColorSpace }
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/******************************************************************************
|
|
52
|
+
* Rec. 2020 definitions
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
const LINEAR_REC2020_TO_XYZ = /*@__PURE__*/ new Matrix3().set(
|
|
56
|
+
0.6369580, 0.1446169, 0.1688810,
|
|
57
|
+
0.2627002, 0.6779981, 0.0593017,
|
|
58
|
+
0.0000000, 0.0280727, 1.0609851
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const XYZ_TO_LINEAR_REC2020 = /*@__PURE__*/ new Matrix3().set(
|
|
62
|
+
1.7166512, - 0.3556708, - 0.2533663,
|
|
63
|
+
- 0.6666844, 1.6164812, 0.0157685,
|
|
64
|
+
0.0176399, - 0.0427706, 0.9421031
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export const LinearRec2020ColorSpace = 'rec2020-linear';
|
|
68
|
+
|
|
69
|
+
export const LinearRec2020ColorSpaceImpl = {
|
|
70
|
+
primaries: REC2020_PRIMARIES,
|
|
71
|
+
whitePoint: D65,
|
|
72
|
+
transfer: LinearTransfer,
|
|
73
|
+
toXYZ: LINEAR_REC2020_TO_XYZ,
|
|
74
|
+
fromXYZ: XYZ_TO_LINEAR_REC2020,
|
|
75
|
+
luminanceCoefficients: REC2020_LUMINANCE_COEFFICIENTS,
|
|
76
|
+
};
|