@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
|
@@ -9,6 +9,7 @@ import { WebGLAnimation } from '../webgl/WebGLAnimation.js';
|
|
|
9
9
|
import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
|
|
10
10
|
import { WebXRController } from './WebXRController.js';
|
|
11
11
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
12
|
+
import { ExternalTexture } from '../../textures/ExternalTexture.js';
|
|
12
13
|
import { DepthFormat, DepthStencilFormat, RGBAFormat, UnsignedByteType, UnsignedIntType, UnsignedInt248Type } from '../../constants.js';
|
|
13
14
|
import { WebXRDepthSensing } from './WebXRDepthSensing.js';
|
|
14
15
|
|
|
@@ -51,7 +52,10 @@ class WebXRManager extends EventDispatcher {
|
|
|
51
52
|
let glBaseLayer = null;
|
|
52
53
|
let xrFrame = null;
|
|
53
54
|
|
|
55
|
+
const supportsGlBinding = typeof XRWebGLBinding !== 'undefined';
|
|
56
|
+
|
|
54
57
|
const depthSensing = new WebXRDepthSensing();
|
|
58
|
+
const cameraAccessTextures = {};
|
|
55
59
|
const attributes = gl.getContextAttributes();
|
|
56
60
|
|
|
57
61
|
let initialRenderTarget = null;
|
|
@@ -232,6 +236,11 @@ class WebXRManager extends EventDispatcher {
|
|
|
232
236
|
_currentDepthFar = null;
|
|
233
237
|
|
|
234
238
|
depthSensing.reset();
|
|
239
|
+
for ( const key in cameraAccessTextures ) {
|
|
240
|
+
|
|
241
|
+
delete cameraAccessTextures[ key ];
|
|
242
|
+
|
|
243
|
+
}
|
|
235
244
|
|
|
236
245
|
// restore framebuffer/rendering state
|
|
237
246
|
|
|
@@ -322,6 +331,9 @@ class WebXRManager extends EventDispatcher {
|
|
|
322
331
|
/**
|
|
323
332
|
* Returns the current base layer.
|
|
324
333
|
*
|
|
334
|
+
* This is an `XRProjectionLayer` when the targeted XR device supports the
|
|
335
|
+
* WebXR Layers API, or an `XRWebGLLayer` otherwise.
|
|
336
|
+
*
|
|
325
337
|
* @return {?(XRWebGLLayer|XRProjectionLayer)} The XR base layer.
|
|
326
338
|
*/
|
|
327
339
|
this.getBaseLayer = function () {
|
|
@@ -333,10 +345,19 @@ class WebXRManager extends EventDispatcher {
|
|
|
333
345
|
/**
|
|
334
346
|
* Returns the current XR binding.
|
|
335
347
|
*
|
|
336
|
-
*
|
|
348
|
+
* Creates a new binding if needed and the browser is
|
|
349
|
+
* capable of doing so.
|
|
350
|
+
*
|
|
351
|
+
* @return {?XRWebGLBinding} The XR binding. Returns `null` if one cannot be created.
|
|
337
352
|
*/
|
|
338
353
|
this.getBinding = function () {
|
|
339
354
|
|
|
355
|
+
if ( glBinding === null && supportsGlBinding ) {
|
|
356
|
+
|
|
357
|
+
glBinding = new XRWebGLBinding( session, gl );
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
340
361
|
return glBinding;
|
|
341
362
|
|
|
342
363
|
};
|
|
@@ -398,11 +419,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
398
419
|
currentPixelRatio = renderer.getPixelRatio();
|
|
399
420
|
renderer.getSize( currentSize );
|
|
400
421
|
|
|
422
|
+
|
|
401
423
|
// Check that the browser implements the necessary APIs to use an
|
|
402
424
|
// XRProjectionLayer rather than an XRWebGLLayer
|
|
403
|
-
const
|
|
425
|
+
const supportsLayers = supportsGlBinding && 'createProjectionLayer' in XRWebGLBinding.prototype;
|
|
404
426
|
|
|
405
|
-
if ( !
|
|
427
|
+
if ( ! supportsLayers ) {
|
|
406
428
|
|
|
407
429
|
const layerInit = {
|
|
408
430
|
antialias: attributes.antialias,
|
|
@@ -453,7 +475,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
453
475
|
scaleFactor: framebufferScaleFactor
|
|
454
476
|
};
|
|
455
477
|
|
|
456
|
-
glBinding =
|
|
478
|
+
glBinding = this.getBinding();
|
|
457
479
|
|
|
458
480
|
glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
|
|
459
481
|
|
|
@@ -514,6 +536,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
514
536
|
/**
|
|
515
537
|
* Returns the current depth texture computed via depth sensing.
|
|
516
538
|
*
|
|
539
|
+
* See {@link WebXRDepthSensing#getDepthTexture}.
|
|
540
|
+
*
|
|
517
541
|
* @return {?Texture} The depth texture.
|
|
518
542
|
*/
|
|
519
543
|
this.getDepthTexture = function () {
|
|
@@ -684,7 +708,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
684
708
|
|
|
685
709
|
/**
|
|
686
710
|
* Updates the state of the XR camera. Use this method on app level if you
|
|
687
|
-
* set cameraAutoUpdate` to `false`. The method requires the non-XR
|
|
711
|
+
* set `cameraAutoUpdate` to `false`. The method requires the non-XR
|
|
688
712
|
* camera of the scene as a parameter. The passed in camera's transformation
|
|
689
713
|
* is automatically adjusted to the position of the XR camera when calling
|
|
690
714
|
* this method.
|
|
@@ -722,9 +746,10 @@ class WebXRManager extends EventDispatcher {
|
|
|
722
746
|
|
|
723
747
|
}
|
|
724
748
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
749
|
+
// inherit camera layers and enable eye layers (1 = left, 2 = right)
|
|
750
|
+
cameraXR.layers.mask = camera.layers.mask | 0b110;
|
|
751
|
+
cameraL.layers.mask = cameraXR.layers.mask & 0b011;
|
|
752
|
+
cameraR.layers.mask = cameraXR.layers.mask & 0b101;
|
|
728
753
|
|
|
729
754
|
const parent = camera.parent;
|
|
730
755
|
const cameras = cameraXR.cameras;
|
|
@@ -805,7 +830,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
805
830
|
/**
|
|
806
831
|
* Returns the amount of foveation used by the XR compositor for the projection layer.
|
|
807
832
|
*
|
|
808
|
-
* @return {number} The amount of foveation.
|
|
833
|
+
* @return {number|undefined} The amount of foveation.
|
|
809
834
|
*/
|
|
810
835
|
this.getFoveation = function () {
|
|
811
836
|
|
|
@@ -860,6 +885,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
860
885
|
/**
|
|
861
886
|
* Returns the depth sensing mesh.
|
|
862
887
|
*
|
|
888
|
+
* See {@link WebXRDepthSensing#getMesh}.
|
|
889
|
+
*
|
|
863
890
|
* @return {Mesh} The depth sensing mesh.
|
|
864
891
|
*/
|
|
865
892
|
this.getDepthSensingMesh = function () {
|
|
@@ -868,6 +895,19 @@ class WebXRManager extends EventDispatcher {
|
|
|
868
895
|
|
|
869
896
|
};
|
|
870
897
|
|
|
898
|
+
/**
|
|
899
|
+
* Retrieves an opaque texture from the view-aligned {@link XRCamera}.
|
|
900
|
+
* Only available during the current animation loop.
|
|
901
|
+
*
|
|
902
|
+
* @param {XRCamera} xrCamera - The camera to query.
|
|
903
|
+
* @return {?Texture} An opaque texture representing the current raw camera frame.
|
|
904
|
+
*/
|
|
905
|
+
this.getCameraTexture = function ( xrCamera ) {
|
|
906
|
+
|
|
907
|
+
return cameraAccessTextures[ xrCamera ];
|
|
908
|
+
|
|
909
|
+
};
|
|
910
|
+
|
|
871
911
|
// Animation Loop
|
|
872
912
|
|
|
873
913
|
let onAnimationFrameCallback = null;
|
|
@@ -967,13 +1007,48 @@ class WebXRManager extends EventDispatcher {
|
|
|
967
1007
|
enabledFeatures.includes( 'depth-sensing' ) &&
|
|
968
1008
|
session.depthUsage == 'gpu-optimized';
|
|
969
1009
|
|
|
970
|
-
if ( gpuDepthSensingEnabled &&
|
|
1010
|
+
if ( gpuDepthSensingEnabled && supportsGlBinding ) {
|
|
1011
|
+
|
|
1012
|
+
glBinding = scope.getBinding();
|
|
971
1013
|
|
|
972
1014
|
const depthData = glBinding.getDepthInformation( views[ 0 ] );
|
|
973
1015
|
|
|
974
1016
|
if ( depthData && depthData.isValid && depthData.texture ) {
|
|
975
1017
|
|
|
976
|
-
depthSensing.init(
|
|
1018
|
+
depthSensing.init( depthData, session.renderState );
|
|
1019
|
+
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
const cameraAccessEnabled = enabledFeatures &&
|
|
1025
|
+
enabledFeatures.includes( 'camera-access' );
|
|
1026
|
+
|
|
1027
|
+
if ( cameraAccessEnabled && supportsGlBinding ) {
|
|
1028
|
+
|
|
1029
|
+
renderer.state.unbindTexture();
|
|
1030
|
+
|
|
1031
|
+
glBinding = scope.getBinding();
|
|
1032
|
+
|
|
1033
|
+
for ( let i = 0; i < views.length; i ++ ) {
|
|
1034
|
+
|
|
1035
|
+
const camera = views[ i ].camera;
|
|
1036
|
+
|
|
1037
|
+
if ( camera ) {
|
|
1038
|
+
|
|
1039
|
+
let cameraTex = cameraAccessTextures[ camera ];
|
|
1040
|
+
|
|
1041
|
+
if ( ! cameraTex ) {
|
|
1042
|
+
|
|
1043
|
+
cameraTex = new ExternalTexture();
|
|
1044
|
+
cameraAccessTextures[ camera ] = cameraTex;
|
|
1045
|
+
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
const glTexture = glBinding.getCameraImage( camera );
|
|
1049
|
+
cameraTex.sourceTexture = glTexture;
|
|
1050
|
+
|
|
1051
|
+
}
|
|
977
1052
|
|
|
978
1053
|
}
|
|
979
1054
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Texture } from './Texture.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a texture created externally with the same renderer context.
|
|
5
|
+
*
|
|
6
|
+
* This may be a texture from a protected media stream, device camera feed,
|
|
7
|
+
* or other data feeds like a depth sensor.
|
|
8
|
+
*
|
|
9
|
+
* Note that this class is only supported in {@link WebGLRenderer}, and in
|
|
10
|
+
* the {@link WebGPURenderer} WebGPU backend.
|
|
11
|
+
*
|
|
12
|
+
* @augments Texture
|
|
13
|
+
*/
|
|
14
|
+
class ExternalTexture extends Texture {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new raw texture.
|
|
18
|
+
*
|
|
19
|
+
* @param {?(WebGLTexture|GPUTexture)} [sourceTexture=null] - The external texture.
|
|
20
|
+
*/
|
|
21
|
+
constructor( sourceTexture = null ) {
|
|
22
|
+
|
|
23
|
+
super();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The external source texture.
|
|
27
|
+
*
|
|
28
|
+
* @type {?(WebGLTexture|GPUTexture)}
|
|
29
|
+
* @default null
|
|
30
|
+
*/
|
|
31
|
+
this.sourceTexture = sourceTexture;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This flag can be used for type testing.
|
|
35
|
+
*
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
* @readonly
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
this.isExternalTexture = true;
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
copy( source ) {
|
|
45
|
+
|
|
46
|
+
super.copy( source );
|
|
47
|
+
|
|
48
|
+
this.sourceTexture = source.sourceTexture;
|
|
49
|
+
|
|
50
|
+
return this;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { ExternalTexture };
|
|
@@ -30,8 +30,8 @@ class FramebufferTexture extends Texture {
|
|
|
30
30
|
/**
|
|
31
31
|
* Constructs a new framebuffer texture.
|
|
32
32
|
*
|
|
33
|
-
* @param {number} width - The width of the texture.
|
|
34
|
-
* @param {number} height - The height of the texture.
|
|
33
|
+
* @param {number} [width] - The width of the texture.
|
|
34
|
+
* @param {number} [height] - The height of the texture.
|
|
35
35
|
*/
|
|
36
36
|
constructor( width, height ) {
|
|
37
37
|
|
package/src/textures/Source.js
CHANGED
|
@@ -73,13 +73,23 @@ class Source {
|
|
|
73
73
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Returns the dimensions of the source into the given target vector.
|
|
78
|
+
*
|
|
79
|
+
* @param {(Vector2|Vector3)} target - The target object the result is written into.
|
|
80
|
+
* @return {(Vector2|Vector3)} The dimensions of the source.
|
|
81
|
+
*/
|
|
76
82
|
getSize( target ) {
|
|
77
83
|
|
|
78
84
|
const data = this.data;
|
|
79
85
|
|
|
80
|
-
if ( data instanceof HTMLVideoElement ) {
|
|
86
|
+
if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( data instanceof HTMLVideoElement ) ) {
|
|
87
|
+
|
|
88
|
+
target.set( data.videoWidth, data.videoHeight, 0 );
|
|
89
|
+
|
|
90
|
+
} else if ( data instanceof VideoFrame ) {
|
|
81
91
|
|
|
82
|
-
target.set( data.
|
|
92
|
+
target.set( data.displayHeight, data.displayWidth, 0 );
|
|
83
93
|
|
|
84
94
|
} else if ( data !== null ) {
|
|
85
95
|
|
|
@@ -10,6 +10,9 @@ import { Texture } from './Texture.js';
|
|
|
10
10
|
* const texture = new THREE.VideoTexture( video );
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
|
+
* Note: When using video textures with {@link WebGPURenderer}, {@link Texture#colorSpace} must be
|
|
14
|
+
* set to THREE.SRGBColorSpace.
|
|
15
|
+
*
|
|
13
16
|
* Note: After the initial use of a texture, its dimensions, format, and type
|
|
14
17
|
* cannot be changed. Instead, call {@link Texture#dispose} on the texture and instantiate a new one.
|
|
15
18
|
*
|
|
@@ -53,18 +56,28 @@ class VideoTexture extends Texture {
|
|
|
53
56
|
*/
|
|
54
57
|
this.generateMipmaps = false;
|
|
55
58
|
|
|
59
|
+
/**
|
|
60
|
+
* The video frame request callback identifier, which is a positive integer.
|
|
61
|
+
*
|
|
62
|
+
* Value of 0 represents no scheduled rVFC.
|
|
63
|
+
*
|
|
64
|
+
* @private
|
|
65
|
+
* @type {number}
|
|
66
|
+
*/
|
|
67
|
+
this._requestVideoFrameCallbackId = 0;
|
|
68
|
+
|
|
56
69
|
const scope = this;
|
|
57
70
|
|
|
58
71
|
function updateVideo() {
|
|
59
72
|
|
|
60
73
|
scope.needsUpdate = true;
|
|
61
|
-
video.requestVideoFrameCallback( updateVideo );
|
|
74
|
+
scope._requestVideoFrameCallbackId = video.requestVideoFrameCallback( updateVideo );
|
|
62
75
|
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
if ( 'requestVideoFrameCallback' in video ) {
|
|
66
79
|
|
|
67
|
-
video.requestVideoFrameCallback( updateVideo );
|
|
80
|
+
this._requestVideoFrameCallbackId = video.requestVideoFrameCallback( updateVideo );
|
|
68
81
|
|
|
69
82
|
}
|
|
70
83
|
|
|
@@ -95,6 +108,18 @@ class VideoTexture extends Texture {
|
|
|
95
108
|
|
|
96
109
|
}
|
|
97
110
|
|
|
111
|
+
dispose() {
|
|
112
|
+
|
|
113
|
+
if ( this._requestVideoFrameCallbackId !== 0 ) {
|
|
114
|
+
|
|
115
|
+
this.source.data.cancelVideoFrameCallback( this._requestVideoFrameCallbackId );
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
super.dispose();
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
98
123
|
}
|
|
99
124
|
|
|
100
125
|
export { VideoTexture };
|