super-three 0.133.2 → 0.135.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.js +619 -538
- package/build/three.min.js +1 -1
- package/build/three.module.js +763 -616
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
- package/examples/fonts/open-sans/open-sans.css +9 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
- package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
- package/examples/js/controls/ArcballControls.js +68 -27
- package/examples/js/controls/DragControls.js +7 -0
- package/examples/js/controls/OrbitControls.js +5 -36
- package/examples/js/controls/TrackballControls.js +3 -2
- package/examples/js/csm/CSM.js +2 -2
- package/examples/js/csm/CSMFrustum.js +133 -0
- package/examples/js/exporters/GLTFExporter.js +147 -63
- package/examples/js/exporters/USDZExporter.js +45 -26
- package/examples/js/lines/LineMaterial.js +58 -20
- package/examples/js/lines/LineSegments2.js +29 -24
- package/examples/js/loaders/3DMLoader.js +24 -11
- package/examples/js/loaders/3MFLoader.js +2 -2
- package/examples/js/loaders/ColladaLoader.js +61 -3
- package/examples/js/loaders/FBXLoader.js +1 -1
- package/examples/js/loaders/GLTFLoader.js +94 -31
- package/examples/js/loaders/KTX2Loader.js +12 -0
- package/examples/js/loaders/LWOLoader.js +8 -6
- package/examples/js/loaders/LogLuvLoader.js +766 -0
- package/examples/js/loaders/PLYLoader.js +32 -7
- package/examples/js/loaders/RGBELoader.js +2 -1
- package/examples/js/loaders/SVGLoader.js +7 -3
- package/examples/js/loaders/TDSLoader.js +237 -271
- package/examples/js/loaders/lwo/LWO2Parser.js +1 -0
- package/examples/js/loaders/lwo/LWO3Parser.js +4 -2
- package/examples/js/objects/MarchingCubes.js +42 -128
- package/examples/js/renderers/CSS2DRenderer.js +4 -4
- package/examples/js/renderers/CSS3DRenderer.js +4 -4
- package/examples/js/utils/RoughnessMipmapper.js +1 -0
- package/examples/jsm/controls/ArcballControls.js +61 -29
- package/examples/jsm/controls/DragControls.js +7 -0
- package/examples/jsm/controls/OrbitControls.js +9 -51
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/csm/CSM.js +3 -3
- package/examples/jsm/csm/{Frustum.js → CSMFrustum.js} +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +160 -74
- package/examples/jsm/exporters/USDZExporter.js +47 -26
- package/examples/jsm/libs/flow.module.js +3218 -0
- package/examples/jsm/libs/lil-gui.module.min.js +8 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lines/LineMaterial.js +59 -23
- package/examples/jsm/lines/LineSegments2.js +22 -18
- package/examples/jsm/loaders/3DMLoader.js +18 -12
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +61 -3
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +99 -35
- package/examples/jsm/loaders/KTX2Loader.js +19 -0
- package/examples/jsm/loaders/LWOLoader.js +8 -6
- package/examples/jsm/loaders/LogLuvLoader.js +606 -0
- package/examples/jsm/loaders/PLYLoader.js +33 -7
- package/examples/jsm/loaders/SVGLoader.js +7 -4
- package/examples/jsm/loaders/TDSLoader.js +225 -285
- package/examples/jsm/loaders/lwo/LWO2Parser.js +1 -0
- package/examples/jsm/loaders/lwo/LWO3Parser.js +2 -2
- package/examples/jsm/node-editor/NodeEditor.js +455 -0
- package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
- package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
- package/examples/jsm/node-editor/accessors/UVEditor.js +26 -0
- package/examples/jsm/node-editor/display/BlendEditor.js +43 -0
- package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
- package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
- package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
- package/examples/jsm/node-editor/examples/rim.json +1 -0
- package/examples/jsm/node-editor/inputs/ColorEditor.js +91 -0
- package/examples/jsm/node-editor/inputs/FloatEditor.js +24 -0
- package/examples/jsm/node-editor/inputs/SliderEditor.js +68 -0
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +69 -0
- package/examples/jsm/node-editor/math/DotEditor.js +36 -0
- package/examples/jsm/node-editor/math/InvertEditor.js +38 -0
- package/examples/jsm/node-editor/math/LimiterEditor.js +48 -0
- package/examples/jsm/node-editor/math/NormalizeEditor.js +26 -0
- package/examples/jsm/node-editor/math/OperatorEditor.js +50 -0
- package/examples/jsm/node-editor/math/PowerEditor.js +34 -0
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +39 -0
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +26 -0
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +42 -0
- package/examples/jsm/node-editor/utils/TimerEditor.js +57 -0
- package/examples/jsm/nodes/materials/StandardNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/nodes/StandardNode.js +6 -6
- package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -49
- package/examples/jsm/objects/MarchingCubes.js +46 -152
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +1 -1
- package/examples/jsm/postprocessing/BloomPass.js +1 -1
- package/examples/jsm/postprocessing/BokehPass.js +1 -1
- package/examples/jsm/postprocessing/ClearPass.js +1 -1
- package/examples/jsm/postprocessing/CubeTexturePass.js +1 -1
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -1
- package/examples/jsm/postprocessing/EffectComposer.js +3 -3
- package/examples/jsm/postprocessing/FilmPass.js +1 -1
- package/examples/jsm/postprocessing/GlitchPass.js +1 -1
- package/examples/jsm/postprocessing/HalftonePass.js +1 -1
- package/examples/jsm/postprocessing/MaskPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SMAAPass.js +1 -1
- package/examples/jsm/postprocessing/SSAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +1 -1
- package/examples/jsm/postprocessing/SSRrPass.js +1 -1
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/ShaderPass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/TexturePass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +1 -1
- package/examples/jsm/renderers/CSS2DRenderer.js +5 -4
- package/examples/jsm/renderers/CSS3DRenderer.js +5 -4
- package/examples/jsm/renderers/nodes/Nodes.js +14 -13
- package/examples/jsm/renderers/nodes/ShaderNode.js +193 -41
- package/examples/jsm/renderers/nodes/accessors/MaterialNode.js +6 -6
- package/examples/jsm/renderers/nodes/accessors/ModelViewProjectionNode.js +5 -5
- package/examples/jsm/renderers/nodes/accessors/NormalNode.js +14 -3
- package/examples/jsm/renderers/nodes/accessors/PointUVNode.js +3 -3
- package/examples/jsm/renderers/nodes/accessors/PositionNode.js +15 -5
- package/examples/jsm/renderers/nodes/accessors/SkinningNode.js +107 -0
- package/examples/jsm/renderers/nodes/accessors/UVNode.js +7 -5
- package/examples/jsm/renderers/nodes/core/ArrayInputNode.js +3 -3
- package/examples/jsm/renderers/nodes/core/AttributeNode.js +6 -0
- package/examples/jsm/renderers/nodes/core/BypassNode.js +38 -0
- package/examples/jsm/renderers/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/renderers/nodes/core/ContextNode.js +4 -19
- package/examples/jsm/renderers/nodes/core/ExpressionNode.js +13 -2
- package/examples/jsm/renderers/nodes/core/FunctionNode.js +19 -132
- package/examples/jsm/renderers/nodes/core/InputNode.js +13 -3
- package/examples/jsm/renderers/nodes/core/Node.js +32 -10
- package/examples/jsm/renderers/nodes/core/NodeBuilder.js +146 -128
- package/examples/jsm/renderers/nodes/core/NodeFunction.js +22 -0
- package/examples/jsm/renderers/nodes/core/NodeFunctionInput.js +4 -4
- package/examples/jsm/renderers/nodes/core/NodeKeywords.js +18 -179
- package/examples/jsm/renderers/nodes/core/NodeParser.js +11 -0
- package/examples/jsm/renderers/nodes/core/NodeVar.js +2 -2
- package/examples/jsm/renderers/nodes/core/PropertyNode.js +14 -2
- package/examples/jsm/renderers/nodes/core/TempNode.js +10 -13
- package/examples/jsm/renderers/nodes/core/VarNode.js +12 -7
- package/examples/jsm/renderers/nodes/core/VaryNode.js +23 -8
- package/examples/jsm/renderers/nodes/core/constants.js +2 -0
- package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +47 -25
- package/examples/jsm/renderers/nodes/display/NormalMapNode.js +21 -22
- package/examples/jsm/renderers/nodes/functions/BSDFs.js +64 -101
- package/examples/jsm/renderers/nodes/inputs/BufferNode.js +25 -0
- package/examples/jsm/renderers/nodes/inputs/IntNode.js +17 -0
- package/examples/jsm/renderers/nodes/inputs/TextureNode.js +10 -2
- package/examples/jsm/renderers/nodes/lights/LightContextNode.js +20 -14
- package/examples/jsm/renderers/nodes/lights/LightNode.js +32 -36
- package/examples/jsm/renderers/nodes/math/CondNode.js +60 -0
- package/examples/jsm/renderers/nodes/math/MathNode.js +87 -36
- package/examples/jsm/renderers/nodes/math/OperatorNode.js +124 -31
- package/examples/jsm/renderers/nodes/parsers/GLSLNodeFunction.js +137 -0
- package/examples/jsm/renderers/nodes/parsers/GLSLNodeParser.js +14 -0
- package/examples/jsm/renderers/nodes/parsers/WGSLNodeFunction.js +89 -0
- package/examples/jsm/renderers/nodes/parsers/WGSLNodeParser.js +14 -0
- package/examples/jsm/renderers/nodes/procedural/CheckerNode.js +7 -9
- package/examples/jsm/renderers/nodes/utils/ArrayElementNode.js +31 -0
- package/examples/jsm/renderers/nodes/utils/ConvertNode.js +33 -0
- package/examples/jsm/renderers/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/renderers/nodes/utils/OscNode.js +58 -0
- package/examples/jsm/renderers/nodes/utils/SplitNode.js +18 -8
- package/examples/jsm/renderers/nodes/utils/SpriteSheetUVNode.js +7 -7
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +22 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +191 -94
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +2 -2
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +3 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +2 -4
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +2 -4
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +15 -23
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +3 -5
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +11 -27
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +62 -28
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +34 -27
- package/examples/jsm/renderers/webgpu/constants.js +2 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +430 -98
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/utils/RoughnessMipmapper.js +1 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -6
- package/package.json +10 -10
- package/src/Three.Legacy.js +6 -0
- package/src/Three.js +0 -1
- package/src/cameras/StereoCamera.js +8 -7
- package/src/constants.js +1 -2
- package/src/core/Layers.js +7 -1
- package/src/core/Object3D.js +2 -0
- package/src/extras/PMREMGenerator.js +11 -6
- package/src/loaders/FileLoader.js +89 -152
- package/src/loaders/ImageLoader.js +9 -4
- package/src/loaders/LoaderUtils.js +26 -0
- package/src/loaders/MaterialLoader.js +7 -4
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/Material.js +4 -4
- package/src/materials/MeshPhysicalMaterial.js +20 -14
- package/src/math/MathUtils.js +5 -16
- package/src/renderers/WebGLMultisampleRenderTarget.js +7 -1
- package/src/renderers/WebGLRenderer.js +83 -117
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -27
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +19 -6
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +13 -5
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib.js +6 -4
- package/src/renderers/shaders/UniformsLib.js +1 -2
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLMaterials.js +27 -15
- package/src/renderers/webgl/WebGLProgram.js +10 -6
- package/src/renderers/webgl/WebGLPrograms.js +17 -12
- package/src/renderers/webgl/WebGLShadowMap.js +14 -5
- package/src/renderers/webgl/WebGLState.js +31 -17
- package/src/renderers/webgl/WebGLTextures.js +188 -51
- package/src/renderers/webgl/WebGLUniforms.js +45 -1
- package/src/renderers/webxr/WebXRManager.js +71 -110
- package/src/textures/Texture.js +6 -0
- package/src/utils.js +37 -1
- package/examples/js/controls/DeviceOrientationControls.js +0 -147
- package/examples/js/libs/dat.gui.min.js +0 -14
- package/examples/jsm/controls/DeviceOrientationControls.js +0 -153
- package/examples/jsm/libs/dat.gui.module.js +0 -3575
- package/examples/jsm/libs/glslang.js +0 -78
- package/examples/jsm/libs/glslang.wasm +0 -0
- package/examples/jsm/renderers/nodes/consts/MathConsts.js +0 -7
- package/examples/jsm/renderers/nodes/core/ConstNode.js +0 -39
- package/examples/jsm/renderers/nodes/core/NodeSlot.js +0 -13
- package/examples/jsm/renderers/nodes/core/StructNode.js +0 -80
- package/examples/jsm/renderers/nodes/core/StructVarNode.js +0 -75
- package/examples/jsm/renderers/nodes/functions/EncodingFunctions.js +0 -99
- package/examples/jsm/renderers/nodes/functions/MathFunctions.js +0 -47
- package/examples/jsm/renderers/webgpu/nodes/ShaderLib.js +0 -152
- package/src/extras/objects/ImmediateRenderObject.js +0 -31
|
@@ -581,12 +581,6 @@ class OrbitControls extends EventDispatcher {
|
|
|
581
581
|
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
function handleMouseUp( /*event*/ ) {
|
|
585
|
-
|
|
586
|
-
// no-op
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
|
|
590
584
|
function handleMouseWheel( event ) {
|
|
591
585
|
|
|
592
586
|
if ( event.deltaY < 0 ) {
|
|
@@ -793,12 +787,6 @@ class OrbitControls extends EventDispatcher {
|
|
|
793
787
|
|
|
794
788
|
}
|
|
795
789
|
|
|
796
|
-
function handleTouchEnd( /*event*/ ) {
|
|
797
|
-
|
|
798
|
-
// no-op
|
|
799
|
-
|
|
800
|
-
}
|
|
801
|
-
|
|
802
790
|
//
|
|
803
791
|
// event handlers - FSM: listen for events and reset state
|
|
804
792
|
//
|
|
@@ -850,30 +838,20 @@ class OrbitControls extends EventDispatcher {
|
|
|
850
838
|
|
|
851
839
|
function onPointerUp( event ) {
|
|
852
840
|
|
|
853
|
-
|
|
841
|
+
removePointer( event );
|
|
854
842
|
|
|
855
|
-
|
|
843
|
+
if ( pointers.length === 0 ) {
|
|
856
844
|
|
|
857
|
-
|
|
845
|
+
scope.domElement.releasePointerCapture( event.pointerId );
|
|
858
846
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
onMouseUp( event );
|
|
847
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
848
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
862
849
|
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
removePointer( event );
|
|
866
|
-
|
|
867
|
-
//
|
|
868
|
-
|
|
869
|
-
if ( pointers.length === 0 ) {
|
|
850
|
+
}
|
|
870
851
|
|
|
871
|
-
|
|
852
|
+
scope.dispatchEvent( _endEvent );
|
|
872
853
|
|
|
873
|
-
|
|
874
|
-
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
875
|
-
|
|
876
|
-
}
|
|
854
|
+
state = STATE.NONE;
|
|
877
855
|
|
|
878
856
|
}
|
|
879
857
|
|
|
@@ -1014,19 +992,9 @@ class OrbitControls extends EventDispatcher {
|
|
|
1014
992
|
|
|
1015
993
|
}
|
|
1016
994
|
|
|
1017
|
-
function onMouseUp( event ) {
|
|
1018
|
-
|
|
1019
|
-
handleMouseUp( event );
|
|
1020
|
-
|
|
1021
|
-
scope.dispatchEvent( _endEvent );
|
|
1022
|
-
|
|
1023
|
-
state = STATE.NONE;
|
|
1024
|
-
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
995
|
function onMouseWheel( event ) {
|
|
1028
996
|
|
|
1029
|
-
if ( scope.enabled === false || scope.enableZoom === false ||
|
|
997
|
+
if ( scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE ) return;
|
|
1030
998
|
|
|
1031
999
|
event.preventDefault();
|
|
1032
1000
|
|
|
@@ -1184,16 +1152,6 @@ class OrbitControls extends EventDispatcher {
|
|
|
1184
1152
|
|
|
1185
1153
|
}
|
|
1186
1154
|
|
|
1187
|
-
function onTouchEnd( event ) {
|
|
1188
|
-
|
|
1189
|
-
handleTouchEnd( event );
|
|
1190
|
-
|
|
1191
|
-
scope.dispatchEvent( _endEvent );
|
|
1192
|
-
|
|
1193
|
-
state = STATE.NONE;
|
|
1194
|
-
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
1155
|
function onContextMenu( event ) {
|
|
1198
1156
|
|
|
1199
1157
|
if ( scope.enabled === false ) return;
|
package/examples/jsm/csm/CSM.js
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
Matrix4,
|
|
8
8
|
Box3
|
|
9
9
|
} from 'three';
|
|
10
|
-
import {
|
|
10
|
+
import { CSMFrustum } from './CSMFrustum.js';
|
|
11
11
|
import { CSMShader } from './CSMShader.js';
|
|
12
12
|
|
|
13
13
|
const _cameraToLightMatrix = new Matrix4();
|
|
14
|
-
const _lightSpaceFrustum = new
|
|
14
|
+
const _lightSpaceFrustum = new CSMFrustum();
|
|
15
15
|
const _center = new Vector3();
|
|
16
16
|
const _bbox = new Box3();
|
|
17
17
|
const _uniformArray = [];
|
|
@@ -37,7 +37,7 @@ export class CSM {
|
|
|
37
37
|
this.lightMargin = data.lightMargin || 200;
|
|
38
38
|
this.customSplitsCallback = data.customSplitsCallback;
|
|
39
39
|
this.fade = false;
|
|
40
|
-
this.mainFrustum = new
|
|
40
|
+
this.mainFrustum = new CSMFrustum();
|
|
41
41
|
this.frustums = [];
|
|
42
42
|
this.breaks = [];
|
|
43
43
|
|
|
@@ -2,7 +2,7 @@ import { Vector3, Matrix4 } from 'three';
|
|
|
2
2
|
|
|
3
3
|
const inverseProjectionMatrix = new Matrix4();
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class CSMFrustum {
|
|
6
6
|
|
|
7
7
|
constructor( data ) {
|
|
8
8
|
|
|
@@ -81,7 +81,7 @@ class Frustum {
|
|
|
81
81
|
|
|
82
82
|
while ( breaks.length > target.length ) {
|
|
83
83
|
|
|
84
|
-
target.push( new
|
|
84
|
+
target.push( new CSMFrustum() );
|
|
85
85
|
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -149,4 +149,4 @@ class Frustum {
|
|
|
149
149
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
export {
|
|
152
|
+
export { CSMFrustum };
|
|
@@ -58,6 +58,12 @@ class GLTFExporter {
|
|
|
58
58
|
|
|
59
59
|
} );
|
|
60
60
|
|
|
61
|
+
this.register( function ( writer ) {
|
|
62
|
+
|
|
63
|
+
return new GLTFMaterialsClearcoatExtension( writer );
|
|
64
|
+
|
|
65
|
+
} );
|
|
66
|
+
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
register( callback ) {
|
|
@@ -88,9 +94,18 @@ class GLTFExporter {
|
|
|
88
94
|
* Parse scenes and generate GLTF output
|
|
89
95
|
* @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
|
|
90
96
|
* @param {Function} onDone Callback on completed
|
|
97
|
+
* @param {Function} onError Callback on errors
|
|
91
98
|
* @param {Object} options options
|
|
92
99
|
*/
|
|
93
|
-
parse( input, onDone, options ) {
|
|
100
|
+
parse( input, onDone, onError, options ) {
|
|
101
|
+
|
|
102
|
+
if ( typeof onError === 'object' ) {
|
|
103
|
+
|
|
104
|
+
console.warn( 'THREE.GLTFExporter: parse() expects options as the fourth argument now.' );
|
|
105
|
+
|
|
106
|
+
options = onError;
|
|
107
|
+
|
|
108
|
+
}
|
|
94
109
|
|
|
95
110
|
const writer = new GLTFWriter();
|
|
96
111
|
const plugins = [];
|
|
@@ -102,7 +117,19 @@ class GLTFExporter {
|
|
|
102
117
|
}
|
|
103
118
|
|
|
104
119
|
writer.setPlugins( plugins );
|
|
105
|
-
writer.write( input, onDone, options );
|
|
120
|
+
writer.write( input, onDone, options ).catch( onError );
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
parseAsync( input, options ) {
|
|
125
|
+
|
|
126
|
+
const scope = this;
|
|
127
|
+
|
|
128
|
+
return new Promise( function ( resolve, reject ) {
|
|
129
|
+
|
|
130
|
+
scope.parse( input, resolve, reject, options );
|
|
131
|
+
|
|
132
|
+
} );
|
|
106
133
|
|
|
107
134
|
}
|
|
108
135
|
|
|
@@ -381,7 +408,7 @@ class GLTFWriter {
|
|
|
381
408
|
* @param {Function} onDone Callback on completed
|
|
382
409
|
* @param {Object} options options
|
|
383
410
|
*/
|
|
384
|
-
write( input, onDone, options ) {
|
|
411
|
+
async write( input, onDone, options ) {
|
|
385
412
|
|
|
386
413
|
this.options = Object.assign( {}, {
|
|
387
414
|
// default options
|
|
@@ -404,97 +431,95 @@ class GLTFWriter {
|
|
|
404
431
|
|
|
405
432
|
this.processInput( input );
|
|
406
433
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
Promise.all( this.pending ).then( function () {
|
|
434
|
+
await Promise.all( this.pending );
|
|
410
435
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
436
|
+
const writer = this;
|
|
437
|
+
const buffers = writer.buffers;
|
|
438
|
+
const json = writer.json;
|
|
439
|
+
options = writer.options;
|
|
440
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
415
441
|
|
|
416
|
-
|
|
417
|
-
|
|
442
|
+
// Merge buffers.
|
|
443
|
+
const blob = new Blob( buffers, { type: 'application/octet-stream' } );
|
|
418
444
|
|
|
419
|
-
|
|
420
|
-
|
|
445
|
+
// Declare extensions.
|
|
446
|
+
const extensionsUsedList = Object.keys( extensionsUsed );
|
|
421
447
|
|
|
422
|
-
|
|
448
|
+
if ( extensionsUsedList.length > 0 ) json.extensionsUsed = extensionsUsedList;
|
|
423
449
|
|
|
424
|
-
|
|
425
|
-
|
|
450
|
+
// Update bytelength of the single buffer.
|
|
451
|
+
if ( json.buffers && json.buffers.length > 0 ) json.buffers[ 0 ].byteLength = blob.size;
|
|
426
452
|
|
|
427
|
-
|
|
453
|
+
if ( options.binary === true ) {
|
|
428
454
|
|
|
429
|
-
|
|
455
|
+
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
|
|
430
456
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
457
|
+
const reader = new window.FileReader();
|
|
458
|
+
reader.readAsArrayBuffer( blob );
|
|
459
|
+
reader.onloadend = function () {
|
|
434
460
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
};
|
|
461
|
+
// Binary chunk.
|
|
462
|
+
const binaryChunk = getPaddedArrayBuffer( reader.result );
|
|
463
|
+
const binaryChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
|
|
464
|
+
binaryChunkPrefix.setUint32( 0, binaryChunk.byteLength, true );
|
|
465
|
+
binaryChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_BIN, true );
|
|
466
|
+
|
|
467
|
+
// JSON chunk.
|
|
468
|
+
const jsonChunk = getPaddedArrayBuffer( stringToArrayBuffer( JSON.stringify( json ) ), 0x20 );
|
|
469
|
+
const jsonChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
|
|
470
|
+
jsonChunkPrefix.setUint32( 0, jsonChunk.byteLength, true );
|
|
471
|
+
jsonChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_JSON, true );
|
|
472
|
+
|
|
473
|
+
// GLB header.
|
|
474
|
+
const header = new ArrayBuffer( GLB_HEADER_BYTES );
|
|
475
|
+
const headerView = new DataView( header );
|
|
476
|
+
headerView.setUint32( 0, GLB_HEADER_MAGIC, true );
|
|
477
|
+
headerView.setUint32( 4, GLB_VERSION, true );
|
|
478
|
+
const totalByteLength = GLB_HEADER_BYTES
|
|
479
|
+
+ jsonChunkPrefix.byteLength + jsonChunk.byteLength
|
|
480
|
+
+ binaryChunkPrefix.byteLength + binaryChunk.byteLength;
|
|
481
|
+
headerView.setUint32( 8, totalByteLength, true );
|
|
482
|
+
|
|
483
|
+
const glbBlob = new Blob( [
|
|
484
|
+
header,
|
|
485
|
+
jsonChunkPrefix,
|
|
486
|
+
jsonChunk,
|
|
487
|
+
binaryChunkPrefix,
|
|
488
|
+
binaryChunk
|
|
489
|
+
], { type: 'application/octet-stream' } );
|
|
490
|
+
|
|
491
|
+
const glbReader = new window.FileReader();
|
|
492
|
+
glbReader.readAsArrayBuffer( glbBlob );
|
|
493
|
+
glbReader.onloadend = function () {
|
|
494
|
+
|
|
495
|
+
onDone( glbReader.result );
|
|
472
496
|
|
|
473
497
|
};
|
|
474
498
|
|
|
475
|
-
}
|
|
499
|
+
};
|
|
476
500
|
|
|
477
|
-
|
|
501
|
+
} else {
|
|
478
502
|
|
|
479
|
-
|
|
480
|
-
reader.readAsDataURL( blob );
|
|
481
|
-
reader.onloadend = function () {
|
|
503
|
+
if ( json.buffers && json.buffers.length > 0 ) {
|
|
482
504
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
505
|
+
const reader = new window.FileReader();
|
|
506
|
+
reader.readAsDataURL( blob );
|
|
507
|
+
reader.onloadend = function () {
|
|
486
508
|
|
|
487
|
-
|
|
509
|
+
const base64data = reader.result;
|
|
510
|
+
json.buffers[ 0 ].uri = base64data;
|
|
511
|
+
onDone( json );
|
|
488
512
|
|
|
489
|
-
}
|
|
513
|
+
};
|
|
490
514
|
|
|
491
|
-
|
|
515
|
+
} else {
|
|
492
516
|
|
|
493
|
-
|
|
517
|
+
onDone( json );
|
|
494
518
|
|
|
495
519
|
}
|
|
496
520
|
|
|
497
|
-
}
|
|
521
|
+
}
|
|
522
|
+
|
|
498
523
|
|
|
499
524
|
}
|
|
500
525
|
|
|
@@ -2227,6 +2252,67 @@ class GLTFMaterialsPBRSpecularGlossiness {
|
|
|
2227
2252
|
|
|
2228
2253
|
}
|
|
2229
2254
|
|
|
2255
|
+
/**
|
|
2256
|
+
* Clearcoat Materials Extension
|
|
2257
|
+
*
|
|
2258
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
|
|
2259
|
+
*/
|
|
2260
|
+
class GLTFMaterialsClearcoatExtension {
|
|
2261
|
+
|
|
2262
|
+
constructor( writer ) {
|
|
2263
|
+
|
|
2264
|
+
this.writer = writer;
|
|
2265
|
+
this.name = 'KHR_materials_clearcoat';
|
|
2266
|
+
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
writeMaterial( material, materialDef ) {
|
|
2270
|
+
|
|
2271
|
+
if ( ! material.isMeshPhysicalMaterial ) return;
|
|
2272
|
+
|
|
2273
|
+
const writer = this.writer;
|
|
2274
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
2275
|
+
|
|
2276
|
+
const extensionDef = {};
|
|
2277
|
+
|
|
2278
|
+
extensionDef.clearcoatFactor = material.clearcoat;
|
|
2279
|
+
|
|
2280
|
+
if ( material.clearcoatMap ) {
|
|
2281
|
+
|
|
2282
|
+
const clearcoatMapDef = { index: writer.processTexture( material.clearcoatMap ) };
|
|
2283
|
+
writer.applyTextureTransform( clearcoatMapDef, material.clearcoatMap );
|
|
2284
|
+
extensionDef.clearcoatTexture = clearcoatMapDef;
|
|
2285
|
+
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
extensionDef.clearcoatRoughnessFactor = material.clearcoatRoughness;
|
|
2289
|
+
|
|
2290
|
+
if ( material.clearcoatRoughnessMap ) {
|
|
2291
|
+
|
|
2292
|
+
const clearcoatRoughnessMapDef = { index: writer.processTexture( material.clearcoatRoughnessMap ) };
|
|
2293
|
+
writer.applyTextureTransform( clearcoatRoughnessMapDef, material.clearcoatRoughnessMap );
|
|
2294
|
+
extensionDef.clearcoatRoughnessTexture = clearcoatRoughnessMapDef;
|
|
2295
|
+
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
if ( material.clearcoatNormalMap ) {
|
|
2299
|
+
|
|
2300
|
+
const clearcoatNormalMapDef = { index: writer.processTexture( material.clearcoatNormalMap ) };
|
|
2301
|
+
writer.applyTextureTransform( clearcoatNormalMapDef, material.clearcoatNormalMap );
|
|
2302
|
+
extensionDef.clearcoatNormalTexture = clearcoatNormalMapDef;
|
|
2303
|
+
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
2307
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
2308
|
+
|
|
2309
|
+
extensionsUsed[ this.name ] = true;
|
|
2310
|
+
|
|
2311
|
+
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2230
2316
|
/**
|
|
2231
2317
|
* Transmission Materials Extension
|
|
2232
2318
|
*
|
|
@@ -2285,7 +2371,7 @@ class GLTFMaterialsVolumeExtension {
|
|
|
2285
2371
|
|
|
2286
2372
|
writeMaterial( material, materialDef ) {
|
|
2287
2373
|
|
|
2288
|
-
if ( ! material.isMeshPhysicalMaterial || material.
|
|
2374
|
+
if ( ! material.isMeshPhysicalMaterial || material.transmission === 0 ) return;
|
|
2289
2375
|
|
|
2290
2376
|
const writer = this.writer;
|
|
2291
2377
|
const extensionsUsed = writer.extensionsUsed;
|
|
@@ -2303,7 +2389,7 @@ class GLTFMaterialsVolumeExtension {
|
|
|
2303
2389
|
}
|
|
2304
2390
|
|
|
2305
2391
|
extensionDef.attenuationDistance = material.attenuationDistance;
|
|
2306
|
-
extensionDef.attenuationColor = material.
|
|
2392
|
+
extensionDef.attenuationColor = material.attenuationColor.toArray();
|
|
2307
2393
|
|
|
2308
2394
|
materialDef.extensions = materialDef.extensions || {};
|
|
2309
2395
|
materialDef.extensions[ this.name ] = extensionDef;
|
|
@@ -17,27 +17,35 @@ class USDZExporter {
|
|
|
17
17
|
|
|
18
18
|
scene.traverseVisible( ( object ) => {
|
|
19
19
|
|
|
20
|
-
if ( object.isMesh
|
|
20
|
+
if ( object.isMesh ) {
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
const material = object.material;
|
|
22
|
+
if ( object.material.isMeshStandardMaterial ) {
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
const geometry = object.geometry;
|
|
25
|
+
const material = object.material;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const geometryFileName = 'geometries/Geometry_' + geometry.id + '.usd';
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
files[ geometryFileName ] = buildUSDFileAsString( meshObject );
|
|
29
|
+
if ( ! ( geometryFileName in files ) ) {
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
const meshObject = buildMeshObject( geometry );
|
|
32
|
+
files[ geometryFileName ] = buildUSDFileAsString( meshObject );
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
if ( ! ( material.uuid in materials ) ) {
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
materials[ material.uuid ] = material;
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
output += buildXform( object, geometry, material );
|
|
43
|
+
|
|
44
|
+
} else {
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
console.warn( 'THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)', object );
|
|
47
|
+
|
|
48
|
+
}
|
|
41
49
|
|
|
42
50
|
}
|
|
43
51
|
|
|
@@ -247,7 +255,7 @@ function buildMesh( geometry ) {
|
|
|
247
255
|
|
|
248
256
|
function buildMeshVertexCount( geometry ) {
|
|
249
257
|
|
|
250
|
-
const count = geometry.index !== null ? geometry.index.
|
|
258
|
+
const count = geometry.index !== null ? geometry.index.count : geometry.attributes.position.count;
|
|
251
259
|
|
|
252
260
|
return Array( count / 3 ).fill( 3 ).join( ', ' );
|
|
253
261
|
|
|
@@ -255,18 +263,26 @@ function buildMeshVertexCount( geometry ) {
|
|
|
255
263
|
|
|
256
264
|
function buildMeshVertexIndices( geometry ) {
|
|
257
265
|
|
|
258
|
-
|
|
266
|
+
const index = geometry.index;
|
|
267
|
+
const array = [];
|
|
259
268
|
|
|
260
|
-
|
|
269
|
+
if ( index !== null ) {
|
|
261
270
|
|
|
262
|
-
|
|
271
|
+
for ( let i = 0; i < index.count; i ++ ) {
|
|
263
272
|
|
|
264
|
-
|
|
265
|
-
const length = geometry.attributes.position.count;
|
|
273
|
+
array.push( index.getX( i ) );
|
|
266
274
|
|
|
267
|
-
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
} else {
|
|
278
|
+
|
|
279
|
+
const length = geometry.attributes.position.count;
|
|
280
|
+
|
|
281
|
+
for ( let i = 0; i < length; i ++ ) {
|
|
268
282
|
|
|
269
|
-
|
|
283
|
+
array.push( i );
|
|
284
|
+
|
|
285
|
+
}
|
|
270
286
|
|
|
271
287
|
}
|
|
272
288
|
|
|
@@ -284,11 +300,14 @@ function buildVector3Array( attribute, count ) {
|
|
|
284
300
|
}
|
|
285
301
|
|
|
286
302
|
const array = [];
|
|
287
|
-
const data = attribute.array;
|
|
288
303
|
|
|
289
|
-
for ( let i = 0; i <
|
|
304
|
+
for ( let i = 0; i < attribute.count; i ++ ) {
|
|
290
305
|
|
|
291
|
-
|
|
306
|
+
const x = attribute.getX( i );
|
|
307
|
+
const y = attribute.getY( i );
|
|
308
|
+
const z = attribute.getZ( i );
|
|
309
|
+
|
|
310
|
+
array.push( `(${ x.toPrecision( PRECISION ) }, ${ y.toPrecision( PRECISION ) }, ${ z.toPrecision( PRECISION ) })` );
|
|
292
311
|
|
|
293
312
|
}
|
|
294
313
|
|
|
@@ -306,11 +325,13 @@ function buildVector2Array( attribute, count ) {
|
|
|
306
325
|
}
|
|
307
326
|
|
|
308
327
|
const array = [];
|
|
309
|
-
const data = attribute.array;
|
|
310
328
|
|
|
311
|
-
for ( let i = 0; i <
|
|
329
|
+
for ( let i = 0; i < attribute.count; i ++ ) {
|
|
330
|
+
|
|
331
|
+
const x = attribute.getX( i );
|
|
332
|
+
const y = attribute.getY( i );
|
|
312
333
|
|
|
313
|
-
array.push( `(${
|
|
334
|
+
array.push( `(${ x.toPrecision( PRECISION ) }, ${ 1 - y.toPrecision( PRECISION ) })` );
|
|
314
335
|
|
|
315
336
|
}
|
|
316
337
|
|