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
|
@@ -131,22 +131,40 @@ class MMDLoader extends Loader {
|
|
|
131
131
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
const
|
|
134
|
+
const parser = this._getParser();
|
|
135
|
+
const extractModelExtension = this._extractModelExtension;
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
this.loader
|
|
138
|
+
.setMimeType( undefined )
|
|
139
|
+
.setPath( this.path )
|
|
140
|
+
.setResponseType( 'arraybuffer' )
|
|
141
|
+
.setRequestHeader( this.requestHeader )
|
|
142
|
+
.setWithCredentials( this.withCredentials )
|
|
143
|
+
.load( url, function ( buffer ) {
|
|
138
144
|
|
|
139
|
-
|
|
145
|
+
try {
|
|
140
146
|
|
|
141
|
-
|
|
147
|
+
const modelExtension = extractModelExtension( buffer );
|
|
142
148
|
|
|
143
|
-
|
|
149
|
+
if ( modelExtension !== 'pmd' && modelExtension !== 'pmx' ) {
|
|
144
150
|
|
|
145
|
-
|
|
151
|
+
if ( onError ) onError( new Error( 'THREE.MMDLoader: Unknown model file extension .' + modelExtension + '.' ) );
|
|
146
152
|
|
|
147
|
-
|
|
153
|
+
return;
|
|
148
154
|
|
|
149
|
-
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const data = modelExtension === 'pmd' ? parser.parsePmd( buffer, true ) : parser.parsePmx( buffer, true );
|
|
158
|
+
|
|
159
|
+
onLoad( builder.build( data, resourcePath, onProgress, onError ) );
|
|
160
|
+
|
|
161
|
+
} catch ( e ) {
|
|
162
|
+
|
|
163
|
+
if ( onError ) onError( e );
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
}, onProgress, onError );
|
|
150
168
|
|
|
151
169
|
}
|
|
152
170
|
|
|
@@ -358,10 +376,11 @@ class MMDLoader extends Loader {
|
|
|
358
376
|
|
|
359
377
|
// private methods
|
|
360
378
|
|
|
361
|
-
|
|
379
|
+
_extractModelExtension( buffer ) {
|
|
362
380
|
|
|
363
|
-
const
|
|
364
|
-
|
|
381
|
+
const decoder = new TextDecoder( 'utf-8' );
|
|
382
|
+
const bytes = new Uint8Array( buffer, 0, 3 );
|
|
383
|
+
return decoder.decode( bytes ).toLowerCase();
|
|
365
384
|
|
|
366
385
|
}
|
|
367
386
|
|
|
@@ -5,12 +5,13 @@ const TEXTURE_HEIGHT = 4;
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
DataTexture,
|
|
8
|
+
DataUtils,
|
|
8
9
|
RGBAFormat,
|
|
9
|
-
|
|
10
|
+
HalfFloatType,
|
|
10
11
|
RepeatWrapping,
|
|
11
12
|
Mesh,
|
|
12
13
|
InstancedMesh,
|
|
13
|
-
|
|
14
|
+
LinearFilter,
|
|
14
15
|
DynamicDrawUsage,
|
|
15
16
|
Matrix4
|
|
16
17
|
} from 'three';
|
|
@@ -22,18 +23,19 @@ import {
|
|
|
22
23
|
*/
|
|
23
24
|
export function initSplineTexture( numberOfCurves = 1 ) {
|
|
24
25
|
|
|
25
|
-
const dataArray = new
|
|
26
|
+
const dataArray = new Uint16Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
|
|
26
27
|
const dataTexture = new DataTexture(
|
|
27
28
|
dataArray,
|
|
28
29
|
TEXTURE_WIDTH,
|
|
29
30
|
TEXTURE_HEIGHT * numberOfCurves,
|
|
30
31
|
RGBAFormat,
|
|
31
|
-
|
|
32
|
+
HalfFloatType
|
|
32
33
|
);
|
|
33
34
|
|
|
34
35
|
dataTexture.wrapS = RepeatWrapping;
|
|
35
36
|
dataTexture.wrapY = RepeatWrapping;
|
|
36
|
-
dataTexture.magFilter =
|
|
37
|
+
dataTexture.magFilter = LinearFilter;
|
|
38
|
+
dataTexture.minFilter = LinearFilter;
|
|
37
39
|
dataTexture.needsUpdate = true;
|
|
38
40
|
|
|
39
41
|
return dataTexture;
|
|
@@ -81,10 +83,10 @@ function setTextureValue( texture, index, x, y, z, o ) {
|
|
|
81
83
|
const image = texture.image;
|
|
82
84
|
const { data } = image;
|
|
83
85
|
const i = CHANNELS * TEXTURE_WIDTH * o; // Row Offset
|
|
84
|
-
data[ index * CHANNELS + i + 0 ] = x;
|
|
85
|
-
data[ index * CHANNELS + i + 1 ] = y;
|
|
86
|
-
data[ index * CHANNELS + i + 2 ] = z;
|
|
87
|
-
data[ index * CHANNELS + i + 3 ] = 1;
|
|
86
|
+
data[ index * CHANNELS + i + 0 ] = DataUtils.toHalfFloat( x );
|
|
87
|
+
data[ index * CHANNELS + i + 1 ] = DataUtils.toHalfFloat( y );
|
|
88
|
+
data[ index * CHANNELS + i + 2 ] = DataUtils.toHalfFloat( z );
|
|
89
|
+
data[ index * CHANNELS + i + 3 ] = DataUtils.toHalfFloat( 1 );
|
|
88
90
|
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -77,34 +77,35 @@ export * from './shadernode/ShaderNode.js';
|
|
|
77
77
|
// accessors
|
|
78
78
|
export { TBNViewMatrix, parallaxDirection, parallaxUV, transformedBentNormalView } from './accessors/AccessorsUtils.js';
|
|
79
79
|
export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js';
|
|
80
|
-
export
|
|
80
|
+
export * from './accessors/BitangentNode.js';
|
|
81
81
|
export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
|
|
82
82
|
export { default as BufferNode, buffer } from './accessors/BufferNode.js';
|
|
83
|
-
export
|
|
83
|
+
export * from './accessors/CameraNode.js';
|
|
84
84
|
export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
|
|
85
85
|
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
|
|
86
86
|
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
|
|
87
87
|
export { default as BatchNode, batch } from './accessors/BatchNode.js';
|
|
88
|
-
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector } from './accessors/MaterialNode.js';
|
|
88
|
+
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector, materialDispersion } from './accessors/MaterialNode.js';
|
|
89
89
|
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
|
|
90
90
|
export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';
|
|
91
91
|
export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
|
|
92
92
|
export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
|
|
93
|
-
export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
|
|
93
|
+
export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale, modelWorldMatrixInverse } from './accessors/ModelNode.js';
|
|
94
94
|
export { default as ModelViewProjectionNode, modelViewProjection } from './accessors/ModelViewProjectionNode.js';
|
|
95
|
-
export
|
|
95
|
+
export * from './accessors/NormalNode.js';
|
|
96
96
|
export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectScale, objectViewPosition } from './accessors/Object3DNode.js';
|
|
97
97
|
export { default as PointUVNode, pointUV } from './accessors/PointUVNode.js';
|
|
98
|
-
export
|
|
98
|
+
export * from './accessors/PositionNode.js';
|
|
99
99
|
export { default as ReferenceNode, reference, referenceBuffer } from './accessors/ReferenceNode.js';
|
|
100
|
-
export
|
|
100
|
+
export * from './accessors/ReflectVectorNode.js';
|
|
101
101
|
export { default as SkinningNode, skinning } from './accessors/SkinningNode.js';
|
|
102
102
|
export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from './accessors/SceneNode.js';
|
|
103
103
|
export { default as StorageBufferNode, storage, storageObject } from './accessors/StorageBufferNode.js';
|
|
104
|
-
export
|
|
104
|
+
export * from './accessors/TangentNode.js';
|
|
105
105
|
export { default as TextureNode, texture, textureLoad, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
|
|
106
|
-
export { default as
|
|
107
|
-
export { default as
|
|
106
|
+
export { default as StorageTextureNode, storageTexture, textureStore, storageTextureReadOnly, storageTextureReadWrite } from './accessors/StorageTextureNode.js';
|
|
107
|
+
export { default as Texture3DNode, texture3D } from './accessors/Texture3DNode.js';
|
|
108
|
+
export * from './accessors/UVNode.js';
|
|
108
109
|
export { default as UserDataNode, userData } from './accessors/UserDataNode.js';
|
|
109
110
|
|
|
110
111
|
// display
|
|
@@ -125,7 +126,7 @@ export { default as GaussianBlurNode, gaussianBlur } from './display/GaussianBlu
|
|
|
125
126
|
export { default as AfterImageNode, afterImage } from './display/AfterImageNode.js';
|
|
126
127
|
export { default as AnamorphicNode, anamorphic } from './display/AnamorphicNode.js';
|
|
127
128
|
|
|
128
|
-
export { default as PassNode, pass, depthPass } from './display/PassNode.js';
|
|
129
|
+
export { default as PassNode, pass, texturePass, depthPass } from './display/PassNode.js';
|
|
129
130
|
|
|
130
131
|
// code
|
|
131
132
|
export { default as ExpressionNode, expression } from './code/ExpressionNode.js';
|
|
@@ -1,89 +1,13 @@
|
|
|
1
|
-
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
1
|
import { varying } from '../core/VaryingNode.js';
|
|
3
|
-
import { normalize } from '../math/MathNode.js';
|
|
4
2
|
import { cameraViewMatrix } from './CameraNode.js';
|
|
5
3
|
import { normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView } from './NormalNode.js';
|
|
6
4
|
import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView } from './TangentNode.js';
|
|
7
|
-
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
const getBitangent = ( crossNormalTangent ) => crossNormalTangent.mul( tangentGeometry.w ).xyz;
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getHash( /*builder*/ ) {
|
|
20
|
-
|
|
21
|
-
return `bitangent-${this.scope}`;
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
generate( builder ) {
|
|
26
|
-
|
|
27
|
-
const scope = this.scope;
|
|
28
|
-
|
|
29
|
-
let crossNormalTangent;
|
|
30
|
-
|
|
31
|
-
if ( scope === BitangentNode.GEOMETRY ) {
|
|
32
|
-
|
|
33
|
-
crossNormalTangent = normalGeometry.cross( tangentGeometry );
|
|
34
|
-
|
|
35
|
-
} else if ( scope === BitangentNode.LOCAL ) {
|
|
36
|
-
|
|
37
|
-
crossNormalTangent = normalLocal.cross( tangentLocal );
|
|
38
|
-
|
|
39
|
-
} else if ( scope === BitangentNode.VIEW ) {
|
|
40
|
-
|
|
41
|
-
crossNormalTangent = normalView.cross( tangentView );
|
|
42
|
-
|
|
43
|
-
} else if ( scope === BitangentNode.WORLD ) {
|
|
44
|
-
|
|
45
|
-
crossNormalTangent = normalWorld.cross( tangentWorld );
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const vertexNode = crossNormalTangent.mul( tangentGeometry.w ).xyz;
|
|
50
|
-
|
|
51
|
-
const outputNode = normalize( varying( vertexNode ) );
|
|
52
|
-
|
|
53
|
-
return outputNode.build( builder, this.getNodeType( builder ) );
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
serialize( data ) {
|
|
58
|
-
|
|
59
|
-
super.serialize( data );
|
|
60
|
-
|
|
61
|
-
data.scope = this.scope;
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
deserialize( data ) {
|
|
66
|
-
|
|
67
|
-
super.deserialize( data );
|
|
68
|
-
|
|
69
|
-
this.scope = data.scope;
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
BitangentNode.GEOMETRY = 'geometry';
|
|
76
|
-
BitangentNode.LOCAL = 'local';
|
|
77
|
-
BitangentNode.VIEW = 'view';
|
|
78
|
-
BitangentNode.WORLD = 'world';
|
|
79
|
-
|
|
80
|
-
export default BitangentNode;
|
|
81
|
-
|
|
82
|
-
export const bitangentGeometry = nodeImmutable( BitangentNode, BitangentNode.GEOMETRY );
|
|
83
|
-
export const bitangentLocal = nodeImmutable( BitangentNode, BitangentNode.LOCAL );
|
|
84
|
-
export const bitangentView = nodeImmutable( BitangentNode, BitangentNode.VIEW );
|
|
85
|
-
export const bitangentWorld = nodeImmutable( BitangentNode, BitangentNode.WORLD );
|
|
86
|
-
export const transformedBitangentView = normalize( transformedNormalView.cross( transformedTangentView ).mul( tangentGeometry.w ) );
|
|
87
|
-
export const transformedBitangentWorld = normalize( transformedBitangentView.transformDirection( cameraViewMatrix ) );
|
|
88
|
-
|
|
89
|
-
addNodeClass( 'BitangentNode', BitangentNode );
|
|
8
|
+
export const bitangentGeometry = /*#__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' );
|
|
9
|
+
export const bitangentLocal = /*#__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' );
|
|
10
|
+
export const bitangentView = /*#__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' );
|
|
11
|
+
export const bitangentWorld = /*#__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' );
|
|
12
|
+
export const transformedBitangentView = /*#__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' );
|
|
13
|
+
export const transformedBitangentWorld = /*#__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' );
|
|
@@ -1,119 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
super( scope );
|
|
14
|
-
|
|
15
|
-
this.updateType = NodeUpdateType.RENDER;
|
|
16
|
-
|
|
17
|
-
//this._uniformNode.groupNode = cameraGroup;
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
getNodeType( builder ) {
|
|
22
|
-
|
|
23
|
-
const scope = this.scope;
|
|
24
|
-
|
|
25
|
-
if ( scope === CameraNode.PROJECTION_MATRIX || scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
26
|
-
|
|
27
|
-
return 'mat4';
|
|
28
|
-
|
|
29
|
-
} else if ( scope === CameraNode.NEAR || scope === CameraNode.FAR || scope === CameraNode.LOG_DEPTH ) {
|
|
30
|
-
|
|
31
|
-
return 'float';
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return super.getNodeType( builder );
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
update( frame ) {
|
|
40
|
-
|
|
41
|
-
const camera = frame.camera;
|
|
42
|
-
const uniformNode = this._uniformNode;
|
|
43
|
-
const scope = this.scope;
|
|
44
|
-
|
|
45
|
-
//cameraGroup.needsUpdate = true;
|
|
46
|
-
|
|
47
|
-
if ( scope === CameraNode.VIEW_MATRIX ) {
|
|
48
|
-
|
|
49
|
-
uniformNode.value = camera.matrixWorldInverse;
|
|
50
|
-
|
|
51
|
-
} else if ( scope === CameraNode.PROJECTION_MATRIX ) {
|
|
52
|
-
|
|
53
|
-
uniformNode.value = camera.projectionMatrix;
|
|
54
|
-
|
|
55
|
-
} else if ( scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
56
|
-
|
|
57
|
-
uniformNode.value = camera.projectionMatrixInverse;
|
|
58
|
-
|
|
59
|
-
} else if ( scope === CameraNode.NEAR ) {
|
|
60
|
-
|
|
61
|
-
uniformNode.value = camera.near;
|
|
62
|
-
|
|
63
|
-
} else if ( scope === CameraNode.FAR ) {
|
|
64
|
-
|
|
65
|
-
uniformNode.value = camera.far;
|
|
66
|
-
|
|
67
|
-
} else if ( scope === CameraNode.LOG_DEPTH ) {
|
|
68
|
-
|
|
69
|
-
uniformNode.value = 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 );
|
|
70
|
-
|
|
71
|
-
} else {
|
|
72
|
-
|
|
73
|
-
this.object3d = camera;
|
|
74
|
-
|
|
75
|
-
super.update( frame );
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
generate( builder ) {
|
|
82
|
-
|
|
83
|
-
const scope = this.scope;
|
|
84
|
-
|
|
85
|
-
if ( scope === CameraNode.PROJECTION_MATRIX || scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
86
|
-
|
|
87
|
-
this._uniformNode.nodeType = 'mat4';
|
|
88
|
-
|
|
89
|
-
} else if ( scope === CameraNode.NEAR || scope === CameraNode.FAR || scope === CameraNode.LOG_DEPTH ) {
|
|
90
|
-
|
|
91
|
-
this._uniformNode.nodeType = 'float';
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return super.generate( builder );
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
CameraNode.PROJECTION_MATRIX = 'projectionMatrix';
|
|
102
|
-
CameraNode.PROJECTION_MATRIX_INVERSE = 'projectionMatrixInverse';
|
|
103
|
-
CameraNode.NEAR = 'near';
|
|
104
|
-
CameraNode.FAR = 'far';
|
|
105
|
-
CameraNode.LOG_DEPTH = 'logDepth';
|
|
106
|
-
|
|
107
|
-
export default CameraNode;
|
|
108
|
-
|
|
109
|
-
export const cameraProjectionMatrix = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX );
|
|
110
|
-
export const cameraProjectionMatrixInverse = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX_INVERSE );
|
|
111
|
-
export const cameraNear = nodeImmutable( CameraNode, CameraNode.NEAR );
|
|
112
|
-
export const cameraFar = nodeImmutable( CameraNode, CameraNode.FAR );
|
|
113
|
-
export const cameraLogDepth = nodeImmutable( CameraNode, CameraNode.LOG_DEPTH );
|
|
114
|
-
export const cameraViewMatrix = nodeImmutable( CameraNode, CameraNode.VIEW_MATRIX );
|
|
115
|
-
export const cameraNormalMatrix = nodeImmutable( CameraNode, CameraNode.NORMAL_MATRIX );
|
|
116
|
-
export const cameraWorldMatrix = nodeImmutable( CameraNode, CameraNode.WORLD_MATRIX );
|
|
117
|
-
export const cameraPosition = nodeImmutable( CameraNode, CameraNode.POSITION );
|
|
118
|
-
|
|
119
|
-
addNodeClass( 'CameraNode', CameraNode );
|
|
1
|
+
import { uniform } from '../core/UniformNode.js';
|
|
2
|
+
import { Vector3 } from 'three';
|
|
3
|
+
|
|
4
|
+
export const cameraNear = /*#__PURE__*/ uniform( 'float' ).onRenderUpdate( ( { camera } ) => camera.near );
|
|
5
|
+
export const cameraFar = /*#__PURE__*/ uniform( 'float' ).onRenderUpdate( ( { camera } ) => camera.far );
|
|
6
|
+
export const cameraLogDepth = /*#__PURE__*/ uniform( 'float' ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
|
|
7
|
+
export const cameraProjectionMatrix = /*#__PURE__*/ uniform( 'mat4' ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix );
|
|
8
|
+
export const cameraProjectionMatrixInverse = /*#__PURE__*/ uniform( 'mat4' ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse );
|
|
9
|
+
export const cameraViewMatrix = /*#__PURE__*/ uniform( 'mat4' ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse );
|
|
10
|
+
export const cameraWorldMatrix = /*#__PURE__*/ uniform( 'mat4' ).onRenderUpdate( ( { camera } ) => camera.matrixWorld );
|
|
11
|
+
export const cameraNormalMatrix = /*#__PURE__*/ uniform( 'mat3' ).onRenderUpdate( ( { camera } ) => camera.normalMatrix );
|
|
12
|
+
export const cameraPosition = /*#__PURE__*/ uniform( new Vector3() ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );
|
|
@@ -366,6 +366,7 @@ MaterialNode.LINE_GAP_SIZE = 'gapSize';
|
|
|
366
366
|
MaterialNode.LINE_WIDTH = 'linewidth';
|
|
367
367
|
MaterialNode.LINE_DASH_OFFSET = 'dashOffset';
|
|
368
368
|
MaterialNode.POINT_WIDTH = 'pointWidth';
|
|
369
|
+
MaterialNode.DISPERSION = 'dispersion';
|
|
369
370
|
|
|
370
371
|
export default MaterialNode;
|
|
371
372
|
|
|
@@ -405,6 +406,7 @@ export const materialLineGapSize = nodeImmutable( MaterialNode, MaterialNode.LIN
|
|
|
405
406
|
export const materialLineWidth = nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH );
|
|
406
407
|
export const materialLineDashOffset = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
|
|
407
408
|
export const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
|
|
409
|
+
export const materialDispersion = nodeImmutable( MaterialNode, MaterialNode.DISPERSION );
|
|
408
410
|
export const materialAnisotropyVector = uniform( new Vector2() ).onReference( function ( frame ) {
|
|
409
411
|
|
|
410
412
|
return frame.material;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Object3DNode from './Object3DNode.js';
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
3
|
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { uniform } from '../core/UniformNode.js';
|
|
5
|
+
import { Matrix4 } from 'three';
|
|
4
6
|
|
|
5
7
|
class ModelNode extends Object3DNode {
|
|
6
8
|
|
|
@@ -29,5 +31,6 @@ export const modelWorldMatrix = nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX
|
|
|
29
31
|
export const modelPosition = nodeImmutable( ModelNode, ModelNode.POSITION );
|
|
30
32
|
export const modelScale = nodeImmutable( ModelNode, ModelNode.SCALE );
|
|
31
33
|
export const modelViewPosition = nodeImmutable( ModelNode, ModelNode.VIEW_POSITION );
|
|
34
|
+
export const modelWorldMatrixInverse = uniform( new Matrix4() ).onObjectUpdate( ( { object }, self ) => self.value.copy( object.matrixWorld ).invert() );
|
|
32
35
|
|
|
33
36
|
addNodeClass( 'ModelNode', ModelNode );
|
|
@@ -1,106 +1,14 @@
|
|
|
1
|
-
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
1
|
import { attribute } from '../core/AttributeNode.js';
|
|
3
2
|
import { varying } from '../core/VaryingNode.js';
|
|
4
3
|
import { property } from '../core/PropertyNode.js';
|
|
5
|
-
import { normalize } from '../math/MathNode.js';
|
|
6
4
|
import { cameraViewMatrix } from './CameraNode.js';
|
|
7
5
|
import { modelNormalMatrix } from './ModelNode.js';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
isGlobal() {
|
|
21
|
-
|
|
22
|
-
return true;
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getHash( /*builder*/ ) {
|
|
27
|
-
|
|
28
|
-
return `normal-${this.scope}`;
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
generate( builder ) {
|
|
33
|
-
|
|
34
|
-
const scope = this.scope;
|
|
35
|
-
|
|
36
|
-
let outputNode = null;
|
|
37
|
-
|
|
38
|
-
if ( scope === NormalNode.GEOMETRY ) {
|
|
39
|
-
|
|
40
|
-
const geometryAttribute = builder.hasGeometryAttribute( 'normal' );
|
|
41
|
-
|
|
42
|
-
if ( geometryAttribute === false ) {
|
|
43
|
-
|
|
44
|
-
outputNode = vec3( 0, 1, 0 );
|
|
45
|
-
|
|
46
|
-
} else {
|
|
47
|
-
|
|
48
|
-
outputNode = attribute( 'normal', 'vec3' );
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
} else if ( scope === NormalNode.LOCAL ) {
|
|
53
|
-
|
|
54
|
-
outputNode = varying( normalGeometry );
|
|
55
|
-
|
|
56
|
-
} else if ( scope === NormalNode.VIEW ) {
|
|
57
|
-
|
|
58
|
-
const vertexNode = modelNormalMatrix.mul( normalLocal );
|
|
59
|
-
outputNode = normalize( varying( vertexNode ) );
|
|
60
|
-
|
|
61
|
-
} else if ( scope === NormalNode.WORLD ) {
|
|
62
|
-
|
|
63
|
-
// To use inverseTransformDirection only inverse the param order like this: cameraViewMatrix.transformDirection( normalView )
|
|
64
|
-
const vertexNode = normalView.transformDirection( cameraViewMatrix );
|
|
65
|
-
outputNode = normalize( varying( vertexNode ) );
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return outputNode.build( builder, this.getNodeType( builder ) );
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
serialize( data ) {
|
|
74
|
-
|
|
75
|
-
super.serialize( data );
|
|
76
|
-
|
|
77
|
-
data.scope = this.scope;
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
deserialize( data ) {
|
|
82
|
-
|
|
83
|
-
super.deserialize( data );
|
|
84
|
-
|
|
85
|
-
this.scope = data.scope;
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
NormalNode.GEOMETRY = 'geometry';
|
|
92
|
-
NormalNode.LOCAL = 'local';
|
|
93
|
-
NormalNode.VIEW = 'view';
|
|
94
|
-
NormalNode.WORLD = 'world';
|
|
95
|
-
|
|
96
|
-
export default NormalNode;
|
|
97
|
-
|
|
98
|
-
export const normalGeometry = nodeImmutable( NormalNode, NormalNode.GEOMETRY );
|
|
99
|
-
export const normalLocal = nodeImmutable( NormalNode, NormalNode.LOCAL ).temp( 'Normal' );
|
|
100
|
-
export const normalView = nodeImmutable( NormalNode, NormalNode.VIEW );
|
|
101
|
-
export const normalWorld = nodeImmutable( NormalNode, NormalNode.WORLD );
|
|
102
|
-
export const transformedNormalView = property( 'vec3', 'TransformedNormalView' );
|
|
103
|
-
export const transformedNormalWorld = transformedNormalView.transformDirection( cameraViewMatrix ).normalize();
|
|
104
|
-
export const transformedClearcoatNormalView = property( 'vec3', 'TransformedClearcoatNormalView' );
|
|
105
|
-
|
|
106
|
-
addNodeClass( 'NormalNode', NormalNode );
|
|
6
|
+
import { vec3 } from '../shadernode/ShaderNode.js';
|
|
7
|
+
|
|
8
|
+
export const normalGeometry = /*#__PURE__*/ attribute( 'normal', 'vec3', vec3( 0, 1, 0 ) );
|
|
9
|
+
export const normalLocal = /*#__PURE__*/ normalGeometry.toVar( 'normalLocal' );
|
|
10
|
+
export const normalView = /*#__PURE__*/ varying( modelNormalMatrix.mul( normalLocal ), 'v_normalView' ).normalize().toVar( 'normalView' );
|
|
11
|
+
export const normalWorld = /*#__PURE__*/ varying( normalView.transformDirection( cameraViewMatrix ), 'v_normalWorld' ).normalize().toVar( 'transformedNormalWorld' );
|
|
12
|
+
export const transformedNormalView = /*#__PURE__*/ property( 'vec3', 'transformedNormalView' );
|
|
13
|
+
export const transformedNormalWorld = /*#__PURE__*/ transformedNormalView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedNormalWorld' );
|
|
14
|
+
export const transformedClearcoatNormalView = /*#__PURE__*/ property( 'vec3', 'transformedClearcoatNormalView' );
|