super-three 0.155.0 → 0.157.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 +361 -324
- package/build/three.js +361 -324
- package/build/three.min.js +2 -2
- package/build/three.module.js +354 -323
- package/build/three.module.min.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +17 -0
- package/examples/jsm/controls/DragControls.js +3 -2
- package/examples/jsm/controls/OrbitControls.js +13 -5
- package/examples/jsm/csm/CSMShader.js +59 -21
- package/examples/jsm/exporters/EXRExporter.js +102 -24
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/lights/LightProbeGenerator.js +37 -3
- package/examples/jsm/lines/LineMaterial.js +90 -156
- package/examples/jsm/loaders/3DMLoader.js +378 -104
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +2 -0
- package/examples/jsm/loaders/GLTFLoader.js +18 -8
- package/examples/jsm/loaders/KTX2Loader.js +126 -77
- package/examples/jsm/loaders/LDrawLoader.js +22 -16
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/loaders/USDZLoader.js +215 -12
- package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
- package/examples/jsm/nodes/Nodes.js +8 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +30 -4
- package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +19 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +4 -5
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +29 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +23 -13
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +12 -9
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
- package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/Object3DNode.js +3 -3
- package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
- package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +18 -8
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
- package/examples/jsm/nodes/code/CodeNode.js +1 -1
- package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +18 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
- package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
- package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/BypassNode.js +1 -1
- package/examples/jsm/nodes/core/CacheNode.js +1 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/ContextNode.js +2 -2
- package/examples/jsm/nodes/core/IndexNode.js +1 -1
- package/examples/jsm/nodes/core/InputNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +45 -14
- package/examples/jsm/nodes/core/NodeBuilder.js +83 -15
- package/examples/jsm/nodes/core/NodeFrame.js +37 -14
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
- package/examples/jsm/nodes/core/PropertyNode.js +3 -1
- package/examples/jsm/nodes/core/StackNode.js +5 -5
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +3 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -1
- package/examples/jsm/nodes/core/VaryingNode.js +1 -1
- package/examples/jsm/nodes/core/constants.js +1 -1
- package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
- package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
- package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +21 -7
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
- package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
- package/examples/jsm/nodes/fog/FogNode.js +2 -2
- package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AONode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
- package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +2 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/NodeMaterial.js +39 -29
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/CondNode.js +1 -1
- package/examples/jsm/nodes/math/HashNode.js +34 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -2
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +85 -28
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
- package/examples/jsm/nodes/utils/JoinNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +11 -11
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/OscNode.js +2 -2
- package/examples/jsm/nodes/utils/PackingNode.js +2 -2
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
- package/examples/jsm/nodes/utils/SetNode.js +62 -0
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +2 -2
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
- package/examples/jsm/objects/Sky.js +1 -3
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/OutputPass.js +3 -2
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/Binding.js +6 -0
- package/examples/jsm/renderers/common/Bindings.js +4 -5
- package/examples/jsm/renderers/common/Pipelines.js +9 -9
- package/examples/jsm/renderers/common/RenderContext.js +3 -0
- package/examples/jsm/renderers/common/RenderContexts.js +26 -1
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +43 -15
- package/examples/jsm/renderers/common/RenderObjects.js +8 -14
- package/examples/jsm/renderers/common/Renderer.js +52 -16
- package/examples/jsm/renderers/common/SampledTexture.js +6 -3
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/StorageTexture.js +19 -0
- package/examples/jsm/renderers/common/Textures.js +166 -21
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +21 -11
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -7
- package/examples/jsm/renderers/common/nodes/Nodes.js +79 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +702 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +207 -20
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +212 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +4 -4
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +282 -43
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +93 -60
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -14
- package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +205 -284
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +4 -4
- package/examples/jsm/shaders/OutputShader.js +2 -2
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
- package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
- package/package.json +1 -1
- package/src/Three.js +1 -2
- package/src/animation/AnimationUtils.js +3 -20
- package/src/animation/KeyframeTrack.js +8 -8
- package/src/audio/Audio.js +6 -0
- package/src/cameras/Camera.js +1 -5
- package/src/cameras/CubeCamera.js +14 -8
- package/src/constants.js +10 -1
- package/src/core/Object3D.js +1 -14
- package/src/core/RenderTarget.js +16 -7
- package/src/core/UniformsGroup.js +2 -2
- package/src/extras/core/CurvePath.js +4 -1
- package/src/loaders/DataTextureLoader.js +0 -2
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +6 -0
- package/src/materials/Material.js +10 -10
- package/src/math/Color.js +1 -5
- package/src/math/ColorManagement.js +82 -60
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +42 -51
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +9 -17
- package/src/renderers/webgl/WebGLLights.js +14 -3
- package/src/renderers/webgl/WebGLProgram.js +36 -5
- package/src/renderers/webgl/WebGLPrograms.js +9 -1
- package/src/renderers/webgl/WebGLTextures.js +19 -8
- package/src/renderers/webgl/WebGLUtils.js +25 -20
- package/src/scenes/Fog.js +1 -0
- package/src/scenes/FogExp2.js +1 -0
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/src/lights/AmbientLightProbe.js +0 -21
- package/src/lights/HemisphereLightProbe.js +0 -30
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
|
@@ -4,14 +4,16 @@ import {
|
|
|
4
4
|
ClampToEdgeWrapping,
|
|
5
5
|
FileLoader,
|
|
6
6
|
Group,
|
|
7
|
+
NoColorSpace,
|
|
7
8
|
Loader,
|
|
8
9
|
Mesh,
|
|
9
|
-
|
|
10
|
+
MeshPhysicalMaterial,
|
|
10
11
|
MirroredRepeatWrapping,
|
|
11
12
|
RepeatWrapping,
|
|
12
13
|
SRGBColorSpace,
|
|
13
14
|
TextureLoader,
|
|
14
15
|
Object3D,
|
|
16
|
+
Vector2
|
|
15
17
|
} from 'three';
|
|
16
18
|
|
|
17
19
|
import * as fflate from '../libs/fflate.module.js';
|
|
@@ -178,7 +180,14 @@ class USDZLoader extends Loader {
|
|
|
178
180
|
|
|
179
181
|
}
|
|
180
182
|
|
|
181
|
-
if ( filename.endsWith( 'usd' ) ) {
|
|
183
|
+
if ( filename.endsWith( 'usd' ) || filename.endsWith( 'usda' ) ) {
|
|
184
|
+
|
|
185
|
+
if ( isCrateFile( zip[ filename ] ) ) {
|
|
186
|
+
|
|
187
|
+
console.warn( 'THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.' );
|
|
188
|
+
continue;
|
|
189
|
+
|
|
190
|
+
}
|
|
182
191
|
|
|
183
192
|
const text = fflate.strFromU8( zip[ filename ] );
|
|
184
193
|
data[ filename ] = parser.parse( text );
|
|
@@ -191,18 +200,56 @@ class USDZLoader extends Loader {
|
|
|
191
200
|
|
|
192
201
|
}
|
|
193
202
|
|
|
203
|
+
function isCrateFile( buffer ) {
|
|
204
|
+
|
|
205
|
+
// Check if this a crate file. First 7 bytes of a crate file are "PXR-USDC".
|
|
206
|
+
const fileHeader = buffer.slice( 0, 7 );
|
|
207
|
+
const crateHeader = new Uint8Array( [ 0x50, 0x58, 0x52, 0x2D, 0x55, 0x53, 0x44, 0x43 ] );
|
|
208
|
+
|
|
209
|
+
// If this is not a crate file, we assume it is a plain USDA file.
|
|
210
|
+
return fileHeader.every( ( value, index ) => value === crateHeader[ index ] );
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
194
214
|
function findUSD( zip ) {
|
|
195
215
|
|
|
196
|
-
|
|
216
|
+
if ( zip.length < 1 ) return undefined;
|
|
217
|
+
|
|
218
|
+
const firstFileName = Object.keys( zip )[ 0 ];
|
|
219
|
+
let isCrate = false;
|
|
220
|
+
|
|
221
|
+
// As per the USD specification, the first entry in the zip archive is used as the main file ("UsdStage").
|
|
222
|
+
// ASCII files can end in either .usda or .usd.
|
|
223
|
+
// See https://openusd.org/release/spec_usdz.html#layout
|
|
224
|
+
if ( firstFileName.endsWith( 'usda' ) ) return zip[ firstFileName ];
|
|
225
|
+
|
|
226
|
+
if ( firstFileName.endsWith( 'usdc' ) ) {
|
|
227
|
+
|
|
228
|
+
isCrate = true;
|
|
197
229
|
|
|
198
|
-
|
|
230
|
+
} else if ( firstFileName.endsWith( 'usd' ) ) {
|
|
199
231
|
|
|
200
|
-
|
|
232
|
+
// If this is not a crate file, we assume it is a plain USDA file.
|
|
233
|
+
if ( ! isCrateFile( zip[ firstFileName ] ) ) {
|
|
234
|
+
|
|
235
|
+
return zip[ firstFileName ];
|
|
236
|
+
|
|
237
|
+
} else {
|
|
238
|
+
|
|
239
|
+
isCrate = true;
|
|
201
240
|
|
|
202
241
|
}
|
|
203
242
|
|
|
204
243
|
}
|
|
205
244
|
|
|
245
|
+
if ( isCrate ) {
|
|
246
|
+
|
|
247
|
+
console.warn( 'THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.' );
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return undefined;
|
|
252
|
+
|
|
206
253
|
}
|
|
207
254
|
|
|
208
255
|
const zip = fflate.unzipSync( new Uint8Array( buffer ) );
|
|
@@ -252,9 +299,11 @@ class USDZLoader extends Loader {
|
|
|
252
299
|
|
|
253
300
|
function findGeometry( data, id ) {
|
|
254
301
|
|
|
302
|
+
if ( ! data ) return undefined;
|
|
303
|
+
|
|
255
304
|
if ( id !== undefined ) {
|
|
256
305
|
|
|
257
|
-
const def = `def "${id}"`;
|
|
306
|
+
const def = `def Mesh "${id}"`;
|
|
258
307
|
|
|
259
308
|
if ( def in data ) {
|
|
260
309
|
|
|
@@ -280,9 +329,9 @@ class USDZLoader extends Loader {
|
|
|
280
329
|
|
|
281
330
|
// Move st to Mesh
|
|
282
331
|
|
|
283
|
-
if ( '
|
|
332
|
+
if ( 'texCoord2f[] primvars:st' in data ) {
|
|
284
333
|
|
|
285
|
-
object[ '
|
|
334
|
+
object[ 'texCoord2f[] primvars:st' ] = data[ 'texCoord2f[] primvars:st' ];
|
|
286
335
|
|
|
287
336
|
}
|
|
288
337
|
|
|
@@ -320,7 +369,7 @@ class USDZLoader extends Loader {
|
|
|
320
369
|
if ( 'int[] faceVertexIndices' in data ) {
|
|
321
370
|
|
|
322
371
|
const indices = JSON.parse( data[ 'int[] faceVertexIndices' ] );
|
|
323
|
-
geometry.setIndex(
|
|
372
|
+
geometry.setIndex( indices );
|
|
324
373
|
|
|
325
374
|
}
|
|
326
375
|
|
|
@@ -441,9 +490,33 @@ class USDZLoader extends Loader {
|
|
|
441
490
|
|
|
442
491
|
}
|
|
443
492
|
|
|
493
|
+
function setTextureParams( map, data_value ) {
|
|
494
|
+
|
|
495
|
+
// rotation, scale and translation
|
|
496
|
+
|
|
497
|
+
if ( data_value[ 'float inputs:rotation' ] ) {
|
|
498
|
+
|
|
499
|
+
map.rotation = parseFloat( data_value[ 'float inputs:rotation' ] );
|
|
500
|
+
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if ( data_value[ 'float2 inputs:scale' ] ) {
|
|
504
|
+
|
|
505
|
+
map.repeat = new Vector2().fromArray( JSON.parse( '[' + data_value[ 'float2 inputs:scale' ].replace( /[()]*/g, '' ) + ']' ) );
|
|
506
|
+
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if ( data_value[ 'float2 inputs:translation' ] ) {
|
|
510
|
+
|
|
511
|
+
map.offset = new Vector2().fromArray( JSON.parse( '[' + data_value[ 'float2 inputs:translation' ].replace( /[()]*/g, '' ) + ']' ) );
|
|
512
|
+
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
}
|
|
516
|
+
|
|
444
517
|
function buildMaterial( data ) {
|
|
445
518
|
|
|
446
|
-
const material = new
|
|
519
|
+
const material = new MeshPhysicalMaterial();
|
|
447
520
|
|
|
448
521
|
if ( data !== undefined ) {
|
|
449
522
|
|
|
@@ -459,6 +532,12 @@ class USDZLoader extends Loader {
|
|
|
459
532
|
material.map = buildTexture( sampler );
|
|
460
533
|
material.map.colorSpace = SRGBColorSpace;
|
|
461
534
|
|
|
535
|
+
if ( 'def Shader "Transform2d_diffuse"' in data ) {
|
|
536
|
+
|
|
537
|
+
setTextureParams( material.map, data[ 'def Shader "Transform2d_diffuse"' ] );
|
|
538
|
+
|
|
539
|
+
}
|
|
540
|
+
|
|
462
541
|
} else if ( 'color3f inputs:diffuseColor' in surface ) {
|
|
463
542
|
|
|
464
543
|
const color = surface[ 'color3f inputs:diffuseColor' ].replace( /[()]*/g, '' );
|
|
@@ -466,27 +545,150 @@ class USDZLoader extends Loader {
|
|
|
466
545
|
|
|
467
546
|
}
|
|
468
547
|
|
|
548
|
+
if ( 'color3f inputs:emissiveColor.connect' in surface ) {
|
|
549
|
+
|
|
550
|
+
const path = surface[ 'color3f inputs:emissiveColor.connect' ];
|
|
551
|
+
const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
|
|
552
|
+
|
|
553
|
+
material.emissiveMap = buildTexture( sampler );
|
|
554
|
+
material.emissiveMap.colorSpace = SRGBColorSpace;
|
|
555
|
+
material.emissive.set( 0xffffff );
|
|
556
|
+
|
|
557
|
+
if ( 'def Shader "Transform2d_emissive"' in data ) {
|
|
558
|
+
|
|
559
|
+
setTextureParams( material.emissiveMap, data[ 'def Shader "Transform2d_emissive"' ] );
|
|
560
|
+
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
} else if ( 'color3f inputs:emissiveColor' in surface ) {
|
|
564
|
+
|
|
565
|
+
const color = surface[ 'color3f inputs:emissiveColor' ].replace( /[()]*/g, '' );
|
|
566
|
+
material.emissive.fromArray( JSON.parse( '[' + color + ']' ) );
|
|
567
|
+
|
|
568
|
+
}
|
|
569
|
+
|
|
469
570
|
if ( 'normal3f inputs:normal.connect' in surface ) {
|
|
470
571
|
|
|
471
572
|
const path = surface[ 'normal3f inputs:normal.connect' ];
|
|
472
573
|
const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
|
|
473
574
|
|
|
474
575
|
material.normalMap = buildTexture( sampler );
|
|
576
|
+
material.normalMap.colorSpace = NoColorSpace;
|
|
577
|
+
|
|
578
|
+
if ( 'def Shader "Transform2d_normal"' in data ) {
|
|
579
|
+
|
|
580
|
+
setTextureParams( material.normalMap, data[ 'def Shader "Transform2d_normal"' ] );
|
|
581
|
+
|
|
582
|
+
}
|
|
475
583
|
|
|
476
584
|
}
|
|
477
585
|
|
|
478
|
-
if ( 'float inputs:roughness' in surface ) {
|
|
586
|
+
if ( 'float inputs:roughness.connect' in surface ) {
|
|
587
|
+
|
|
588
|
+
const path = surface[ 'float inputs:roughness.connect' ];
|
|
589
|
+
const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
|
|
590
|
+
|
|
591
|
+
material.roughness = 1.0;
|
|
592
|
+
material.roughnessMap = buildTexture( sampler );
|
|
593
|
+
material.roughnessMap.colorSpace = NoColorSpace;
|
|
594
|
+
|
|
595
|
+
if ( 'def Shader "Transform2d_roughness"' in data ) {
|
|
596
|
+
|
|
597
|
+
setTextureParams( material.roughnessMap, data[ 'def Shader "Transform2d_roughness"' ] );
|
|
598
|
+
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
} else if ( 'float inputs:roughness' in surface ) {
|
|
479
602
|
|
|
480
603
|
material.roughness = parseFloat( surface[ 'float inputs:roughness' ] );
|
|
481
604
|
|
|
482
605
|
}
|
|
483
606
|
|
|
484
|
-
if ( 'float inputs:metallic' in surface ) {
|
|
607
|
+
if ( 'float inputs:metallic.connect' in surface ) {
|
|
608
|
+
|
|
609
|
+
const path = surface[ 'float inputs:metallic.connect' ];
|
|
610
|
+
const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
|
|
611
|
+
|
|
612
|
+
material.metalness = 1.0;
|
|
613
|
+
material.metalnessMap = buildTexture( sampler );
|
|
614
|
+
material.metalnessMap.colorSpace = NoColorSpace;
|
|
615
|
+
|
|
616
|
+
if ( 'def Shader "Transform2d_metallic"' in data ) {
|
|
617
|
+
|
|
618
|
+
setTextureParams( material.metalnessMap, data[ 'def Shader "Transform2d_metallic"' ] );
|
|
619
|
+
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
} else if ( 'float inputs:metallic' in surface ) {
|
|
485
623
|
|
|
486
624
|
material.metalness = parseFloat( surface[ 'float inputs:metallic' ] );
|
|
487
625
|
|
|
488
626
|
}
|
|
489
627
|
|
|
628
|
+
if ( 'float inputs:clearcoat.connect' in surface ) {
|
|
629
|
+
|
|
630
|
+
const path = surface[ 'float inputs:clearcoat.connect' ];
|
|
631
|
+
const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
|
|
632
|
+
|
|
633
|
+
material.clearcoat = 1.0;
|
|
634
|
+
material.clearcoatMap = buildTexture( sampler );
|
|
635
|
+
material.clearcoatMap.colorSpace = NoColorSpace;
|
|
636
|
+
|
|
637
|
+
if ( 'def Shader "Transform2d_clearcoat"' in data ) {
|
|
638
|
+
|
|
639
|
+
setTextureParams( material.clearcoatMap, data[ 'def Shader "Transform2d_clearcoat"' ] );
|
|
640
|
+
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
} else if ( 'float inputs:clearcoat' in surface ) {
|
|
644
|
+
|
|
645
|
+
material.clearcoat = parseFloat( surface[ 'float inputs:clearcoat' ] );
|
|
646
|
+
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if ( 'float inputs:clearcoatRoughness.connect' in surface ) {
|
|
650
|
+
|
|
651
|
+
const path = surface[ 'float inputs:clearcoatRoughness.connect' ];
|
|
652
|
+
const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
|
|
653
|
+
|
|
654
|
+
material.clearcoatRoughness = 1.0;
|
|
655
|
+
material.clearcoatRoughnessMap = buildTexture( sampler );
|
|
656
|
+
material.clearcoatRoughnessMap.colorSpace = NoColorSpace;
|
|
657
|
+
|
|
658
|
+
if ( 'def Shader "Transform2d_clearcoatRoughness"' in data ) {
|
|
659
|
+
|
|
660
|
+
setTextureParams( material.clearcoatRoughnessMap, data[ 'def Shader "Transform2d_clearcoatRoughness"' ] );
|
|
661
|
+
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
} else if ( 'float inputs:clearcoatRoughness' in surface ) {
|
|
665
|
+
|
|
666
|
+
material.clearcoatRoughness = parseFloat( surface[ 'float inputs:clearcoatRoughness' ] );
|
|
667
|
+
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
if ( 'float inputs:ior' in surface ) {
|
|
671
|
+
|
|
672
|
+
material.ior = parseFloat( surface[ 'float inputs:ior' ] );
|
|
673
|
+
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if ( 'float inputs:occlusion.connect' in surface ) {
|
|
677
|
+
|
|
678
|
+
const path = surface[ 'float inputs:occlusion.connect' ];
|
|
679
|
+
const sampler = findTexture( root, /(\w+).output/.exec( path )[ 1 ] );
|
|
680
|
+
|
|
681
|
+
material.aoMap = buildTexture( sampler );
|
|
682
|
+
material.aoMap.colorSpace = NoColorSpace;
|
|
683
|
+
|
|
684
|
+
if ( 'def Shader "Transform2d_occlusion"' in data ) {
|
|
685
|
+
|
|
686
|
+
setTextureParams( material.aoMap, data[ 'def Shader "Transform2d_occlusion"' ] );
|
|
687
|
+
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
}
|
|
691
|
+
|
|
490
692
|
}
|
|
491
693
|
|
|
492
694
|
if ( 'def Shader "diffuseColor_texture"' in data ) {
|
|
@@ -503,6 +705,7 @@ class USDZLoader extends Loader {
|
|
|
503
705
|
const sampler = data[ 'def Shader "normal_texture"' ];
|
|
504
706
|
|
|
505
707
|
material.normalMap = buildTexture( sampler );
|
|
708
|
+
material.normalMap.colorSpace = NoColorSpace;
|
|
506
709
|
|
|
507
710
|
}
|
|
508
711
|
|
|
@@ -74,15 +74,11 @@ const GouraudShader = {
|
|
|
74
74
|
|
|
75
75
|
vec3 diffuse = vec3( 1.0 );
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
|
|
77
|
+
vec3 geometryPosition = mvPosition.xyz;
|
|
78
|
+
vec3 geometryNormal = normalize( transformedNormal );
|
|
79
|
+
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
backGeometry.position = geometry.position;
|
|
84
|
-
backGeometry.normal = -geometry.normal;
|
|
85
|
-
backGeometry.viewDir = geometry.viewDir;
|
|
81
|
+
vec3 backGeometryNormal = - geometryNormal;
|
|
86
82
|
|
|
87
83
|
vLightFront = vec3( 0.0 );
|
|
88
84
|
vIndirectFront = vec3( 0.0 );
|
|
@@ -97,13 +93,21 @@ const GouraudShader = {
|
|
|
97
93
|
|
|
98
94
|
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
|
|
99
95
|
|
|
100
|
-
|
|
96
|
+
#if defined( USE_LIGHT_PROBES )
|
|
97
|
+
|
|
98
|
+
vIndirectFront += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
99
|
+
|
|
100
|
+
#endif
|
|
101
101
|
|
|
102
102
|
#ifdef DOUBLE_SIDED
|
|
103
103
|
|
|
104
104
|
vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
#if defined( USE_LIGHT_PROBES )
|
|
107
|
+
|
|
108
|
+
vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometryNormal );
|
|
109
|
+
|
|
110
|
+
#endif
|
|
107
111
|
|
|
108
112
|
#endif
|
|
109
113
|
|
|
@@ -112,9 +116,9 @@ const GouraudShader = {
|
|
|
112
116
|
#pragma unroll_loop_start
|
|
113
117
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
114
118
|
|
|
115
|
-
getPointLightInfo( pointLights[ i ],
|
|
119
|
+
getPointLightInfo( pointLights[ i ], geometryPosition, directLight );
|
|
116
120
|
|
|
117
|
-
dotNL = dot(
|
|
121
|
+
dotNL = dot( geometryNormal, directLight.direction );
|
|
118
122
|
directLightColor_Diffuse = directLight.color;
|
|
119
123
|
|
|
120
124
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
|
@@ -135,9 +139,9 @@ const GouraudShader = {
|
|
|
135
139
|
#pragma unroll_loop_start
|
|
136
140
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
137
141
|
|
|
138
|
-
getSpotLightInfo( spotLights[ i ],
|
|
142
|
+
getSpotLightInfo( spotLights[ i ], geometryPosition, directLight );
|
|
139
143
|
|
|
140
|
-
dotNL = dot(
|
|
144
|
+
dotNL = dot( geometryNormal, directLight.direction );
|
|
141
145
|
directLightColor_Diffuse = directLight.color;
|
|
142
146
|
|
|
143
147
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
|
@@ -157,9 +161,9 @@ const GouraudShader = {
|
|
|
157
161
|
#pragma unroll_loop_start
|
|
158
162
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
159
163
|
|
|
160
|
-
getDirectionalLightInfo( directionalLights[ i ],
|
|
164
|
+
getDirectionalLightInfo( directionalLights[ i ], directLight );
|
|
161
165
|
|
|
162
|
-
dotNL = dot(
|
|
166
|
+
dotNL = dot( geometryNormal, directLight.direction );
|
|
163
167
|
directLightColor_Diffuse = directLight.color;
|
|
164
168
|
|
|
165
169
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
|
@@ -180,11 +184,11 @@ const GouraudShader = {
|
|
|
180
184
|
#pragma unroll_loop_start
|
|
181
185
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
182
186
|
|
|
183
|
-
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ],
|
|
187
|
+
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
184
188
|
|
|
185
189
|
#ifdef DOUBLE_SIDED
|
|
186
190
|
|
|
187
|
-
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ],
|
|
191
|
+
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometryNormal );
|
|
188
192
|
|
|
189
193
|
#endif
|
|
190
194
|
|
|
@@ -30,6 +30,7 @@ export { default as TempNode } from './core/TempNode.js';
|
|
|
30
30
|
export { default as UniformNode, uniform } from './core/UniformNode.js';
|
|
31
31
|
export { default as VarNode, temp } from './core/VarNode.js';
|
|
32
32
|
export { default as VaryingNode, varying } from './core/VaryingNode.js';
|
|
33
|
+
export { default as OutputStructNode, outputStruct } from './core/OutputStructNode.js';
|
|
33
34
|
|
|
34
35
|
import * as NodeUtils from './core/NodeUtils.js';
|
|
35
36
|
export { NodeUtils };
|
|
@@ -38,6 +39,7 @@ export { NodeUtils };
|
|
|
38
39
|
export { default as MathNode, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward } from './math/MathNode.js';
|
|
39
40
|
export { default as OperatorNode, add, sub, mul, div, remainder, equal, assign, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, xor, bitAnd, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
|
|
40
41
|
export { default as CondNode, cond } from './math/CondNode.js';
|
|
42
|
+
export { default as HashNode, hash } from './math/HashNode.js';
|
|
41
43
|
|
|
42
44
|
// utils
|
|
43
45
|
export { default as ArrayElementNode } from './utils/ArrayElementNode.js';
|
|
@@ -52,6 +54,7 @@ export { default as OscNode, oscSine, oscSquare, oscTriangle, oscSawtooth } from
|
|
|
52
54
|
export { default as PackingNode, directionToColor, colorToDirection } from './utils/PackingNode.js';
|
|
53
55
|
export { default as RemapNode, remap, remapClamp } from './utils/RemapNode.js';
|
|
54
56
|
export { default as RotateUVNode, rotateUV } from './utils/RotateUVNode.js';
|
|
57
|
+
export { default as SetNode } from './utils/SetNode.js';
|
|
55
58
|
export { default as SpecularMIPLevelNode, specularMIPLevel } from './utils/SpecularMIPLevelNode.js';
|
|
56
59
|
export { default as SplitNode } from './utils/SplitNode.js';
|
|
57
60
|
export { default as SpriteSheetUVNode, spritesheetUV } from './utils/SpriteSheetUVNode.js';
|
|
@@ -69,6 +72,7 @@ export { default as CameraNode, cameraProjectionMatrix, cameraViewMatrix, camera
|
|
|
69
72
|
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
|
|
70
73
|
export { default as ExtendedMaterialNode, materialNormal } from './accessors/ExtendedMaterialNode.js';
|
|
71
74
|
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
|
|
75
|
+
export { default as LineMaterialNode, materialLineDashSize, materialLineDashOffset, materialLineGapSize, materialLineScale, materialLineWidth } from './accessors/LineMaterialNode.js';
|
|
72
76
|
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialReflectivity, materialRoughness, materialMetalness, materialRotation, materialSheen, materialSheenRoughness } from './accessors/MaterialNode.js';
|
|
73
77
|
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
|
|
74
78
|
export { default as MorphNode, morph } from './accessors/MorphNode.js';
|
|
@@ -86,18 +90,20 @@ export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from
|
|
|
86
90
|
export { default as StorageBufferNode, storage } from './accessors/StorageBufferNode.js';
|
|
87
91
|
export { default as TangentNode, tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView, transformedTangentWorld } from './accessors/TangentNode.js';
|
|
88
92
|
export { default as TextureNode, texture, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
|
|
93
|
+
export { default as TextureStoreNode, textureStore } from './accessors/TextureStoreNode.js';
|
|
89
94
|
export { default as UVNode, uv } from './accessors/UVNode.js';
|
|
90
95
|
export { default as UserDataNode, userData } from './accessors/UserDataNode.js';
|
|
91
96
|
|
|
92
97
|
// display
|
|
93
98
|
export { default as BlendModeNode, burn, dodge, overlay, screen } from './display/BlendModeNode.js';
|
|
99
|
+
export { default as BumpMapNode, bumpMap } from './display/BumpMapNode.js';
|
|
94
100
|
export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance } from './display/ColorAdjustmentNode.js';
|
|
95
101
|
export { default as ColorSpaceNode, linearToColorSpace, colorSpaceToLinear, linearTosRGB, sRGBToLinear } from './display/ColorSpaceNode.js';
|
|
96
102
|
export { default as FrontFacingNode, frontFacing, faceDirection } from './display/FrontFacingNode.js';
|
|
97
103
|
export { default as NormalMapNode, normalMap, TBNViewMatrix } from './display/NormalMapNode.js';
|
|
98
104
|
export { default as PosterizeNode, posterize } from './display/PosterizeNode.js';
|
|
99
105
|
export { default as ToneMappingNode, toneMapping } from './display/ToneMappingNode.js';
|
|
100
|
-
export { default as ViewportNode, viewportCoordinate, viewportResolution, viewportTopLeft, viewportBottomLeft, viewportTopRight, viewportBottomRight } from './display/ViewportNode.js';
|
|
106
|
+
export { default as ViewportNode, viewport, viewportCoordinate, viewportResolution, viewportTopLeft, viewportBottomLeft, viewportTopRight, viewportBottomRight } from './display/ViewportNode.js';
|
|
101
107
|
export { default as ViewportTextureNode, viewportTexture, viewportMipTexture } from './display/ViewportTextureNode.js';
|
|
102
108
|
export { default as ViewportSharedTextureNode, viewportSharedTexture } from './display/ViewportSharedTextureNode.js';
|
|
103
109
|
export { default as ViewportDepthTextureNode, viewportDepthTexture } from './display/ViewportDepthTextureNode.js';
|
|
@@ -160,6 +166,7 @@ export { default as BRDF_Lambert } from './functions/BSDF/BRDF_Lambert.js';
|
|
|
160
166
|
export { default as D_GGX } from './functions/BSDF/D_GGX.js';
|
|
161
167
|
export { default as DFGApprox } from './functions/BSDF/DFGApprox.js';
|
|
162
168
|
export { default as F_Schlick } from './functions/BSDF/F_Schlick.js';
|
|
169
|
+
export { default as Schlick_to_F0 } from './functions/BSDF/Schlick_to_F0.js';
|
|
163
170
|
export { default as V_GGX_SmithCorrelated } from './functions/BSDF/V_GGX_SmithCorrelated.js';
|
|
164
171
|
|
|
165
172
|
export { getDistanceAttenuation } from './lighting/LightUtils.js';
|
|
@@ -86,4 +86,4 @@ export const bitangentWorld = nodeImmutable( BitangentNode, BitangentNode.WORLD
|
|
|
86
86
|
export const transformedBitangentView = normalize( transformedNormalView.cross( transformedTangentView ).mul( tangentGeometry.w ) );
|
|
87
87
|
export const transformedBitangentWorld = normalize( transformedBitangentView.transformDirection( cameraViewMatrix ) );
|
|
88
88
|
|
|
89
|
-
addNodeClass( BitangentNode );
|
|
89
|
+
addNodeClass( 'BitangentNode', BitangentNode );
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import InputNode from '../core/InputNode.js';
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
3
|
import { varying } from '../core/VaryingNode.js';
|
|
4
|
-
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { nodeObject, addNodeElement } from '../shadernode/ShaderNode.js';
|
|
5
5
|
import { InterleavedBufferAttribute, InterleavedBuffer, StaticDrawUsage, DynamicDrawUsage } from 'three';
|
|
6
6
|
|
|
7
7
|
class BufferAttributeNode extends InputNode {
|
|
8
8
|
|
|
9
|
-
constructor( value, bufferType, bufferStride = 0, bufferOffset = 0 ) {
|
|
9
|
+
constructor( value, bufferType = null, bufferStride = 0, bufferOffset = 0 ) {
|
|
10
10
|
|
|
11
11
|
super( value, bufferType );
|
|
12
12
|
|
|
@@ -19,9 +19,33 @@ class BufferAttributeNode extends InputNode {
|
|
|
19
19
|
this.usage = StaticDrawUsage;
|
|
20
20
|
this.instanced = false;
|
|
21
21
|
|
|
22
|
+
this.attribute = null;
|
|
23
|
+
|
|
24
|
+
if ( value && value.isBufferAttribute === true ) {
|
|
25
|
+
|
|
26
|
+
this.attribute = value;
|
|
27
|
+
this.usage = value.usage;
|
|
28
|
+
this.instanced = value.isInstancedBufferAttribute;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
}
|
|
23
33
|
|
|
24
|
-
|
|
34
|
+
getNodeType( builder ) {
|
|
35
|
+
|
|
36
|
+
if ( this.bufferType === null ) {
|
|
37
|
+
|
|
38
|
+
this.bufferType = builder.getTypeFromAttribute( this.attribute );
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return this.bufferType;
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setup( builder ) {
|
|
47
|
+
|
|
48
|
+
if ( this.attribute !== null ) return;
|
|
25
49
|
|
|
26
50
|
const type = this.getNodeType( builder );
|
|
27
51
|
const array = this.value;
|
|
@@ -96,4 +120,6 @@ export const dynamicBufferAttribute = ( array, type, stride, offset ) => bufferA
|
|
|
96
120
|
export const instancedBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setInstanced( true );
|
|
97
121
|
export const instancedDynamicBufferAttribute = ( array, type, stride, offset ) => dynamicBufferAttribute( array, type, stride, offset ).setInstanced( true );
|
|
98
122
|
|
|
99
|
-
|
|
123
|
+
addNodeElement( 'toAttribute', ( bufferNode ) => bufferAttribute( bufferNode.value ) );
|
|
124
|
+
|
|
125
|
+
addNodeClass( 'BufferAttributeNode', BufferAttributeNode );
|
|
@@ -95,4 +95,4 @@ export const cameraNormalMatrix = nodeImmutable( CameraNode, CameraNode.NORMAL_M
|
|
|
95
95
|
export const cameraWorldMatrix = nodeImmutable( CameraNode, CameraNode.WORLD_MATRIX );
|
|
96
96
|
export const cameraPosition = nodeImmutable( CameraNode, CameraNode.POSITION );
|
|
97
97
|
|
|
98
|
-
addNodeClass( CameraNode );
|
|
98
|
+
addNodeClass( 'CameraNode', CameraNode );
|
|
@@ -2,6 +2,8 @@ import TextureNode from './TextureNode.js';
|
|
|
2
2
|
import UniformNode from '../core/UniformNode.js';
|
|
3
3
|
import { reflectVector } from './ReflectVectorNode.js';
|
|
4
4
|
import { addNodeClass } from '../core/Node.js';
|
|
5
|
+
import { colorSpaceToLinear } from '../display/ColorSpaceNode.js';
|
|
6
|
+
import { expression } from '../code/ExpressionNode.js';
|
|
5
7
|
import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
6
8
|
|
|
7
9
|
class CubeTextureNode extends TextureNode {
|
|
@@ -52,6 +54,7 @@ class CubeTextureNode extends TextureNode {
|
|
|
52
54
|
|
|
53
55
|
} else {
|
|
54
56
|
|
|
57
|
+
const nodeType = this.getNodeType( builder );
|
|
55
58
|
const nodeData = builder.getDataFromNode( this );
|
|
56
59
|
|
|
57
60
|
let propertyName = nodeData.propertyName;
|
|
@@ -81,12 +84,24 @@ class CubeTextureNode extends TextureNode {
|
|
|
81
84
|
|
|
82
85
|
builder.addLineFlowCode( `${propertyName} = ${snippet}` );
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
if ( builder.context.tempWrite !== false ) {
|
|
88
|
+
|
|
89
|
+
nodeData.snippet = snippet;
|
|
90
|
+
nodeData.propertyName = propertyName;
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let snippet = propertyName;
|
|
97
|
+
|
|
98
|
+
if ( builder.needsColorSpaceToLinear( this.value ) ) {
|
|
99
|
+
|
|
100
|
+
snippet = colorSpaceToLinear( expression( snippet, nodeType ), this.value.colorSpace ).setup( builder ).build( builder, nodeType );
|
|
86
101
|
|
|
87
102
|
}
|
|
88
103
|
|
|
89
|
-
return builder.format(
|
|
104
|
+
return builder.format( snippet, 'vec4', output );
|
|
90
105
|
|
|
91
106
|
}
|
|
92
107
|
|
|
@@ -100,4 +115,4 @@ export const cubeTexture = nodeProxy( CubeTextureNode );
|
|
|
100
115
|
|
|
101
116
|
addNodeElement( 'cubeTexture', cubeTexture );
|
|
102
117
|
|
|
103
|
-
addNodeClass( CubeTextureNode );
|
|
118
|
+
addNodeClass( 'CubeTextureNode', CubeTextureNode );
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @TODO: Is this needed? Can it be moved in MaterialNode?
|
|
2
|
-
|
|
3
1
|
import MaterialNode from './MaterialNode.js';
|
|
4
2
|
import { materialReference } from './MaterialReferenceNode.js';
|
|
5
3
|
import { normalView } from './NormalNode.js';
|
|
@@ -31,7 +29,7 @@ class ExtendedMaterialNode extends MaterialNode {
|
|
|
31
29
|
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
setup( builder ) {
|
|
35
33
|
|
|
36
34
|
const material = builder.material;
|
|
37
35
|
const scope = this.scope;
|
|
@@ -46,6 +44,7 @@ class ExtendedMaterialNode extends MaterialNode {
|
|
|
46
44
|
|
|
47
45
|
} else if ( material.bumpMap ) {
|
|
48
46
|
|
|
47
|
+
// @TODO: Replace material.bumpMap to this.getTexture( 'bumpMap' )
|
|
49
48
|
node = bumpMap( material.bumpMap, materialReference( 'bumpScale', 'float' ) );
|
|
50
49
|
|
|
51
50
|
} else {
|
|
@@ -60,7 +59,7 @@ class ExtendedMaterialNode extends MaterialNode {
|
|
|
60
59
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
return node || super.
|
|
62
|
+
return node || super.setup( builder );
|
|
64
63
|
|
|
65
64
|
}
|
|
66
65
|
|
|
@@ -74,4 +73,4 @@ export default ExtendedMaterialNode;
|
|
|
74
73
|
export const materialNormal = nodeImmutable( ExtendedMaterialNode, ExtendedMaterialNode.NORMAL );
|
|
75
74
|
export const materialClearcoatNormal = nodeImmutable( ExtendedMaterialNode, ExtendedMaterialNode.CLEARCOAT_NORMAL );
|
|
76
75
|
|
|
77
|
-
addNodeClass( ExtendedMaterialNode );
|
|
76
|
+
addNodeClass( 'ExtendedMaterialNode', ExtendedMaterialNode );
|
|
@@ -17,7 +17,7 @@ class InstanceNode extends Node {
|
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
setup( builder ) {
|
|
21
21
|
|
|
22
22
|
let instanceMatrixNode = this.instanceMatrixNode;
|
|
23
23
|
|
|
@@ -68,4 +68,4 @@ export default InstanceNode;
|
|
|
68
68
|
|
|
69
69
|
export const instance = nodeProxy( InstanceNode );
|
|
70
70
|
|
|
71
|
-
addNodeClass( InstanceNode );
|
|
71
|
+
addNodeClass( 'InstanceNode', InstanceNode );
|