super-three 0.169.1 → 0.170.1
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 +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- 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/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- 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 +437 -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 +70 -21
- 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/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -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 +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- 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/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +12 -10
- 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/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- 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 +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- 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 +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- 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 +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -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 +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- 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 +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- 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 +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +48 -8
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- 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 +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- 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/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -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 +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- 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/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- 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 +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- 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/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- 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 +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- 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 +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- 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/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -26,8 +26,6 @@ import {
|
|
|
26
26
|
Quaternion,
|
|
27
27
|
REVISION
|
|
28
28
|
} from 'three';
|
|
29
|
-
import { decompress } from './../utils/TextureUtils.js';
|
|
30
|
-
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
31
|
* The KHR_mesh_quantization extension allows these extra attribute component types
|
|
@@ -68,6 +66,8 @@ class GLTFExporter {
|
|
|
68
66
|
|
|
69
67
|
constructor() {
|
|
70
68
|
|
|
69
|
+
this.textureUtils = null;
|
|
70
|
+
|
|
71
71
|
this.pluginCallbacks = [];
|
|
72
72
|
|
|
73
73
|
this.register( function ( writer ) {
|
|
@@ -180,6 +180,14 @@ class GLTFExporter {
|
|
|
180
180
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
setTextureUtils( utils ) {
|
|
184
|
+
|
|
185
|
+
this.textureUtils = utils;
|
|
186
|
+
|
|
187
|
+
return this;
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
183
191
|
/**
|
|
184
192
|
* Parse scenes and generate GLTF output
|
|
185
193
|
* @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
|
|
@@ -199,7 +207,8 @@ class GLTFExporter {
|
|
|
199
207
|
}
|
|
200
208
|
|
|
201
209
|
writer.setPlugins( plugins );
|
|
202
|
-
writer.
|
|
210
|
+
writer.setTextureUtils( this.textureUtils );
|
|
211
|
+
writer.writeAsync( input, onDone, options ).catch( onError );
|
|
203
212
|
|
|
204
213
|
}
|
|
205
214
|
|
|
@@ -516,6 +525,8 @@ class GLTFWriter {
|
|
|
516
525
|
images: new Map()
|
|
517
526
|
};
|
|
518
527
|
|
|
528
|
+
this.textureUtils = null;
|
|
529
|
+
|
|
519
530
|
}
|
|
520
531
|
|
|
521
532
|
setPlugins( plugins ) {
|
|
@@ -524,13 +535,19 @@ class GLTFWriter {
|
|
|
524
535
|
|
|
525
536
|
}
|
|
526
537
|
|
|
538
|
+
setTextureUtils( utils ) {
|
|
539
|
+
|
|
540
|
+
this.textureUtils = utils;
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
527
544
|
/**
|
|
528
545
|
* Parse scenes and generate GLTF output
|
|
529
546
|
* @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
|
|
530
547
|
* @param {Function} onDone Callback on completed
|
|
531
548
|
* @param {Object} options options
|
|
532
549
|
*/
|
|
533
|
-
async
|
|
550
|
+
async writeAsync( input, onDone, options = {} ) {
|
|
534
551
|
|
|
535
552
|
this.options = Object.assign( {
|
|
536
553
|
// default options
|
|
@@ -549,7 +566,7 @@ class GLTFWriter {
|
|
|
549
566
|
|
|
550
567
|
}
|
|
551
568
|
|
|
552
|
-
this.
|
|
569
|
+
await this.processInputAsync( input );
|
|
553
570
|
|
|
554
571
|
await Promise.all( this.pending );
|
|
555
572
|
|
|
@@ -823,7 +840,7 @@ class GLTFWriter {
|
|
|
823
840
|
|
|
824
841
|
}
|
|
825
842
|
|
|
826
|
-
|
|
843
|
+
async buildMetalRoughTextureAsync( metalnessMap, roughnessMap ) {
|
|
827
844
|
|
|
828
845
|
if ( metalnessMap === roughnessMap ) return metalnessMap;
|
|
829
846
|
|
|
@@ -847,17 +864,15 @@ class GLTFWriter {
|
|
|
847
864
|
|
|
848
865
|
}
|
|
849
866
|
|
|
850
|
-
console.warn( 'THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.' );
|
|
851
|
-
|
|
852
867
|
if ( metalnessMap instanceof CompressedTexture ) {
|
|
853
868
|
|
|
854
|
-
metalnessMap =
|
|
869
|
+
metalnessMap = await this.decompressTextureAsync( metalnessMap );
|
|
855
870
|
|
|
856
871
|
}
|
|
857
872
|
|
|
858
873
|
if ( roughnessMap instanceof CompressedTexture ) {
|
|
859
874
|
|
|
860
|
-
roughnessMap =
|
|
875
|
+
roughnessMap = await this.decompressTextureAsync( roughnessMap );
|
|
861
876
|
|
|
862
877
|
}
|
|
863
878
|
|
|
@@ -927,10 +942,25 @@ class GLTFWriter {
|
|
|
927
942
|
|
|
928
943
|
}
|
|
929
944
|
|
|
945
|
+
console.warn( 'THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.' );
|
|
946
|
+
|
|
930
947
|
return texture;
|
|
931
948
|
|
|
932
949
|
}
|
|
933
950
|
|
|
951
|
+
|
|
952
|
+
async decompressTextureAsync( texture, maxTextureSize = Infinity ) {
|
|
953
|
+
|
|
954
|
+
if ( this.textureUtils === null ) {
|
|
955
|
+
|
|
956
|
+
throw new Error( 'THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.' );
|
|
957
|
+
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
return await this.textureUtils.decompress( texture, maxTextureSize );
|
|
961
|
+
|
|
962
|
+
}
|
|
963
|
+
|
|
934
964
|
/**
|
|
935
965
|
* Process a buffer to append to the default one.
|
|
936
966
|
* @param {ArrayBuffer} buffer
|
|
@@ -1407,7 +1437,7 @@ class GLTFWriter {
|
|
|
1407
1437
|
* @param {Texture} map Map to process
|
|
1408
1438
|
* @return {Integer} Index of the processed texture in the "textures" array
|
|
1409
1439
|
*/
|
|
1410
|
-
|
|
1440
|
+
async processTextureAsync( map ) {
|
|
1411
1441
|
|
|
1412
1442
|
const writer = this;
|
|
1413
1443
|
const options = writer.options;
|
|
@@ -1421,7 +1451,7 @@ class GLTFWriter {
|
|
|
1421
1451
|
// make non-readable textures (e.g. CompressedTexture) readable by blitting them into a new texture
|
|
1422
1452
|
if ( map instanceof CompressedTexture ) {
|
|
1423
1453
|
|
|
1424
|
-
map =
|
|
1454
|
+
map = await this.decompressTextureAsync( map, options.maxTextureSize );
|
|
1425
1455
|
|
|
1426
1456
|
}
|
|
1427
1457
|
|
|
@@ -1436,9 +1466,9 @@ class GLTFWriter {
|
|
|
1436
1466
|
|
|
1437
1467
|
if ( map.name ) textureDef.name = map.name;
|
|
1438
1468
|
|
|
1439
|
-
this.
|
|
1469
|
+
await this._invokeAllAsync( async function ( ext ) {
|
|
1440
1470
|
|
|
1441
|
-
ext.writeTexture && ext.writeTexture( map, textureDef );
|
|
1471
|
+
ext.writeTexture && await ext.writeTexture( map, textureDef );
|
|
1442
1472
|
|
|
1443
1473
|
} );
|
|
1444
1474
|
|
|
@@ -1453,7 +1483,7 @@ class GLTFWriter {
|
|
|
1453
1483
|
* @param {THREE.Material} material Material to process
|
|
1454
1484
|
* @return {Integer|null} Index of the processed material in the "materials" array
|
|
1455
1485
|
*/
|
|
1456
|
-
|
|
1486
|
+
async processMaterialAsync( material ) {
|
|
1457
1487
|
|
|
1458
1488
|
const cache = this.cache;
|
|
1459
1489
|
const json = this.json;
|
|
@@ -1494,19 +1524,19 @@ class GLTFWriter {
|
|
|
1494
1524
|
|
|
1495
1525
|
} else {
|
|
1496
1526
|
|
|
1497
|
-
materialDef.pbrMetallicRoughness.metallicFactor = 0
|
|
1498
|
-
materialDef.pbrMetallicRoughness.roughnessFactor =
|
|
1527
|
+
materialDef.pbrMetallicRoughness.metallicFactor = 0;
|
|
1528
|
+
materialDef.pbrMetallicRoughness.roughnessFactor = 1;
|
|
1499
1529
|
|
|
1500
1530
|
}
|
|
1501
1531
|
|
|
1502
1532
|
// pbrMetallicRoughness.metallicRoughnessTexture
|
|
1503
1533
|
if ( material.metalnessMap || material.roughnessMap ) {
|
|
1504
1534
|
|
|
1505
|
-
const metalRoughTexture = this.
|
|
1535
|
+
const metalRoughTexture = await this.buildMetalRoughTextureAsync( material.metalnessMap, material.roughnessMap );
|
|
1506
1536
|
|
|
1507
1537
|
const metalRoughMapDef = {
|
|
1508
|
-
index: this.
|
|
1509
|
-
|
|
1538
|
+
index: await this.processTextureAsync( metalRoughTexture ),
|
|
1539
|
+
texCoord: metalRoughTexture.channel
|
|
1510
1540
|
};
|
|
1511
1541
|
this.applyTextureTransform( metalRoughMapDef, metalRoughTexture );
|
|
1512
1542
|
materialDef.pbrMetallicRoughness.metallicRoughnessTexture = metalRoughMapDef;
|
|
@@ -1517,7 +1547,7 @@ class GLTFWriter {
|
|
|
1517
1547
|
if ( material.map ) {
|
|
1518
1548
|
|
|
1519
1549
|
const baseColorMapDef = {
|
|
1520
|
-
index: this.
|
|
1550
|
+
index: await this.processTextureAsync( material.map ),
|
|
1521
1551
|
texCoord: material.map.channel
|
|
1522
1552
|
};
|
|
1523
1553
|
this.applyTextureTransform( baseColorMapDef, material.map );
|
|
@@ -1540,7 +1570,7 @@ class GLTFWriter {
|
|
|
1540
1570
|
if ( material.emissiveMap ) {
|
|
1541
1571
|
|
|
1542
1572
|
const emissiveMapDef = {
|
|
1543
|
-
index: this.
|
|
1573
|
+
index: await this.processTextureAsync( material.emissiveMap ),
|
|
1544
1574
|
texCoord: material.emissiveMap.channel
|
|
1545
1575
|
};
|
|
1546
1576
|
this.applyTextureTransform( emissiveMapDef, material.emissiveMap );
|
|
@@ -1554,7 +1584,7 @@ class GLTFWriter {
|
|
|
1554
1584
|
if ( material.normalMap ) {
|
|
1555
1585
|
|
|
1556
1586
|
const normalMapDef = {
|
|
1557
|
-
index: this.
|
|
1587
|
+
index: await this.processTextureAsync( material.normalMap ),
|
|
1558
1588
|
texCoord: material.normalMap.channel
|
|
1559
1589
|
};
|
|
1560
1590
|
|
|
@@ -1575,7 +1605,7 @@ class GLTFWriter {
|
|
|
1575
1605
|
if ( material.aoMap ) {
|
|
1576
1606
|
|
|
1577
1607
|
const occlusionMapDef = {
|
|
1578
|
-
index: this.
|
|
1608
|
+
index: await this.processTextureAsync( material.aoMap ),
|
|
1579
1609
|
texCoord: material.aoMap.channel
|
|
1580
1610
|
};
|
|
1581
1611
|
|
|
@@ -1612,9 +1642,9 @@ class GLTFWriter {
|
|
|
1612
1642
|
|
|
1613
1643
|
this.serializeUserData( material, materialDef );
|
|
1614
1644
|
|
|
1615
|
-
this.
|
|
1645
|
+
await this._invokeAllAsync( async function ( ext ) {
|
|
1616
1646
|
|
|
1617
|
-
ext.
|
|
1647
|
+
ext.writeMaterialAsync && await ext.writeMaterialAsync( material, materialDef );
|
|
1618
1648
|
|
|
1619
1649
|
} );
|
|
1620
1650
|
|
|
@@ -1629,7 +1659,7 @@ class GLTFWriter {
|
|
|
1629
1659
|
* @param {THREE.Mesh} mesh Mesh to process
|
|
1630
1660
|
* @return {Integer|null} Index of the processed mesh in the "meshes" array
|
|
1631
1661
|
*/
|
|
1632
|
-
|
|
1662
|
+
async processMeshAsync( mesh ) {
|
|
1633
1663
|
|
|
1634
1664
|
const cache = this.cache;
|
|
1635
1665
|
const json = this.json;
|
|
@@ -1733,7 +1763,9 @@ class GLTFWriter {
|
|
|
1733
1763
|
|
|
1734
1764
|
}
|
|
1735
1765
|
|
|
1736
|
-
//
|
|
1766
|
+
// Enforce glTF vertex attribute requirements:
|
|
1767
|
+
// - JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT
|
|
1768
|
+
// - Only custom attributes may be INT or UNSIGNED_INT
|
|
1737
1769
|
modifiedAttribute = null;
|
|
1738
1770
|
const array = attribute.array;
|
|
1739
1771
|
|
|
@@ -1744,6 +1776,11 @@ class GLTFWriter {
|
|
|
1744
1776
|
console.warn( 'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.' );
|
|
1745
1777
|
modifiedAttribute = new BufferAttribute( new Uint16Array( array ), attribute.itemSize, attribute.normalized );
|
|
1746
1778
|
|
|
1779
|
+
} else if ( ( array instanceof Uint32Array || array instanceof Int32Array ) && ! attributeName.startsWith( '_' ) ) {
|
|
1780
|
+
|
|
1781
|
+
console.warn( `GLTFExporter: Attribute "${ attributeName }" converted to type FLOAT.` );
|
|
1782
|
+
modifiedAttribute = GLTFExporter.Utils.toFloat32BufferAttribute( attribute );
|
|
1783
|
+
|
|
1747
1784
|
}
|
|
1748
1785
|
|
|
1749
1786
|
const accessor = this.processAccessor( modifiedAttribute || attribute, geometry );
|
|
@@ -1930,7 +1967,7 @@ class GLTFWriter {
|
|
|
1930
1967
|
|
|
1931
1968
|
}
|
|
1932
1969
|
|
|
1933
|
-
const material = this.
|
|
1970
|
+
const material = await this.processMaterialAsync( materials[ groups[ i ].materialIndex ] );
|
|
1934
1971
|
|
|
1935
1972
|
if ( material !== null ) primitive.material = material;
|
|
1936
1973
|
|
|
@@ -1948,7 +1985,7 @@ class GLTFWriter {
|
|
|
1948
1985
|
|
|
1949
1986
|
if ( ! json.meshes ) json.meshes = [];
|
|
1950
1987
|
|
|
1951
|
-
this.
|
|
1988
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
1952
1989
|
|
|
1953
1990
|
ext.writeMesh && ext.writeMesh( mesh, meshDef );
|
|
1954
1991
|
|
|
@@ -2225,10 +2262,10 @@ class GLTFWriter {
|
|
|
2225
2262
|
|
|
2226
2263
|
/**
|
|
2227
2264
|
* Process Object3D node
|
|
2228
|
-
* @param {THREE.Object3D} node Object3D to
|
|
2265
|
+
* @param {THREE.Object3D} node Object3D to processNodeAsync
|
|
2229
2266
|
* @return {Integer} Index of the node in the nodes list
|
|
2230
2267
|
*/
|
|
2231
|
-
|
|
2268
|
+
async processNodeAsync( object ) {
|
|
2232
2269
|
|
|
2233
2270
|
const json = this.json;
|
|
2234
2271
|
const options = this.options;
|
|
@@ -2285,7 +2322,7 @@ class GLTFWriter {
|
|
|
2285
2322
|
|
|
2286
2323
|
if ( object.isMesh || object.isLine || object.isPoints ) {
|
|
2287
2324
|
|
|
2288
|
-
const meshIndex = this.
|
|
2325
|
+
const meshIndex = await this.processMeshAsync( object );
|
|
2289
2326
|
|
|
2290
2327
|
if ( meshIndex !== null ) nodeDef.mesh = meshIndex;
|
|
2291
2328
|
|
|
@@ -2307,7 +2344,7 @@ class GLTFWriter {
|
|
|
2307
2344
|
|
|
2308
2345
|
if ( child.visible || options.onlyVisible === false ) {
|
|
2309
2346
|
|
|
2310
|
-
const nodeIndex = this.
|
|
2347
|
+
const nodeIndex = await this.processNodeAsync( child );
|
|
2311
2348
|
|
|
2312
2349
|
if ( nodeIndex !== null ) children.push( nodeIndex );
|
|
2313
2350
|
|
|
@@ -2319,7 +2356,7 @@ class GLTFWriter {
|
|
|
2319
2356
|
|
|
2320
2357
|
}
|
|
2321
2358
|
|
|
2322
|
-
this.
|
|
2359
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2323
2360
|
|
|
2324
2361
|
ext.writeNode && ext.writeNode( object, nodeDef );
|
|
2325
2362
|
|
|
@@ -2335,7 +2372,7 @@ class GLTFWriter {
|
|
|
2335
2372
|
* Process Scene
|
|
2336
2373
|
* @param {Scene} node Scene to process
|
|
2337
2374
|
*/
|
|
2338
|
-
|
|
2375
|
+
async processSceneAsync( scene ) {
|
|
2339
2376
|
|
|
2340
2377
|
const json = this.json;
|
|
2341
2378
|
const options = this.options;
|
|
@@ -2361,7 +2398,7 @@ class GLTFWriter {
|
|
|
2361
2398
|
|
|
2362
2399
|
if ( child.visible || options.onlyVisible === false ) {
|
|
2363
2400
|
|
|
2364
|
-
const nodeIndex = this.
|
|
2401
|
+
const nodeIndex = await this.processNodeAsync( child );
|
|
2365
2402
|
|
|
2366
2403
|
if ( nodeIndex !== null ) nodes.push( nodeIndex );
|
|
2367
2404
|
|
|
@@ -2379,7 +2416,7 @@ class GLTFWriter {
|
|
|
2379
2416
|
* Creates a Scene to hold a list of objects and parse it
|
|
2380
2417
|
* @param {Array} objects List of objects to process
|
|
2381
2418
|
*/
|
|
2382
|
-
|
|
2419
|
+
async processObjectsAsync( objects ) {
|
|
2383
2420
|
|
|
2384
2421
|
const scene = new Scene();
|
|
2385
2422
|
scene.name = 'AuxScene';
|
|
@@ -2392,20 +2429,20 @@ class GLTFWriter {
|
|
|
2392
2429
|
|
|
2393
2430
|
}
|
|
2394
2431
|
|
|
2395
|
-
this.
|
|
2432
|
+
await this.processSceneAsync( scene );
|
|
2396
2433
|
|
|
2397
2434
|
}
|
|
2398
2435
|
|
|
2399
2436
|
/**
|
|
2400
2437
|
* @param {THREE.Object3D|Array<THREE.Object3D>} input
|
|
2401
2438
|
*/
|
|
2402
|
-
|
|
2439
|
+
async processInputAsync( input ) {
|
|
2403
2440
|
|
|
2404
2441
|
const options = this.options;
|
|
2405
2442
|
|
|
2406
2443
|
input = input instanceof Array ? input : [ input ];
|
|
2407
2444
|
|
|
2408
|
-
this.
|
|
2445
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2409
2446
|
|
|
2410
2447
|
ext.beforeParse && ext.beforeParse( input );
|
|
2411
2448
|
|
|
@@ -2417,7 +2454,7 @@ class GLTFWriter {
|
|
|
2417
2454
|
|
|
2418
2455
|
if ( input[ i ] instanceof Scene ) {
|
|
2419
2456
|
|
|
2420
|
-
this.
|
|
2457
|
+
await this.processSceneAsync( input[ i ] );
|
|
2421
2458
|
|
|
2422
2459
|
} else {
|
|
2423
2460
|
|
|
@@ -2427,7 +2464,11 @@ class GLTFWriter {
|
|
|
2427
2464
|
|
|
2428
2465
|
}
|
|
2429
2466
|
|
|
2430
|
-
if ( objectsWithoutScene.length > 0 )
|
|
2467
|
+
if ( objectsWithoutScene.length > 0 ) {
|
|
2468
|
+
|
|
2469
|
+
await this.processObjectsAsync( objectsWithoutScene );
|
|
2470
|
+
|
|
2471
|
+
}
|
|
2431
2472
|
|
|
2432
2473
|
for ( let i = 0; i < this.skins.length; ++ i ) {
|
|
2433
2474
|
|
|
@@ -2441,7 +2482,7 @@ class GLTFWriter {
|
|
|
2441
2482
|
|
|
2442
2483
|
}
|
|
2443
2484
|
|
|
2444
|
-
this.
|
|
2485
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2445
2486
|
|
|
2446
2487
|
ext.afterParse && ext.afterParse( input );
|
|
2447
2488
|
|
|
@@ -2449,11 +2490,11 @@ class GLTFWriter {
|
|
|
2449
2490
|
|
|
2450
2491
|
}
|
|
2451
2492
|
|
|
2452
|
-
|
|
2493
|
+
async _invokeAllAsync( func ) {
|
|
2453
2494
|
|
|
2454
2495
|
for ( let i = 0, il = this.plugins.length; i < il; i ++ ) {
|
|
2455
2496
|
|
|
2456
|
-
func( this.plugins[ i ] );
|
|
2497
|
+
await func( this.plugins[ i ] );
|
|
2457
2498
|
|
|
2458
2499
|
}
|
|
2459
2500
|
|
|
@@ -2570,7 +2611,7 @@ class GLTFMaterialsUnlitExtension {
|
|
|
2570
2611
|
|
|
2571
2612
|
}
|
|
2572
2613
|
|
|
2573
|
-
|
|
2614
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2574
2615
|
|
|
2575
2616
|
if ( ! material.isMeshBasicMaterial ) return;
|
|
2576
2617
|
|
|
@@ -2603,7 +2644,7 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
2603
2644
|
|
|
2604
2645
|
}
|
|
2605
2646
|
|
|
2606
|
-
|
|
2647
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2607
2648
|
|
|
2608
2649
|
if ( ! material.isMeshPhysicalMaterial || material.clearcoat === 0 ) return;
|
|
2609
2650
|
|
|
@@ -2617,7 +2658,7 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
2617
2658
|
if ( material.clearcoatMap ) {
|
|
2618
2659
|
|
|
2619
2660
|
const clearcoatMapDef = {
|
|
2620
|
-
index: writer.
|
|
2661
|
+
index: await writer.processTextureAsync( material.clearcoatMap ),
|
|
2621
2662
|
texCoord: material.clearcoatMap.channel
|
|
2622
2663
|
};
|
|
2623
2664
|
writer.applyTextureTransform( clearcoatMapDef, material.clearcoatMap );
|
|
@@ -2630,7 +2671,7 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
2630
2671
|
if ( material.clearcoatRoughnessMap ) {
|
|
2631
2672
|
|
|
2632
2673
|
const clearcoatRoughnessMapDef = {
|
|
2633
|
-
index: writer.
|
|
2674
|
+
index: await writer.processTextureAsync( material.clearcoatRoughnessMap ),
|
|
2634
2675
|
texCoord: material.clearcoatRoughnessMap.channel
|
|
2635
2676
|
};
|
|
2636
2677
|
writer.applyTextureTransform( clearcoatRoughnessMapDef, material.clearcoatRoughnessMap );
|
|
@@ -2641,7 +2682,7 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
2641
2682
|
if ( material.clearcoatNormalMap ) {
|
|
2642
2683
|
|
|
2643
2684
|
const clearcoatNormalMapDef = {
|
|
2644
|
-
index: writer.
|
|
2685
|
+
index: await writer.processTextureAsync( material.clearcoatNormalMap ),
|
|
2645
2686
|
texCoord: material.clearcoatNormalMap.channel
|
|
2646
2687
|
};
|
|
2647
2688
|
|
|
@@ -2676,7 +2717,7 @@ class GLTFMaterialsDispersionExtension {
|
|
|
2676
2717
|
|
|
2677
2718
|
}
|
|
2678
2719
|
|
|
2679
|
-
|
|
2720
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2680
2721
|
|
|
2681
2722
|
if ( ! material.isMeshPhysicalMaterial || material.dispersion === 0 ) return;
|
|
2682
2723
|
|
|
@@ -2710,7 +2751,7 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
2710
2751
|
|
|
2711
2752
|
}
|
|
2712
2753
|
|
|
2713
|
-
|
|
2754
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2714
2755
|
|
|
2715
2756
|
if ( ! material.isMeshPhysicalMaterial || material.iridescence === 0 ) return;
|
|
2716
2757
|
|
|
@@ -2724,7 +2765,7 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
2724
2765
|
if ( material.iridescenceMap ) {
|
|
2725
2766
|
|
|
2726
2767
|
const iridescenceMapDef = {
|
|
2727
|
-
index: writer.
|
|
2768
|
+
index: await writer.processTextureAsync( material.iridescenceMap ),
|
|
2728
2769
|
texCoord: material.iridescenceMap.channel
|
|
2729
2770
|
};
|
|
2730
2771
|
writer.applyTextureTransform( iridescenceMapDef, material.iridescenceMap );
|
|
@@ -2739,7 +2780,7 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
2739
2780
|
if ( material.iridescenceThicknessMap ) {
|
|
2740
2781
|
|
|
2741
2782
|
const iridescenceThicknessMapDef = {
|
|
2742
|
-
index: writer.
|
|
2783
|
+
index: await writer.processTextureAsync( material.iridescenceThicknessMap ),
|
|
2743
2784
|
texCoord: material.iridescenceThicknessMap.channel
|
|
2744
2785
|
};
|
|
2745
2786
|
writer.applyTextureTransform( iridescenceThicknessMapDef, material.iridescenceThicknessMap );
|
|
@@ -2770,7 +2811,7 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
2770
2811
|
|
|
2771
2812
|
}
|
|
2772
2813
|
|
|
2773
|
-
|
|
2814
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2774
2815
|
|
|
2775
2816
|
if ( ! material.isMeshPhysicalMaterial || material.transmission === 0 ) return;
|
|
2776
2817
|
|
|
@@ -2784,7 +2825,7 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
2784
2825
|
if ( material.transmissionMap ) {
|
|
2785
2826
|
|
|
2786
2827
|
const transmissionMapDef = {
|
|
2787
|
-
index: writer.
|
|
2828
|
+
index: await writer.processTextureAsync( material.transmissionMap ),
|
|
2788
2829
|
texCoord: material.transmissionMap.channel
|
|
2789
2830
|
};
|
|
2790
2831
|
writer.applyTextureTransform( transmissionMapDef, material.transmissionMap );
|
|
@@ -2815,7 +2856,7 @@ class GLTFMaterialsVolumeExtension {
|
|
|
2815
2856
|
|
|
2816
2857
|
}
|
|
2817
2858
|
|
|
2818
|
-
|
|
2859
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2819
2860
|
|
|
2820
2861
|
if ( ! material.isMeshPhysicalMaterial || material.transmission === 0 ) return;
|
|
2821
2862
|
|
|
@@ -2829,7 +2870,7 @@ class GLTFMaterialsVolumeExtension {
|
|
|
2829
2870
|
if ( material.thicknessMap ) {
|
|
2830
2871
|
|
|
2831
2872
|
const thicknessMapDef = {
|
|
2832
|
-
index: writer.
|
|
2873
|
+
index: await writer.processTextureAsync( material.thicknessMap ),
|
|
2833
2874
|
texCoord: material.thicknessMap.channel
|
|
2834
2875
|
};
|
|
2835
2876
|
writer.applyTextureTransform( thicknessMapDef, material.thicknessMap );
|
|
@@ -2868,7 +2909,7 @@ class GLTFMaterialsIorExtension {
|
|
|
2868
2909
|
|
|
2869
2910
|
}
|
|
2870
2911
|
|
|
2871
|
-
|
|
2912
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2872
2913
|
|
|
2873
2914
|
if ( ! material.isMeshPhysicalMaterial || material.ior === 1.5 ) return;
|
|
2874
2915
|
|
|
@@ -2902,7 +2943,7 @@ class GLTFMaterialsSpecularExtension {
|
|
|
2902
2943
|
|
|
2903
2944
|
}
|
|
2904
2945
|
|
|
2905
|
-
|
|
2946
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2906
2947
|
|
|
2907
2948
|
if ( ! material.isMeshPhysicalMaterial || ( material.specularIntensity === 1.0 &&
|
|
2908
2949
|
material.specularColor.equals( DEFAULT_SPECULAR_COLOR ) &&
|
|
@@ -2916,7 +2957,7 @@ class GLTFMaterialsSpecularExtension {
|
|
|
2916
2957
|
if ( material.specularIntensityMap ) {
|
|
2917
2958
|
|
|
2918
2959
|
const specularIntensityMapDef = {
|
|
2919
|
-
index: writer.
|
|
2960
|
+
index: await writer.processTextureAsync( material.specularIntensityMap ),
|
|
2920
2961
|
texCoord: material.specularIntensityMap.channel
|
|
2921
2962
|
};
|
|
2922
2963
|
writer.applyTextureTransform( specularIntensityMapDef, material.specularIntensityMap );
|
|
@@ -2927,7 +2968,7 @@ class GLTFMaterialsSpecularExtension {
|
|
|
2927
2968
|
if ( material.specularColorMap ) {
|
|
2928
2969
|
|
|
2929
2970
|
const specularColorMapDef = {
|
|
2930
|
-
index: writer.
|
|
2971
|
+
index: await writer.processTextureAsync( material.specularColorMap ),
|
|
2931
2972
|
texCoord: material.specularColorMap.channel
|
|
2932
2973
|
};
|
|
2933
2974
|
writer.applyTextureTransform( specularColorMapDef, material.specularColorMap );
|
|
@@ -2961,7 +3002,7 @@ class GLTFMaterialsSheenExtension {
|
|
|
2961
3002
|
|
|
2962
3003
|
}
|
|
2963
3004
|
|
|
2964
|
-
|
|
3005
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2965
3006
|
|
|
2966
3007
|
if ( ! material.isMeshPhysicalMaterial || material.sheen == 0.0 ) return;
|
|
2967
3008
|
|
|
@@ -2973,7 +3014,7 @@ class GLTFMaterialsSheenExtension {
|
|
|
2973
3014
|
if ( material.sheenRoughnessMap ) {
|
|
2974
3015
|
|
|
2975
3016
|
const sheenRoughnessMapDef = {
|
|
2976
|
-
index: writer.
|
|
3017
|
+
index: await writer.processTextureAsync( material.sheenRoughnessMap ),
|
|
2977
3018
|
texCoord: material.sheenRoughnessMap.channel
|
|
2978
3019
|
};
|
|
2979
3020
|
writer.applyTextureTransform( sheenRoughnessMapDef, material.sheenRoughnessMap );
|
|
@@ -2984,7 +3025,7 @@ class GLTFMaterialsSheenExtension {
|
|
|
2984
3025
|
if ( material.sheenColorMap ) {
|
|
2985
3026
|
|
|
2986
3027
|
const sheenColorMapDef = {
|
|
2987
|
-
index: writer.
|
|
3028
|
+
index: await writer.processTextureAsync( material.sheenColorMap ),
|
|
2988
3029
|
texCoord: material.sheenColorMap.channel
|
|
2989
3030
|
};
|
|
2990
3031
|
writer.applyTextureTransform( sheenColorMapDef, material.sheenColorMap );
|
|
@@ -3018,7 +3059,7 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
3018
3059
|
|
|
3019
3060
|
}
|
|
3020
3061
|
|
|
3021
|
-
|
|
3062
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3022
3063
|
|
|
3023
3064
|
if ( ! material.isMeshPhysicalMaterial || material.anisotropy == 0.0 ) return;
|
|
3024
3065
|
|
|
@@ -3029,7 +3070,7 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
3029
3070
|
|
|
3030
3071
|
if ( material.anisotropyMap ) {
|
|
3031
3072
|
|
|
3032
|
-
const anisotropyMapDef = { index: writer.
|
|
3073
|
+
const anisotropyMapDef = { index: await writer.processTextureAsync( material.anisotropyMap ) };
|
|
3033
3074
|
writer.applyTextureTransform( anisotropyMapDef, material.anisotropyMap );
|
|
3034
3075
|
extensionDef.anisotropyTexture = anisotropyMapDef;
|
|
3035
3076
|
|
|
@@ -3061,7 +3102,7 @@ class GLTFMaterialsEmissiveStrengthExtension {
|
|
|
3061
3102
|
|
|
3062
3103
|
}
|
|
3063
3104
|
|
|
3064
|
-
|
|
3105
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3065
3106
|
|
|
3066
3107
|
if ( ! material.isMeshStandardMaterial || material.emissiveIntensity === 1.0 ) return;
|
|
3067
3108
|
|
|
@@ -3096,7 +3137,7 @@ class GLTFMaterialsBumpExtension {
|
|
|
3096
3137
|
|
|
3097
3138
|
}
|
|
3098
3139
|
|
|
3099
|
-
|
|
3140
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3100
3141
|
|
|
3101
3142
|
if ( ! material.isMeshStandardMaterial || (
|
|
3102
3143
|
material.bumpScale === 1 &&
|
|
@@ -3110,7 +3151,7 @@ class GLTFMaterialsBumpExtension {
|
|
|
3110
3151
|
if ( material.bumpMap ) {
|
|
3111
3152
|
|
|
3112
3153
|
const bumpMapDef = {
|
|
3113
|
-
index: writer.
|
|
3154
|
+
index: await writer.processTextureAsync( material.bumpMap ),
|
|
3114
3155
|
texCoord: material.bumpMap.channel
|
|
3115
3156
|
};
|
|
3116
3157
|
writer.applyTextureTransform( bumpMapDef, material.bumpMap );
|
|
@@ -3382,6 +3423,32 @@ GLTFExporter.Utils = {
|
|
|
3382
3423
|
|
|
3383
3424
|
return clip;
|
|
3384
3425
|
|
|
3426
|
+
},
|
|
3427
|
+
|
|
3428
|
+
toFloat32BufferAttribute: function ( srcAttribute ) {
|
|
3429
|
+
|
|
3430
|
+
const dstAttribute = new BufferAttribute( new Float32Array( srcAttribute.count * srcAttribute.itemSize ), srcAttribute.itemSize, false );
|
|
3431
|
+
|
|
3432
|
+
if ( ! srcAttribute.normalized && ! srcAttribute.isInterleavedBufferAttribute ) {
|
|
3433
|
+
|
|
3434
|
+
dstAttribute.array.set( srcAttribute.array );
|
|
3435
|
+
|
|
3436
|
+
return dstAttribute;
|
|
3437
|
+
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
for ( let i = 0, il = srcAttribute.count; i < il; i ++ ) {
|
|
3441
|
+
|
|
3442
|
+
for ( let j = 0; j < srcAttribute.itemSize; j ++ ) {
|
|
3443
|
+
|
|
3444
|
+
dstAttribute.setComponent( i, j, srcAttribute.getComponent( i, j ) );
|
|
3445
|
+
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
return dstAttribute;
|
|
3451
|
+
|
|
3385
3452
|
}
|
|
3386
3453
|
|
|
3387
3454
|
};
|