super-three 0.177.0 → 0.179.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 +959 -231
- package/build/three.core.js +751 -170
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +210 -64
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +78 -29
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3269 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3093 -1545
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +61 -14
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- 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/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- 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/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +95 -16
- 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/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +197 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/hashBlur.js +3 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +77 -28
- package/src/Three.WebGPU.js +2 -0
- 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 +3 -3
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/Clock.js +2 -8
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/Object3D.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/core/Path.js +22 -22
- 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/loaders/FileLoader.js +27 -4
- package/src/loaders/ImageBitmapLoader.js +27 -4
- package/src/loaders/ImageLoader.js +55 -8
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +28 -5
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Quaternion.js +1 -1
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +2 -3
- package/src/nodes/TSL.js +5 -3
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +95 -29
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +7 -7
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/CacheNode.js +0 -14
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +15 -3
- package/src/nodes/core/NodeBuilder.js +228 -92
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +49 -29
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/core/VaryingNode.js +6 -4
- package/src/nodes/display/BlendModes.js +2 -2
- package/src/nodes/display/FrontFacingNode.js +34 -2
- package/src/nodes/display/NormalMapNode.js +19 -50
- package/src/nodes/display/PassNode.js +157 -9
- package/src/nodes/display/ScreenNode.js +0 -26
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +16 -16
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/EnvironmentNode.js +5 -5
- package/src/nodes/lighting/LightsNode.js +4 -4
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +2 -2
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/ConditionalNode.js +1 -20
- package/src/nodes/math/MathNode.js +90 -55
- package/src/nodes/math/OperatorNode.js +22 -39
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +114 -55
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/LoopNode.js +0 -17
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/RTTNode.js +22 -5
- package/src/nodes/utils/ReflectorNode.js +11 -4
- package/src/nodes/utils/SampleNode.js +81 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +26 -24
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderObject.js +68 -3
- package/src/renderers/common/Renderer.js +19 -16
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +31 -12
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +1 -1
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +12 -6
- package/src/renderers/webgl/WebGLPrograms.js +6 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLState.js +4 -4
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
- package/src/renderers/webgpu/WebGPUBackend.js +63 -16
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -6
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +11 -1
- package/src/textures/VideoTexture.js +30 -2
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -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,
|
package/src/extras/core/Path.js
CHANGED
|
@@ -190,11 +190,11 @@ class Path extends CurvePath {
|
|
|
190
190
|
* Adds an arc as an instance of {@link EllipseCurve} to the path, positioned relative
|
|
191
191
|
* to the current point.
|
|
192
192
|
*
|
|
193
|
-
* @param {number} aX - The x coordinate of the center of the arc offsetted from the previous curve.
|
|
194
|
-
* @param {number} aY - The y coordinate of the center of the arc offsetted from the previous curve.
|
|
195
|
-
* @param {number} aRadius - The radius of the arc.
|
|
196
|
-
* @param {number} aStartAngle - The start angle in radians.
|
|
197
|
-
* @param {number} aEndAngle - The end angle in radians.
|
|
193
|
+
* @param {number} [aX=0] - The x coordinate of the center of the arc offsetted from the previous curve.
|
|
194
|
+
* @param {number} [aY=0] - The y coordinate of the center of the arc offsetted from the previous curve.
|
|
195
|
+
* @param {number} [aRadius=1] - The radius of the arc.
|
|
196
|
+
* @param {number} [aStartAngle=0] - The start angle in radians.
|
|
197
|
+
* @param {number} [aEndAngle=Math.PI*2] - The end angle in radians.
|
|
198
198
|
* @param {boolean} [aClockwise=false] - Whether to sweep the arc clockwise or not.
|
|
199
199
|
* @return {Path} A reference to this path.
|
|
200
200
|
*/
|
|
@@ -213,11 +213,11 @@ class Path extends CurvePath {
|
|
|
213
213
|
/**
|
|
214
214
|
* Adds an absolutely positioned arc as an instance of {@link EllipseCurve} to the path.
|
|
215
215
|
*
|
|
216
|
-
* @param {number} aX - The x coordinate of the center of the arc.
|
|
217
|
-
* @param {number} aY - The y coordinate of the center of the arc.
|
|
218
|
-
* @param {number} aRadius - The radius of the arc.
|
|
219
|
-
* @param {number} aStartAngle - The start angle in radians.
|
|
220
|
-
* @param {number} aEndAngle - The end angle in radians.
|
|
216
|
+
* @param {number} [aX=0] - The x coordinate of the center of the arc.
|
|
217
|
+
* @param {number} [aY=0] - The y coordinate of the center of the arc.
|
|
218
|
+
* @param {number} [aRadius=1] - The radius of the arc.
|
|
219
|
+
* @param {number} [aStartAngle=0] - The start angle in radians.
|
|
220
|
+
* @param {number} [aEndAngle=Math.PI*2] - The end angle in radians.
|
|
221
221
|
* @param {boolean} [aClockwise=false] - Whether to sweep the arc clockwise or not.
|
|
222
222
|
* @return {Path} A reference to this path.
|
|
223
223
|
*/
|
|
@@ -233,12 +233,12 @@ class Path extends CurvePath {
|
|
|
233
233
|
* Adds an ellipse as an instance of {@link EllipseCurve} to the path, positioned relative
|
|
234
234
|
* to the current point
|
|
235
235
|
*
|
|
236
|
-
* @param {number} aX - The x coordinate of the center of the ellipse offsetted from the previous curve.
|
|
237
|
-
* @param {number} aY - The y coordinate of the center of the ellipse offsetted from the previous curve.
|
|
238
|
-
* @param {number} xRadius - The radius of the ellipse in the x axis.
|
|
239
|
-
* @param {number} yRadius - The radius of the ellipse in the y axis.
|
|
240
|
-
* @param {number} aStartAngle - The start angle in radians.
|
|
241
|
-
* @param {number} aEndAngle - The end angle in radians.
|
|
236
|
+
* @param {number} [aX=0] - The x coordinate of the center of the ellipse offsetted from the previous curve.
|
|
237
|
+
* @param {number} [aY=0] - The y coordinate of the center of the ellipse offsetted from the previous curve.
|
|
238
|
+
* @param {number} [xRadius=1] - The radius of the ellipse in the x axis.
|
|
239
|
+
* @param {number} [yRadius=1] - The radius of the ellipse in the y axis.
|
|
240
|
+
* @param {number} [aStartAngle=0] - The start angle in radians.
|
|
241
|
+
* @param {number} [aEndAngle=Math.PI*2] - The end angle in radians.
|
|
242
242
|
* @param {boolean} [aClockwise=false] - Whether to sweep the ellipse clockwise or not.
|
|
243
243
|
* @param {number} [aRotation=0] - The rotation angle of the ellipse in radians, counterclockwise from the positive X axis.
|
|
244
244
|
* @return {Path} A reference to this path.
|
|
@@ -257,12 +257,12 @@ class Path extends CurvePath {
|
|
|
257
257
|
/**
|
|
258
258
|
* Adds an absolutely positioned ellipse as an instance of {@link EllipseCurve} to the path.
|
|
259
259
|
*
|
|
260
|
-
* @param {number} aX - The x coordinate of the absolute center of the ellipse.
|
|
261
|
-
* @param {number} aY - The y coordinate of the absolute center of the ellipse.
|
|
262
|
-
* @param {number} xRadius - The radius of the ellipse in the x axis.
|
|
263
|
-
* @param {number} yRadius - The radius of the ellipse in the y axis.
|
|
264
|
-
* @param {number} aStartAngle - The start angle in radians.
|
|
265
|
-
* @param {number} aEndAngle - The end angle in radians.
|
|
260
|
+
* @param {number} [aX=0] - The x coordinate of the absolute center of the ellipse.
|
|
261
|
+
* @param {number} [aY=0] - The y coordinate of the absolute center of the ellipse.
|
|
262
|
+
* @param {number} [xRadius=1] - The radius of the ellipse in the x axis.
|
|
263
|
+
* @param {number} [yRadius=1] - The radius of the ellipse in the y axis.
|
|
264
|
+
* @param {number} [aStartAngle=0] - The start angle in radians.
|
|
265
|
+
* @param {number} [aEndAngle=Math.PI*2] - The end angle in radians.
|
|
266
266
|
* @param {boolean} [aClockwise=false] - Whether to sweep the ellipse clockwise or not.
|
|
267
267
|
* @param {number} [aRotation=0] - The rotation angle of the ellipse in radians, counterclockwise from the positive X axis.
|
|
268
268
|
* @return {Path} A reference to this path.
|
|
@@ -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
|
/**
|
|
@@ -74,7 +83,7 @@ class FileLoader extends Loader {
|
|
|
74
83
|
|
|
75
84
|
url = this.manager.resolveURL( url );
|
|
76
85
|
|
|
77
|
-
const cached = Cache.get( url );
|
|
86
|
+
const cached = Cache.get( `file:${url}` );
|
|
78
87
|
|
|
79
88
|
if ( cached !== undefined ) {
|
|
80
89
|
|
|
@@ -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 )
|
|
@@ -263,7 +272,7 @@ class FileLoader extends Loader {
|
|
|
263
272
|
|
|
264
273
|
// Add to cache only on HTTP success, so that we do not cache
|
|
265
274
|
// error response bodies as proper responses to requests.
|
|
266
|
-
Cache.add( url
|
|
275
|
+
Cache.add( `file:${url}`, data );
|
|
267
276
|
|
|
268
277
|
const callbacks = loading[ url ];
|
|
269
278
|
delete loading[ url ];
|
|
@@ -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
|
/**
|
|
@@ -102,7 +110,7 @@ class ImageBitmapLoader extends Loader {
|
|
|
102
110
|
|
|
103
111
|
const scope = this;
|
|
104
112
|
|
|
105
|
-
const cached = Cache.get( url );
|
|
113
|
+
const cached = Cache.get( `image-bitmap:${url}` );
|
|
106
114
|
|
|
107
115
|
if ( cached !== undefined ) {
|
|
108
116
|
|
|
@@ -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
|
|
|
@@ -165,7 +174,7 @@ class ImageBitmapLoader extends Loader {
|
|
|
165
174
|
|
|
166
175
|
} ).then( function ( imageBitmap ) {
|
|
167
176
|
|
|
168
|
-
Cache.add( url
|
|
177
|
+
Cache.add( `image-bitmap:${url}`, imageBitmap );
|
|
169
178
|
|
|
170
179
|
if ( onLoad ) onLoad( imageBitmap );
|
|
171
180
|
|
|
@@ -179,18 +188,32 @@ class ImageBitmapLoader extends Loader {
|
|
|
179
188
|
|
|
180
189
|
_errorMap.set( promise, e );
|
|
181
190
|
|
|
182
|
-
Cache.remove( url );
|
|
191
|
+
Cache.remove( `image-bitmap:${url}` );
|
|
183
192
|
|
|
184
193
|
scope.manager.itemError( url );
|
|
185
194
|
scope.manager.itemEnd( url );
|
|
186
195
|
|
|
187
196
|
} );
|
|
188
197
|
|
|
189
|
-
Cache.add( url
|
|
198
|
+
Cache.add( `image-bitmap:${url}`, promise );
|
|
190
199
|
scope.manager.itemStart( url );
|
|
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 };
|
|
@@ -2,6 +2,8 @@ import { Cache } from './Cache.js';
|
|
|
2
2
|
import { Loader } from './Loader.js';
|
|
3
3
|
import { createElementNS } from '../utils.js';
|
|
4
4
|
|
|
5
|
+
const _loading = new WeakMap();
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* A loader for loading images. The class loads images with the HTML `Image` API.
|
|
7
9
|
*
|
|
@@ -48,19 +50,36 @@ class ImageLoader extends Loader {
|
|
|
48
50
|
|
|
49
51
|
const scope = this;
|
|
50
52
|
|
|
51
|
-
const cached = Cache.get( url );
|
|
53
|
+
const cached = Cache.get( `image:${url}` );
|
|
52
54
|
|
|
53
55
|
if ( cached !== undefined ) {
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
if ( cached.complete === true ) {
|
|
58
|
+
|
|
59
|
+
scope.manager.itemStart( url );
|
|
60
|
+
|
|
61
|
+
setTimeout( function () {
|
|
62
|
+
|
|
63
|
+
if ( onLoad ) onLoad( cached );
|
|
64
|
+
|
|
65
|
+
scope.manager.itemEnd( url );
|
|
66
|
+
|
|
67
|
+
}, 0 );
|
|
56
68
|
|
|
57
|
-
|
|
69
|
+
} else {
|
|
58
70
|
|
|
59
|
-
|
|
71
|
+
let arr = _loading.get( cached );
|
|
60
72
|
|
|
61
|
-
|
|
73
|
+
if ( arr === undefined ) {
|
|
62
74
|
|
|
63
|
-
|
|
75
|
+
arr = [];
|
|
76
|
+
_loading.set( cached, arr );
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
arr.push( { onLoad, onError } );
|
|
81
|
+
|
|
82
|
+
}
|
|
64
83
|
|
|
65
84
|
return cached;
|
|
66
85
|
|
|
@@ -72,10 +91,21 @@ class ImageLoader extends Loader {
|
|
|
72
91
|
|
|
73
92
|
removeEventListeners();
|
|
74
93
|
|
|
75
|
-
Cache.add( url, this );
|
|
76
|
-
|
|
77
94
|
if ( onLoad ) onLoad( this );
|
|
78
95
|
|
|
96
|
+
//
|
|
97
|
+
|
|
98
|
+
const callbacks = _loading.get( this ) || [];
|
|
99
|
+
|
|
100
|
+
for ( let i = 0; i < callbacks.length; i ++ ) {
|
|
101
|
+
|
|
102
|
+
const callback = callbacks[ i ];
|
|
103
|
+
if ( callback.onLoad ) callback.onLoad( this );
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
_loading.delete( this );
|
|
108
|
+
|
|
79
109
|
scope.manager.itemEnd( url );
|
|
80
110
|
|
|
81
111
|
}
|
|
@@ -86,6 +116,22 @@ class ImageLoader extends Loader {
|
|
|
86
116
|
|
|
87
117
|
if ( onError ) onError( event );
|
|
88
118
|
|
|
119
|
+
Cache.remove( `image:${url}` );
|
|
120
|
+
|
|
121
|
+
//
|
|
122
|
+
|
|
123
|
+
const callbacks = _loading.get( this ) || [];
|
|
124
|
+
|
|
125
|
+
for ( let i = 0; i < callbacks.length; i ++ ) {
|
|
126
|
+
|
|
127
|
+
const callback = callbacks[ i ];
|
|
128
|
+
if ( callback.onError ) callback.onError( event );
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_loading.delete( this );
|
|
133
|
+
|
|
134
|
+
|
|
89
135
|
scope.manager.itemError( url );
|
|
90
136
|
scope.manager.itemEnd( url );
|
|
91
137
|
|
|
@@ -107,6 +153,7 @@ class ImageLoader extends Loader {
|
|
|
107
153
|
|
|
108
154
|
}
|
|
109
155
|
|
|
156
|
+
Cache.add( `image:${url}`, image );
|
|
110
157
|
scope.manager.itemStart( url );
|
|
111
158
|
|
|
112
159
|
image.src = url;
|
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
|
}
|
|
@@ -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
|