@plastic-software/three 0.178.0 → 0.180.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +950 -230
- package/build/three.core.js +754 -138
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +197 -96
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +99 -25
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +4586 -1499
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +4544 -1499
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +2 -3
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +7 -7
- package/examples/jsm/controls/DragControls.js +6 -56
- package/examples/jsm/controls/FirstPersonControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +0 -8
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/GLTFExporter.js +30 -22
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +9 -5
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +112 -32
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +2 -2
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +23 -20
- package/examples/jsm/transpiler/TSLEncoder.js +2 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
- package/examples/jsm/tsl/display/BloomNode.js +7 -6
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
- package/examples/jsm/tsl/display/GTAONode.js +8 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +51 -41
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +180 -65
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/boxBlur.js +64 -0
- package/examples/jsm/tsl/display/hashBlur.js +15 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +2 -0
- package/src/Three.TSL.js +98 -24
- package/src/animation/AnimationClip.js +17 -2
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +2 -2
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/lib/earcut.js +1 -1
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/Material.js +12 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/ColorManagement.js +7 -1
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +142 -16
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +2 -2
- package/src/nodes/accessors/InstanceNode.js +3 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +19 -4
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Texture3DNode.js +13 -0
- package/src/nodes/accessors/TextureNode.js +83 -19
- package/src/nodes/code/FunctionCallNode.js +19 -0
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/ContextNode.js +44 -1
- package/src/nodes/core/Node.js +30 -22
- package/src/nodes/core/NodeBuilder.js +71 -32
- package/src/nodes/core/NodeFrame.js +1 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/StackNode.js +71 -4
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +79 -14
- package/src/nodes/core/VarNode.js +83 -15
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/PassNode.js +148 -2
- package/src/nodes/display/ScreenNode.js +42 -13
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +94 -4
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +1 -1
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +19 -3
- package/src/nodes/math/MathNode.js +72 -60
- package/src/nodes/math/OperatorNode.js +26 -25
- package/src/nodes/tsl/TSLCore.js +477 -142
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/JoinNode.js +3 -1
- package/src/nodes/utils/MemberNode.js +58 -7
- package/src/nodes/utils/RTTNode.js +10 -1
- package/src/nodes/utils/ReflectorNode.js +51 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +6 -4
- package/src/objects/LOD.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +21 -31
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +19 -1
- package/src/renderers/common/Bindings.js +21 -18
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderObject.js +14 -2
- package/src/renderers/common/Renderer.js +55 -32
- package/src/renderers/common/SampledTexture.js +4 -72
- package/src/renderers/common/Sampler.js +91 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +52 -14
- package/src/renderers/common/TimestampQueryPool.js +3 -3
- package/src/renderers/common/XRManager.js +51 -17
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +21 -11
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -18
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +207 -146
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +112 -19
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +87 -44
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +169 -99
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +10 -19
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +120 -84
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +86 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +12 -2
- package/src/textures/VideoTexture.js +27 -2
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
* const timer = new Timer();
|
|
12
12
|
* timer.connect( document ); // use Page Visibility API
|
|
13
13
|
* ```
|
|
14
|
-
*
|
|
15
|
-
* @three_import import { Timer } from 'three/addons/misc/Timer.js';
|
|
16
14
|
*/
|
|
17
15
|
class Timer {
|
|
18
16
|
|
|
@@ -23,7 +21,7 @@ class Timer {
|
|
|
23
21
|
|
|
24
22
|
this._previousTime = 0;
|
|
25
23
|
this._currentTime = 0;
|
|
26
|
-
this._startTime = now();
|
|
24
|
+
this._startTime = performance.now();
|
|
27
25
|
|
|
28
26
|
this._delta = 0;
|
|
29
27
|
this._elapsed = 0;
|
|
@@ -129,7 +127,7 @@ class Timer {
|
|
|
129
127
|
*/
|
|
130
128
|
reset() {
|
|
131
129
|
|
|
132
|
-
this._currentTime = now() - this._startTime;
|
|
130
|
+
this._currentTime = performance.now() - this._startTime;
|
|
133
131
|
|
|
134
132
|
return this;
|
|
135
133
|
|
|
@@ -164,7 +162,7 @@ class Timer {
|
|
|
164
162
|
} else {
|
|
165
163
|
|
|
166
164
|
this._previousTime = this._currentTime;
|
|
167
|
-
this._currentTime = ( timestamp !== undefined ? timestamp : now() ) - this._startTime;
|
|
165
|
+
this._currentTime = ( timestamp !== undefined ? timestamp : performance.now() ) - this._startTime;
|
|
168
166
|
|
|
169
167
|
this._delta = ( this._currentTime - this._previousTime ) * this._timescale;
|
|
170
168
|
this._elapsed += this._delta; // _elapsed is the accumulation of all previous deltas
|
|
@@ -177,46 +175,10 @@ class Timer {
|
|
|
177
175
|
|
|
178
176
|
}
|
|
179
177
|
|
|
180
|
-
/**
|
|
181
|
-
* A special version of a timer with a fixed time delta value.
|
|
182
|
-
* Can be useful for testing and debugging purposes.
|
|
183
|
-
*
|
|
184
|
-
* @augments Timer
|
|
185
|
-
*/
|
|
186
|
-
class FixedTimer extends Timer {
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Constructs a new timer.
|
|
190
|
-
*
|
|
191
|
-
* @param {number} [fps=60] - The fixed FPS of this timer.
|
|
192
|
-
*/
|
|
193
|
-
constructor( fps = 60 ) {
|
|
194
|
-
|
|
195
|
-
super();
|
|
196
|
-
this._delta = ( 1 / fps ) * 1000;
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
update() {
|
|
201
|
-
|
|
202
|
-
this._elapsed += ( this._delta * this._timescale ); // _elapsed is the accumulation of all previous deltas
|
|
203
|
-
|
|
204
|
-
return this;
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function now() {
|
|
211
|
-
|
|
212
|
-
return performance.now();
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
178
|
function handleVisibilityChange() {
|
|
217
179
|
|
|
218
180
|
if ( this._document.hidden === false ) this.reset();
|
|
219
181
|
|
|
220
182
|
}
|
|
221
183
|
|
|
222
|
-
export { Timer
|
|
184
|
+
export { Timer };
|
|
@@ -347,6 +347,17 @@ class PMREMGenerator {
|
|
|
347
347
|
renderer.toneMapping = NoToneMapping;
|
|
348
348
|
renderer.autoClear = false;
|
|
349
349
|
|
|
350
|
+
// https://github.com/mrdoob/three.js/issues/31413#issuecomment-3095966812
|
|
351
|
+
const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
|
|
352
|
+
|
|
353
|
+
if ( reversedDepthBuffer ) {
|
|
354
|
+
|
|
355
|
+
renderer.setRenderTarget( cubeUVRenderTarget );
|
|
356
|
+
renderer.clearDepth();
|
|
357
|
+
renderer.setRenderTarget( null );
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
350
361
|
const backgroundMaterial = new MeshBasicMaterial( {
|
|
351
362
|
name: 'PMREM.Background',
|
|
352
363
|
side: BackSide,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlphaFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBFormat, RGBAFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, UnsignedByteType, ByteType, UnsignedShortType, ShortType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedIntType, IntType, FloatType, UnsignedInt5999Type } from '../constants.js';
|
|
1
|
+
import { AlphaFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBFormat, RGBAFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, UnsignedByteType, ByteType, UnsignedShortType, ShortType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedIntType, IntType, FloatType, UnsignedInt5999Type, UnsignedInt101111Type } from '../constants.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Scales the texture as large as possible within its surface without cropping
|
|
@@ -215,6 +215,7 @@ function getTextureTypeByteLength( type ) {
|
|
|
215
215
|
case FloatType:
|
|
216
216
|
return { byteLength: 4, components: 1 };
|
|
217
217
|
case UnsignedInt5999Type:
|
|
218
|
+
case UnsignedInt101111Type:
|
|
218
219
|
return { byteLength: 4, components: 3 };
|
|
219
220
|
|
|
220
221
|
}
|
package/src/extras/lib/earcut.js
CHANGED
|
@@ -487,7 +487,7 @@ function pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {
|
|
|
487
487
|
|
|
488
488
|
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
|
|
489
489
|
function isValidDiagonal(a, b) {
|
|
490
|
-
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && //
|
|
490
|
+
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // doesn't intersect other edges
|
|
491
491
|
(locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
|
|
492
492
|
(area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
493
493
|
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
|
|
@@ -5,7 +5,7 @@ import { Color } from '../math/Color.js';
|
|
|
5
5
|
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
|
6
6
|
import { BufferGeometry } from '../core/BufferGeometry.js';
|
|
7
7
|
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
|
8
|
-
import { WebGLCoordinateSystem } from '../constants.js';
|
|
8
|
+
import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../constants.js';
|
|
9
9
|
|
|
10
10
|
const _vector = /*@__PURE__*/ new Vector3();
|
|
11
11
|
const _camera = /*@__PURE__*/ new Camera();
|
|
@@ -159,6 +159,7 @@ class CameraHelper extends LineSegments {
|
|
|
159
159
|
* @param {Color} up - The up line color.
|
|
160
160
|
* @param {Color} target - The target line color.
|
|
161
161
|
* @param {Color} cross - The cross line color.
|
|
162
|
+
* @return {CameraHelper} A reference to this helper.
|
|
162
163
|
*/
|
|
163
164
|
setColors( frustum, cone, up, target, cross ) {
|
|
164
165
|
|
|
@@ -215,6 +216,8 @@ class CameraHelper extends LineSegments {
|
|
|
215
216
|
|
|
216
217
|
colorAttribute.needsUpdate = true;
|
|
217
218
|
|
|
219
|
+
return this;
|
|
220
|
+
|
|
218
221
|
}
|
|
219
222
|
|
|
220
223
|
/**
|
|
@@ -227,17 +230,44 @@ class CameraHelper extends LineSegments {
|
|
|
227
230
|
|
|
228
231
|
const w = 1, h = 1;
|
|
229
232
|
|
|
233
|
+
let nearZ, farZ;
|
|
234
|
+
|
|
230
235
|
// we need just camera projection matrix inverse
|
|
231
236
|
// world matrix must be identity
|
|
232
237
|
|
|
233
238
|
_camera.projectionMatrixInverse.copy( this.camera.projectionMatrixInverse );
|
|
234
239
|
|
|
235
240
|
// Adjust z values based on coordinate system
|
|
236
|
-
|
|
241
|
+
|
|
242
|
+
if ( this.camera.reversedDepth === true ) {
|
|
243
|
+
|
|
244
|
+
nearZ = 1;
|
|
245
|
+
farZ = 0;
|
|
246
|
+
|
|
247
|
+
} else {
|
|
248
|
+
|
|
249
|
+
if ( this.camera.coordinateSystem === WebGLCoordinateSystem ) {
|
|
250
|
+
|
|
251
|
+
nearZ = - 1;
|
|
252
|
+
farZ = 1;
|
|
253
|
+
|
|
254
|
+
} else if ( this.camera.coordinateSystem === WebGPUCoordinateSystem ) {
|
|
255
|
+
|
|
256
|
+
nearZ = 0;
|
|
257
|
+
farZ = 1;
|
|
258
|
+
|
|
259
|
+
} else {
|
|
260
|
+
|
|
261
|
+
throw new Error( 'THREE.CameraHelper.update(): Invalid coordinate system: ' + this.camera.coordinateSystem );
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
|
|
237
267
|
|
|
238
268
|
// center / target
|
|
239
269
|
setPoint( 'c', pointMap, geometry, _camera, 0, 0, nearZ );
|
|
240
|
-
setPoint( 't', pointMap, geometry, _camera, 0, 0,
|
|
270
|
+
setPoint( 't', pointMap, geometry, _camera, 0, 0, farZ );
|
|
241
271
|
|
|
242
272
|
// near
|
|
243
273
|
|
|
@@ -248,10 +278,10 @@ class CameraHelper extends LineSegments {
|
|
|
248
278
|
|
|
249
279
|
// far
|
|
250
280
|
|
|
251
|
-
setPoint( 'f1', pointMap, geometry, _camera, - w, - h,
|
|
252
|
-
setPoint( 'f2', pointMap, geometry, _camera, w, - h,
|
|
253
|
-
setPoint( 'f3', pointMap, geometry, _camera, - w, h,
|
|
254
|
-
setPoint( 'f4', pointMap, geometry, _camera, w, h,
|
|
281
|
+
setPoint( 'f1', pointMap, geometry, _camera, - w, - h, farZ );
|
|
282
|
+
setPoint( 'f2', pointMap, geometry, _camera, w, - h, farZ );
|
|
283
|
+
setPoint( 'f3', pointMap, geometry, _camera, - w, h, farZ );
|
|
284
|
+
setPoint( 'f4', pointMap, geometry, _camera, w, h, farZ );
|
|
255
285
|
|
|
256
286
|
// up
|
|
257
287
|
|
|
@@ -261,10 +291,10 @@ class CameraHelper extends LineSegments {
|
|
|
261
291
|
|
|
262
292
|
// cross
|
|
263
293
|
|
|
264
|
-
setPoint( 'cf1', pointMap, geometry, _camera, - w, 0,
|
|
265
|
-
setPoint( 'cf2', pointMap, geometry, _camera, w, 0,
|
|
266
|
-
setPoint( 'cf3', pointMap, geometry, _camera, 0, - h,
|
|
267
|
-
setPoint( 'cf4', pointMap, geometry, _camera, 0, h,
|
|
294
|
+
setPoint( 'cf1', pointMap, geometry, _camera, - w, 0, farZ );
|
|
295
|
+
setPoint( 'cf2', pointMap, geometry, _camera, w, 0, farZ );
|
|
296
|
+
setPoint( 'cf3', pointMap, geometry, _camera, 0, - h, farZ );
|
|
297
|
+
setPoint( 'cf4', pointMap, geometry, _camera, 0, h, farZ );
|
|
268
298
|
|
|
269
299
|
setPoint( 'cn1', pointMap, geometry, _camera, - w, 0, nearZ );
|
|
270
300
|
setPoint( 'cn2', pointMap, geometry, _camera, w, 0, nearZ );
|
|
@@ -23,7 +23,7 @@ const _matrixWorldInv = /*@__PURE__*/ new Matrix4();
|
|
|
23
23
|
class SkeletonHelper extends LineSegments {
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Constructs a new
|
|
26
|
+
* Constructs a new skeleton helper.
|
|
27
27
|
*
|
|
28
28
|
* @param {Object3D} object - Usually an instance of {@link SkinnedMesh}. However, any 3D object
|
|
29
29
|
* can be used if it represents a hierarchy of bones (see {@link Bone}).
|
|
@@ -37,9 +37,6 @@ class SkeletonHelper extends LineSegments {
|
|
|
37
37
|
const vertices = [];
|
|
38
38
|
const colors = [];
|
|
39
39
|
|
|
40
|
-
const color1 = new Color( 0, 0, 1 );
|
|
41
|
-
const color2 = new Color( 0, 1, 0 );
|
|
42
|
-
|
|
43
40
|
for ( let i = 0; i < bones.length; i ++ ) {
|
|
44
41
|
|
|
45
42
|
const bone = bones[ i ];
|
|
@@ -48,8 +45,8 @@ class SkeletonHelper extends LineSegments {
|
|
|
48
45
|
|
|
49
46
|
vertices.push( 0, 0, 0 );
|
|
50
47
|
vertices.push( 0, 0, 0 );
|
|
51
|
-
colors.push(
|
|
52
|
-
colors.push(
|
|
48
|
+
colors.push( 0, 0, 0 );
|
|
49
|
+
colors.push( 0, 0, 0 );
|
|
53
50
|
|
|
54
51
|
}
|
|
55
52
|
|
|
@@ -90,6 +87,13 @@ class SkeletonHelper extends LineSegments {
|
|
|
90
87
|
this.matrix = object.matrixWorld;
|
|
91
88
|
this.matrixAutoUpdate = false;
|
|
92
89
|
|
|
90
|
+
// colors
|
|
91
|
+
|
|
92
|
+
const color1 = new Color( 0x0000ff );
|
|
93
|
+
const color2 = new Color( 0x00ff00 );
|
|
94
|
+
|
|
95
|
+
this.setColors( color1, color2 );
|
|
96
|
+
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
updateMatrixWorld( force ) {
|
|
@@ -127,6 +131,31 @@ class SkeletonHelper extends LineSegments {
|
|
|
127
131
|
|
|
128
132
|
}
|
|
129
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Defines the colors of the helper.
|
|
136
|
+
*
|
|
137
|
+
* @param {Color} color1 - The first line color for each bone.
|
|
138
|
+
* @param {Color} color2 - The second line color for each bone.
|
|
139
|
+
* @return {SkeletonHelper} A reference to this helper.
|
|
140
|
+
*/
|
|
141
|
+
setColors( color1, color2 ) {
|
|
142
|
+
|
|
143
|
+
const geometry = this.geometry;
|
|
144
|
+
const colorAttribute = geometry.getAttribute( 'color' );
|
|
145
|
+
|
|
146
|
+
for ( let i = 0; i < colorAttribute.count; i += 2 ) {
|
|
147
|
+
|
|
148
|
+
colorAttribute.setXYZ( i, color1.r, color1.g, color1.b );
|
|
149
|
+
colorAttribute.setXYZ( i + 1, color2.r, color2.g, color2.b );
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
colorAttribute.needsUpdate = true;
|
|
154
|
+
|
|
155
|
+
return this;
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
130
159
|
/**
|
|
131
160
|
* Frees the GPU-related resources allocated by this instance. Call this
|
|
132
161
|
* method whenever this instance is no longer used in your app.
|
|
@@ -204,14 +204,27 @@ class LightShadow {
|
|
|
204
204
|
shadowCamera.updateMatrixWorld();
|
|
205
205
|
|
|
206
206
|
_projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
|
|
207
|
-
this._frustum.setFromProjectionMatrix( _projScreenMatrix );
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
207
|
+
this._frustum.setFromProjectionMatrix( _projScreenMatrix, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
|
|
208
|
+
|
|
209
|
+
if ( shadowCamera.reversedDepth ) {
|
|
210
|
+
|
|
211
|
+
shadowMatrix.set(
|
|
212
|
+
0.5, 0.0, 0.0, 0.5,
|
|
213
|
+
0.0, 0.5, 0.0, 0.5,
|
|
214
|
+
0.0, 0.0, 1.0, 0.0,
|
|
215
|
+
0.0, 0.0, 0.0, 1.0
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
} else {
|
|
219
|
+
|
|
220
|
+
shadowMatrix.set(
|
|
221
|
+
0.5, 0.0, 0.0, 0.5,
|
|
222
|
+
0.0, 0.5, 0.0, 0.5,
|
|
223
|
+
0.0, 0.0, 0.5, 0.5,
|
|
224
|
+
0.0, 0.0, 0.0, 1.0
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
}
|
|
215
228
|
|
|
216
229
|
shadowMatrix.multiply( _projScreenMatrix );
|
|
217
230
|
|
|
@@ -108,7 +108,7 @@ class PointLightShadow extends LightShadow {
|
|
|
108
108
|
shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );
|
|
109
109
|
|
|
110
110
|
_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
111
|
-
this._frustum.setFromProjectionMatrix( _projScreenMatrix );
|
|
111
|
+
this._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
|
|
112
112
|
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -41,7 +41,8 @@ class FileLoader extends Loader {
|
|
|
41
41
|
super( manager );
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* The expected mime type.
|
|
44
|
+
* The expected mime type. Valid values can be found
|
|
45
|
+
* [here]{@link hhttps://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#mimetype}
|
|
45
46
|
*
|
|
46
47
|
* @type {string}
|
|
47
48
|
*/
|
|
@@ -55,6 +56,14 @@ class FileLoader extends Loader {
|
|
|
55
56
|
*/
|
|
56
57
|
this.responseType = '';
|
|
57
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Used for aborting requests.
|
|
61
|
+
*
|
|
62
|
+
* @private
|
|
63
|
+
* @type {AbortController}
|
|
64
|
+
*/
|
|
65
|
+
this._abortController = new AbortController();
|
|
66
|
+
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
/**
|
|
@@ -121,7 +130,7 @@ class FileLoader extends Loader {
|
|
|
121
130
|
const req = new Request( url, {
|
|
122
131
|
headers: new Headers( this.requestHeader ),
|
|
123
132
|
credentials: this.withCredentials ? 'include' : 'same-origin',
|
|
124
|
-
|
|
133
|
+
signal: ( typeof AbortSignal.any === 'function' ) ? AbortSignal.any( [ this._abortController.signal, this.manager.abortController.signal ] ) : this._abortController.signal
|
|
125
134
|
} );
|
|
126
135
|
|
|
127
136
|
// record states ( avoid data race )
|
|
@@ -338,6 +347,20 @@ class FileLoader extends Loader {
|
|
|
338
347
|
|
|
339
348
|
}
|
|
340
349
|
|
|
350
|
+
/**
|
|
351
|
+
* Aborts ongoing fetch requests.
|
|
352
|
+
*
|
|
353
|
+
* @return {FileLoader} A reference to this instance.
|
|
354
|
+
*/
|
|
355
|
+
abort() {
|
|
356
|
+
|
|
357
|
+
this._abortController.abort();
|
|
358
|
+
this._abortController = new AbortController();
|
|
359
|
+
|
|
360
|
+
return this;
|
|
361
|
+
|
|
362
|
+
}
|
|
363
|
+
|
|
341
364
|
}
|
|
342
365
|
|
|
343
366
|
|
|
@@ -66,6 +66,14 @@ class ImageBitmapLoader extends Loader {
|
|
|
66
66
|
*/
|
|
67
67
|
this.options = { premultiplyAlpha: 'none' };
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Used for aborting requests.
|
|
71
|
+
*
|
|
72
|
+
* @private
|
|
73
|
+
* @type {AbortController}
|
|
74
|
+
*/
|
|
75
|
+
this._abortController = new AbortController();
|
|
76
|
+
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
/**
|
|
@@ -154,6 +162,7 @@ class ImageBitmapLoader extends Loader {
|
|
|
154
162
|
const fetchOptions = {};
|
|
155
163
|
fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include';
|
|
156
164
|
fetchOptions.headers = this.requestHeader;
|
|
165
|
+
fetchOptions.signal = ( typeof AbortSignal.any === 'function' ) ? AbortSignal.any( [ this._abortController.signal, this.manager.abortController.signal ] ) : this._abortController.signal;
|
|
157
166
|
|
|
158
167
|
const promise = fetch( url, fetchOptions ).then( function ( res ) {
|
|
159
168
|
|
|
@@ -191,6 +200,20 @@ class ImageBitmapLoader extends Loader {
|
|
|
191
200
|
|
|
192
201
|
}
|
|
193
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Aborts ongoing fetch requests.
|
|
205
|
+
*
|
|
206
|
+
* @return {ImageBitmapLoader} A reference to this instance.
|
|
207
|
+
*/
|
|
208
|
+
abort() {
|
|
209
|
+
|
|
210
|
+
this._abortController.abort();
|
|
211
|
+
this._abortController = new AbortController();
|
|
212
|
+
|
|
213
|
+
return this;
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
|
|
194
217
|
}
|
|
195
218
|
|
|
196
219
|
export { ImageBitmapLoader };
|
package/src/loaders/Loader.js
CHANGED
|
@@ -67,6 +67,7 @@ class Loader {
|
|
|
67
67
|
* This method needs to be implemented by all concrete loaders. It holds the
|
|
68
68
|
* logic for loading assets from the backend.
|
|
69
69
|
*
|
|
70
|
+
* @abstract
|
|
70
71
|
* @param {string} url - The path/URL of the file to be loaded.
|
|
71
72
|
* @param {Function} onLoad - Executed when the loading process has been finished.
|
|
72
73
|
* @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
|
|
@@ -97,6 +98,7 @@ class Loader {
|
|
|
97
98
|
* This method needs to be implemented by all concrete loaders. It holds the
|
|
98
99
|
* logic for parsing the asset into three.js entities.
|
|
99
100
|
*
|
|
101
|
+
* @abstract
|
|
100
102
|
* @param {any} data - The data to parse.
|
|
101
103
|
*/
|
|
102
104
|
parse( /* data */ ) {}
|
|
@@ -171,6 +173,18 @@ class Loader {
|
|
|
171
173
|
|
|
172
174
|
}
|
|
173
175
|
|
|
176
|
+
/**
|
|
177
|
+
* This method can be implemented in loaders for aborting ongoing requests.
|
|
178
|
+
*
|
|
179
|
+
* @abstract
|
|
180
|
+
* @return {Loader} A reference to this instance.
|
|
181
|
+
*/
|
|
182
|
+
abort() {
|
|
183
|
+
|
|
184
|
+
return this;
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
174
188
|
}
|
|
175
189
|
|
|
176
190
|
/**
|
|
@@ -69,6 +69,13 @@ class LoadingManager {
|
|
|
69
69
|
*/
|
|
70
70
|
this.onError = onError;
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Used for aborting ongoing requests in loaders using this manager.
|
|
74
|
+
*
|
|
75
|
+
* @type {AbortController}
|
|
76
|
+
*/
|
|
77
|
+
this.abortController = new AbortController();
|
|
78
|
+
|
|
72
79
|
/**
|
|
73
80
|
* This should be called by any loader using the manager when the loader
|
|
74
81
|
* starts loading an item.
|
|
@@ -269,6 +276,22 @@ class LoadingManager {
|
|
|
269
276
|
|
|
270
277
|
};
|
|
271
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Can be used to abort ongoing loading requests in loaders using this manager.
|
|
281
|
+
* The abort only works if the loaders implement {@link Loader#abort} and `AbortSignal.any()`
|
|
282
|
+
* is supported in the browser.
|
|
283
|
+
*
|
|
284
|
+
* @return {LoadingManager} A reference to this loading manager.
|
|
285
|
+
*/
|
|
286
|
+
this.abort = function () {
|
|
287
|
+
|
|
288
|
+
this.abortController.abort();
|
|
289
|
+
this.abortController = new AbortController();
|
|
290
|
+
|
|
291
|
+
return this;
|
|
292
|
+
|
|
293
|
+
};
|
|
294
|
+
|
|
272
295
|
}
|
|
273
296
|
|
|
274
297
|
}
|
|
@@ -664,6 +664,18 @@ class Material extends EventDispatcher {
|
|
|
664
664
|
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
+
if ( this.sheenColorMap && this.sheenColorMap.isTexture ) {
|
|
668
|
+
|
|
669
|
+
data.sheenColorMap = this.sheenColorMap.toJSON( meta ).uuid;
|
|
670
|
+
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if ( this.sheenRoughnessMap && this.sheenRoughnessMap.isTexture ) {
|
|
674
|
+
|
|
675
|
+
data.sheenRoughnessMap = this.sheenRoughnessMap.toJSON( meta ).uuid;
|
|
676
|
+
|
|
677
|
+
}
|
|
678
|
+
|
|
667
679
|
if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
|
|
668
680
|
|
|
669
681
|
if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
|
|
@@ -42,7 +42,7 @@ class MeshBasicMaterial extends Material {
|
|
|
42
42
|
* @type {Color}
|
|
43
43
|
* @default (1,1,1)
|
|
44
44
|
*/
|
|
45
|
-
this.color = new Color( 0xffffff ); //
|
|
45
|
+
this.color = new Color( 0xffffff ); // diffuse
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* The color map. May optionally include an alpha channel, typically combined
|
|
@@ -7,7 +7,7 @@ import { Material } from './Material.js';
|
|
|
7
7
|
* Can also be used to customize the shadow casting of an object by assigning
|
|
8
8
|
* an instance of `MeshDistanceMaterial` to {@link Object3D#customDistanceMaterial}.
|
|
9
9
|
* The following examples demonstrates this approach in order to ensure
|
|
10
|
-
* transparent parts of objects do
|
|
10
|
+
* transparent parts of objects do not cast shadows.
|
|
11
11
|
*
|
|
12
12
|
* @augments Material
|
|
13
13
|
*/
|