super-three 0.168.0 → 0.169.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +369 -131
- package/build/three.module.js +369 -131
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +24644 -22406
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -6
- package/examples/jsm/controls/TrackballControls.js +32 -12
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +10 -7
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +29 -10
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +5 -4
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +1 -2
- package/examples/jsm/objects/Water2Mesh.js +2 -3
- package/examples/jsm/objects/WaterMesh.js +1 -2
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +1 -0
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +2 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +1 -1
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/nodes/NodeLoader.js +24 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +21 -17
- package/src/loaders/nodes/NodeObjectLoader.js +19 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +19 -34
- package/src/materials/nodes/Line2NodeMaterial.js +26 -26
- package/src/materials/nodes/LineBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/LineDashedNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshLambertNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhongNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshStandardNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshToonNodeMaterial.js +7 -3
- package/src/materials/nodes/NodeMaterial.js +20 -45
- package/src/materials/nodes/NodeMaterials.js +2 -0
- package/src/materials/nodes/PointsNodeMaterial.js +7 -3
- package/src/materials/nodes/ShadowNodeMaterial.js +7 -3
- package/src/materials/nodes/SpriteNodeMaterial.js +39 -6
- package/src/materials/nodes/VolumeNodeMaterial.js +13 -9
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +3 -3
- package/src/nodes/TSL.js +96 -93
- package/src/nodes/accessors/BatchNode.js +7 -3
- package/src/nodes/accessors/BufferAttributeNode.js +6 -3
- package/src/nodes/accessors/BufferNode.js +6 -3
- package/src/nodes/accessors/Camera.js +10 -16
- package/src/nodes/accessors/ClippingNode.js +7 -3
- package/src/nodes/accessors/CubeTextureNode.js +6 -3
- package/src/nodes/accessors/InstanceNode.js +11 -11
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +6 -3
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +8 -4
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -3
- package/src/nodes/accessors/ModelNode.js +42 -7
- package/src/nodes/accessors/ModelViewProjectionNode.js +9 -5
- package/src/nodes/accessors/MorphNode.js +7 -3
- package/src/nodes/accessors/Normal.js +32 -6
- package/src/nodes/accessors/Object3DNode.js +11 -27
- package/src/nodes/accessors/PointUVNode.js +7 -3
- package/src/nodes/accessors/ReferenceBaseNode.js +32 -4
- package/src/nodes/accessors/ReferenceNode.js +40 -3
- package/src/nodes/accessors/RendererReferenceNode.js +9 -3
- package/src/nodes/accessors/SceneNode.js +7 -3
- package/src/nodes/accessors/SkinningNode.js +7 -3
- package/src/nodes/accessors/StorageBufferNode.js +21 -3
- package/src/nodes/accessors/StorageTextureNode.js +7 -4
- package/src/nodes/accessors/Texture3DNode.js +7 -4
- package/src/nodes/accessors/TextureNode.js +19 -8
- package/src/nodes/accessors/TextureSizeNode.js +8 -5
- package/src/nodes/accessors/UniformArrayNode.js +12 -9
- package/src/nodes/accessors/UserDataNode.js +9 -6
- package/src/nodes/accessors/VelocityNode.js +74 -23
- package/src/nodes/accessors/VertexColorNode.js +6 -3
- package/src/nodes/code/CodeNode.js +7 -3
- package/src/nodes/code/ExpressionNode.js +8 -4
- package/src/nodes/code/FunctionCallNode.js +6 -3
- package/src/nodes/code/FunctionNode.js +6 -3
- package/src/nodes/code/ScriptableNode.js +11 -6
- package/src/nodes/code/ScriptableValueNode.js +7 -3
- package/src/nodes/core/AssignNode.js +9 -6
- package/src/nodes/core/AttributeNode.js +7 -3
- package/src/nodes/core/BypassNode.js +8 -4
- package/src/nodes/core/CacheNode.js +8 -4
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +7 -3
- package/src/nodes/core/IndexNode.js +25 -3
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +6 -3
- package/src/nodes/core/Node.js +10 -51
- package/src/nodes/core/NodeBuilder.js +71 -5
- package/src/nodes/core/NodeUtils.js +48 -6
- package/src/nodes/core/OutputStructNode.js +8 -4
- package/src/nodes/core/ParameterNode.js +6 -3
- package/src/nodes/core/PropertyNode.js +7 -3
- package/src/nodes/core/StackNode.js +7 -3
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +10 -6
- package/src/nodes/core/UniformNode.js +6 -3
- package/src/nodes/core/VarNode.js +8 -4
- package/src/nodes/core/VaryingNode.js +7 -3
- package/src/nodes/display/AfterImageNode.js +6 -0
- package/src/nodes/display/AnaglyphPassNode.js +6 -0
- package/src/nodes/display/AnamorphicNode.js +6 -0
- package/src/nodes/display/BloomNode.js +6 -0
- package/src/nodes/display/BumpMapNode.js +6 -0
- package/src/nodes/display/ColorSpaceFunctions.js +4 -4
- package/src/nodes/display/ColorSpaceNode.js +43 -14
- package/src/nodes/display/DenoiseNode.js +6 -3
- package/src/nodes/display/DepthOfFieldNode.js +6 -3
- package/src/nodes/display/DotScreenNode.js +8 -5
- package/src/nodes/display/FXAANode.js +6 -3
- package/src/nodes/display/FilmNode.js +6 -3
- package/src/nodes/display/FrontFacingNode.js +7 -3
- package/src/nodes/display/GTAONode.js +6 -3
- package/src/nodes/display/GaussianBlurNode.js +6 -3
- package/src/nodes/display/Lut3DNode.js +6 -3
- package/src/nodes/display/NormalMapNode.js +8 -6
- package/src/nodes/display/ParallaxBarrierPassNode.js +8 -5
- package/src/nodes/display/PassNode.js +18 -7
- package/src/nodes/display/PixelationPassNode.js +12 -5
- package/src/nodes/display/PosterizeNode.js +6 -3
- package/src/nodes/display/RGBShiftNode.js +6 -3
- package/src/nodes/display/RenderOutputNode.js +12 -8
- package/src/nodes/display/SSAAPassNode.js +6 -3
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/SobelOperatorNode.js +6 -3
- package/src/nodes/display/StereoCompositePassNode.js +6 -3
- package/src/nodes/display/StereoPassNode.js +6 -3
- package/src/nodes/display/ToneMappingFunctions.js +12 -12
- package/src/nodes/display/ToneMappingNode.js +8 -7
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +6 -3
- package/src/nodes/display/ViewportDepthNode.js +7 -3
- package/src/nodes/display/ViewportDepthTextureNode.js +8 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +8 -5
- package/src/nodes/display/ViewportTextureNode.js +8 -5
- package/src/nodes/fog/FogExp2Node.js +6 -3
- package/src/nodes/fog/FogNode.js +7 -3
- package/src/nodes/fog/FogRangeNode.js +6 -3
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +7 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +8 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -3
- package/src/nodes/lighting/AnalyticLightNode.js +198 -30
- package/src/nodes/lighting/BasicEnvironmentNode.js +6 -3
- package/src/nodes/lighting/BasicLightMapNode.js +6 -3
- package/src/nodes/lighting/DirectionalLightNode.js +7 -4
- package/src/nodes/lighting/EnvironmentNode.js +6 -3
- package/src/nodes/lighting/HemisphereLightNode.js +10 -6
- package/src/nodes/lighting/IESSpotLightNode.js +6 -3
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +8 -31
- package/src/nodes/lighting/LightingContextNode.js +6 -3
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +24 -5
- package/src/nodes/lighting/PointLightNode.js +11 -7
- package/src/nodes/lighting/RectAreaLightNode.js +11 -7
- package/src/nodes/lighting/SpotLightNode.js +13 -10
- package/src/nodes/math/ConditionalNode.js +23 -6
- package/src/nodes/math/MathNode.js +6 -3
- package/src/nodes/math/OperatorNode.js +6 -3
- package/src/nodes/pmrem/PMREMNode.js +6 -3
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +6 -3
- package/src/nodes/utils/EquirectUVNode.js +6 -3
- package/src/nodes/utils/FlipNode.js +7 -4
- package/src/nodes/utils/FunctionOverloadingNode.js +7 -3
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +7 -3
- package/src/nodes/utils/MatcapUVNode.js +6 -3
- package/src/nodes/utils/MaxMipLevelNode.js +6 -3
- package/src/nodes/utils/OscNode.js +7 -3
- package/src/nodes/utils/RTTNode.js +6 -3
- package/src/nodes/utils/ReflectorNode.js +8 -5
- package/src/nodes/utils/RemapNode.js +7 -3
- package/src/nodes/utils/RotateNode.js +6 -3
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +7 -3
- package/src/nodes/utils/StorageArrayElementNode.js +9 -8
- package/src/nodes/utils/TimerNode.js +6 -3
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -3
- package/src/nodes/utils/ViewportUtils.js +2 -2
- package/src/objects/BatchedMesh.js +76 -10
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +64 -41
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +4 -3
- package/src/renderers/common/RenderContext.js +4 -5
- package/src/renderers/common/RenderObject.js +116 -5
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +57 -49
- package/src/renderers/common/extras/PMREMGenerator.js +7 -9
- package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
- package/src/renderers/common/nodes/Nodes.js +33 -14
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +22 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +50 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +61 -16
- package/src/renderers/webgpu/WebGPUBackend.js +33 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +5 -2
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/{common → webgpu}/nodes/StandardNodeLibrary.js +11 -11
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +91 -11
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +7 -5
- package/src/renderers/webgpu/utils/WebGPUUtils.js +1 -1
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/display/ViewportNode.js +0 -138
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/renderers/common/StandardRenderer.js +0 -18
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { float, addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
3
3
|
|
|
4
4
|
class RemapNode extends Node {
|
|
5
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'RemapNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
constructor( node, inLowNode, inHighNode, outLowNode = float( 0 ), outHighNode = float( 1 ) ) {
|
|
7
13
|
|
|
8
14
|
super();
|
|
@@ -33,8 +39,6 @@ class RemapNode extends Node {
|
|
|
33
39
|
|
|
34
40
|
export default RemapNode;
|
|
35
41
|
|
|
36
|
-
RemapNode.type = /*@__PURE__*/ registerNode( 'Remap', RemapNode );
|
|
37
|
-
|
|
38
42
|
export const remap = /*@__PURE__*/ nodeProxy( RemapNode, null, null, { doClamp: false } );
|
|
39
43
|
export const remapClamp = /*@__PURE__*/ nodeProxy( RemapNode );
|
|
40
44
|
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import TempNode from '../core/TempNode.js';
|
|
3
2
|
import { nodeProxy, vec4, mat2, mat4 } from '../tsl/TSLBase.js';
|
|
4
3
|
import { cos, sin } from '../math/MathNode.js';
|
|
5
4
|
|
|
6
5
|
class RotateNode extends TempNode {
|
|
7
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'RotateNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
constructor( positionNode, rotationNode ) {
|
|
9
14
|
|
|
10
15
|
super();
|
|
@@ -55,6 +60,4 @@ class RotateNode extends TempNode {
|
|
|
55
60
|
|
|
56
61
|
export default RotateNode;
|
|
57
62
|
|
|
58
|
-
RotateNode.type = /*@__PURE__*/ registerNode( 'Rotate', RotateNode );
|
|
59
|
-
|
|
60
63
|
export const rotate = /*@__PURE__*/ nodeProxy( RotateNode );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import TempNode from '../core/TempNode.js';
|
|
3
2
|
import { vectorComponents } from '../core/constants.js';
|
|
4
3
|
|
|
5
4
|
class SetNode extends TempNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'SetNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( sourceNode, components, targetNode ) {
|
|
8
13
|
|
|
9
14
|
super();
|
|
@@ -25,7 +30,7 @@ class SetNode extends TempNode {
|
|
|
25
30
|
const { sourceNode, components, targetNode } = this;
|
|
26
31
|
|
|
27
32
|
const sourceType = this.getNodeType( builder );
|
|
28
|
-
const targetType = builder.getTypeFromLength( components.length );
|
|
33
|
+
const targetType = builder.getTypeFromLength( components.length, targetNode.getNodeType( builder ) );
|
|
29
34
|
|
|
30
35
|
const targetSnippet = targetNode.build( builder, targetType );
|
|
31
36
|
const sourceSnippet = sourceNode.build( builder, sourceType );
|
|
@@ -58,5 +63,3 @@ class SetNode extends TempNode {
|
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
export default SetNode;
|
|
61
|
-
|
|
62
|
-
SetNode.type = /*@__PURE__*/ registerNode( 'Set', SetNode );
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { vectorComponents } from '../core/constants.js';
|
|
3
3
|
|
|
4
4
|
const stringVectorComponents = vectorComponents.join( '' );
|
|
5
5
|
|
|
6
6
|
class SplitNode extends Node {
|
|
7
7
|
|
|
8
|
+
static get type() {
|
|
9
|
+
|
|
10
|
+
return 'SplitNode';
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
constructor( node, components = 'x' ) {
|
|
9
15
|
|
|
10
16
|
super();
|
|
@@ -108,5 +114,3 @@ class SplitNode extends Node {
|
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
export default SplitNode;
|
|
111
|
-
|
|
112
|
-
SplitNode.type = /*@__PURE__*/ registerNode( 'Split', SplitNode );
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { uv } from '../accessors/UV.js';
|
|
3
3
|
import { nodeProxy, float, vec2 } from '../tsl/TSLBase.js';
|
|
4
4
|
|
|
5
5
|
class SpriteSheetUVNode extends Node {
|
|
6
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'SpriteSheetUVNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
constructor( countNode, uvNode = uv(), frameNode = float( 0 ) ) {
|
|
8
14
|
|
|
9
15
|
super( 'vec2' );
|
|
@@ -36,6 +42,4 @@ class SpriteSheetUVNode extends Node {
|
|
|
36
42
|
|
|
37
43
|
export default SpriteSheetUVNode;
|
|
38
44
|
|
|
39
|
-
SpriteSheetUVNode.type = /*@__PURE__*/ registerNode( 'SpriteSheetUV', SpriteSheetUVNode );
|
|
40
|
-
|
|
41
45
|
export const spritesheetUV = /*@__PURE__*/ nodeProxy( SpriteSheetUVNode );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import { nodeProxy } from '../tsl/TSLBase.js';
|
|
3
2
|
import ArrayElementNode from './ArrayElementNode.js';
|
|
4
3
|
|
|
5
4
|
class StorageArrayElementNode extends ArrayElementNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'StorageArrayElementNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( storageBufferNode, indexNode ) {
|
|
8
13
|
|
|
9
14
|
super( storageBufferNode, indexNode );
|
|
@@ -28,7 +33,7 @@ class StorageArrayElementNode extends ArrayElementNode {
|
|
|
28
33
|
|
|
29
34
|
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
|
30
35
|
|
|
31
|
-
if (
|
|
36
|
+
if ( this.node.bufferObject === true ) {
|
|
32
37
|
|
|
33
38
|
builder.setupPBO( this.node );
|
|
34
39
|
|
|
@@ -50,15 +55,13 @@ class StorageArrayElementNode extends ArrayElementNode {
|
|
|
50
55
|
|
|
51
56
|
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if ( ! node.instanceIndex && this.node.bufferObject === true && isAssignContext !== true ) {
|
|
58
|
+
if ( this.node.bufferObject === true && isAssignContext !== true ) {
|
|
56
59
|
|
|
57
60
|
snippet = builder.generatePBO( this );
|
|
58
61
|
|
|
59
62
|
} else {
|
|
60
63
|
|
|
61
|
-
snippet = node.build( builder );
|
|
64
|
+
snippet = this.node.build( builder );
|
|
62
65
|
|
|
63
66
|
}
|
|
64
67
|
|
|
@@ -84,6 +87,4 @@ class StorageArrayElementNode extends ArrayElementNode {
|
|
|
84
87
|
|
|
85
88
|
export default StorageArrayElementNode;
|
|
86
89
|
|
|
87
|
-
StorageArrayElementNode.type = /*@__PURE__*/ registerNode( 'StorageArrayElement', StorageArrayElementNode );
|
|
88
|
-
|
|
89
90
|
export const storageElement = /*@__PURE__*/ nodeProxy( StorageArrayElementNode );
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import UniformNode from '../core/UniformNode.js';
|
|
3
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
4
3
|
import { nodeObject, nodeImmutable } from '../tsl/TSLBase.js';
|
|
5
4
|
|
|
6
5
|
class TimerNode extends UniformNode {
|
|
7
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'TimerNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
constructor( scope = TimerNode.LOCAL, scale = 1, value = 0 ) {
|
|
9
14
|
|
|
10
15
|
super( value );
|
|
@@ -85,8 +90,6 @@ TimerNode.FRAME = 'frame';
|
|
|
85
90
|
|
|
86
91
|
export default TimerNode;
|
|
87
92
|
|
|
88
|
-
TimerNode.type = /*@__PURE__*/ registerNode( 'Timer', TimerNode );
|
|
89
|
-
|
|
90
93
|
// @TODO: add support to use node in timeScale
|
|
91
94
|
export const timerLocal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.LOCAL, timeScale, value ) );
|
|
92
95
|
export const timerGlobal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.GLOBAL, timeScale, value ) );
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { add } from '../math/OperatorNode.js';
|
|
3
3
|
import { normalLocal } from '../accessors/Normal.js';
|
|
4
4
|
import { positionLocal } from '../accessors/Position.js';
|
|
@@ -7,6 +7,12 @@ import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
|
|
|
7
7
|
|
|
8
8
|
class TriplanarTexturesNode extends Node {
|
|
9
9
|
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'TriplanarTexturesNode';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
constructor( textureXNode, textureYNode = null, textureZNode = null, scaleNode = float( 1 ), positionNode = positionLocal, normalNode = normalLocal ) {
|
|
11
17
|
|
|
12
18
|
super( 'vec4' );
|
|
@@ -54,7 +60,5 @@ class TriplanarTexturesNode extends Node {
|
|
|
54
60
|
|
|
55
61
|
export default TriplanarTexturesNode;
|
|
56
62
|
|
|
57
|
-
TriplanarTexturesNode.type = /*@__PURE__*/ registerNode( 'TriplanarTextures', TriplanarTexturesNode );
|
|
58
|
-
|
|
59
63
|
export const triplanarTextures = /*@__PURE__*/ nodeProxy( TriplanarTexturesNode );
|
|
60
64
|
export const triplanarTexture = ( ...params ) => triplanarTextures( ...params );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fn } from '../tsl/TSLBase.js';
|
|
2
|
-
import {
|
|
2
|
+
import { screenUV } from '../display/ScreenNode.js';
|
|
3
3
|
import { viewportDepthTexture } from '../display/ViewportDepthTextureNode.js';
|
|
4
4
|
import { linearDepth } from '../display/ViewportDepthNode.js';
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ export const viewportSafeUV = /*@__PURE__*/ Fn( ( [ uv = null ] ) => {
|
|
|
7
7
|
|
|
8
8
|
const depth = linearDepth();
|
|
9
9
|
const depthDiff = linearDepth( viewportDepthTexture( uv ) ).sub( depth );
|
|
10
|
-
const finalUV = depthDiff.lessThan( 0 ).select(
|
|
10
|
+
const finalUV = depthDiff.lessThan( 0 ).select( screenUV, uv );
|
|
11
11
|
|
|
12
12
|
return finalUV;
|
|
13
13
|
|
|
@@ -145,6 +145,9 @@ class BatchedMesh extends Mesh {
|
|
|
145
145
|
// stores visible, active, and geometry id per object
|
|
146
146
|
this._drawInfo = [];
|
|
147
147
|
|
|
148
|
+
// instance ids that have been set as inactive, and are available to be overwritten
|
|
149
|
+
this._availableInstanceIds = [];
|
|
150
|
+
|
|
148
151
|
// geometry information
|
|
149
152
|
this._drawRanges = [];
|
|
150
153
|
this._reservedRanges = [];
|
|
@@ -344,23 +347,36 @@ class BatchedMesh extends Mesh {
|
|
|
344
347
|
|
|
345
348
|
addInstance( geometryId ) {
|
|
346
349
|
|
|
350
|
+
const atCapacity = this._drawInfo.length >= this.maxInstanceCount;
|
|
351
|
+
|
|
347
352
|
// ensure we're not over geometry
|
|
348
|
-
if ( this.
|
|
353
|
+
if ( atCapacity && this._availableInstanceIds.length === 0 ) {
|
|
349
354
|
|
|
350
355
|
throw new Error( 'BatchedMesh: Maximum item count reached.' );
|
|
351
356
|
|
|
352
357
|
}
|
|
353
358
|
|
|
354
|
-
|
|
355
|
-
|
|
359
|
+
const instanceDrawInfo = {
|
|
356
360
|
visible: true,
|
|
357
361
|
active: true,
|
|
358
362
|
geometryIndex: geometryId,
|
|
363
|
+
};
|
|
359
364
|
|
|
360
|
-
|
|
365
|
+
let drawId = null;
|
|
366
|
+
|
|
367
|
+
// Prioritize using previously freed instance ids
|
|
368
|
+
if ( this._availableInstanceIds.length > 0 ) {
|
|
369
|
+
|
|
370
|
+
drawId = this._availableInstanceIds.pop();
|
|
371
|
+
this._drawInfo[ drawId ] = instanceDrawInfo;
|
|
372
|
+
|
|
373
|
+
} else {
|
|
374
|
+
|
|
375
|
+
drawId = this._drawInfo.length;
|
|
376
|
+
this._drawInfo.push( instanceDrawInfo );
|
|
377
|
+
|
|
378
|
+
}
|
|
361
379
|
|
|
362
|
-
// initialize the matrix
|
|
363
|
-
const drawId = this._drawInfo.length - 1;
|
|
364
380
|
const matricesTexture = this._matricesTexture;
|
|
365
381
|
const matricesArray = matricesTexture.image.data;
|
|
366
382
|
_identityMatrix.toArray( matricesArray, drawId * 16 );
|
|
@@ -609,11 +625,8 @@ class BatchedMesh extends Mesh {
|
|
|
609
625
|
}
|
|
610
626
|
*/
|
|
611
627
|
|
|
612
|
-
/*
|
|
613
628
|
deleteInstance( instanceId ) {
|
|
614
629
|
|
|
615
|
-
// Note: User needs to call optimize() afterward to pack the data.
|
|
616
|
-
|
|
617
630
|
const drawInfo = this._drawInfo;
|
|
618
631
|
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
619
632
|
|
|
@@ -622,12 +635,12 @@ class BatchedMesh extends Mesh {
|
|
|
622
635
|
}
|
|
623
636
|
|
|
624
637
|
drawInfo[ instanceId ].active = false;
|
|
638
|
+
this._availableInstanceIds.push( instanceId );
|
|
625
639
|
this._visibilityChanged = true;
|
|
626
640
|
|
|
627
641
|
return this;
|
|
628
642
|
|
|
629
643
|
}
|
|
630
|
-
*/
|
|
631
644
|
|
|
632
645
|
// get bounding box and compute it if it doesn't exist
|
|
633
646
|
getBoundingBoxAt( geometryId, target ) {
|
|
@@ -832,6 +845,59 @@ class BatchedMesh extends Mesh {
|
|
|
832
845
|
|
|
833
846
|
}
|
|
834
847
|
|
|
848
|
+
setGeometryIdAt( instanceId, geometryId ) {
|
|
849
|
+
|
|
850
|
+
// return early if the geometry is out of range or not active
|
|
851
|
+
const drawInfo = this._drawInfo;
|
|
852
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
853
|
+
|
|
854
|
+
return null;
|
|
855
|
+
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// check if the provided geometryId is within the valid range
|
|
859
|
+
if ( geometryId < 0 || geometryId >= this._geometryCount ) {
|
|
860
|
+
|
|
861
|
+
return null;
|
|
862
|
+
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
drawInfo[ instanceId ].geometryIndex = geometryId;
|
|
866
|
+
|
|
867
|
+
return this;
|
|
868
|
+
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
getGeometryIdAt( instanceId ) {
|
|
872
|
+
|
|
873
|
+
const drawInfo = this._drawInfo;
|
|
874
|
+
if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
|
|
875
|
+
|
|
876
|
+
return - 1;
|
|
877
|
+
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
return drawInfo[ instanceId ].geometryIndex;
|
|
881
|
+
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
getGeometryRangeAt( geometryId, target = {} ) {
|
|
885
|
+
|
|
886
|
+
if ( geometryId < 0 || geometryId >= this._geometryCount ) {
|
|
887
|
+
|
|
888
|
+
return null;
|
|
889
|
+
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
const drawRange = this._drawRanges[ geometryId ];
|
|
893
|
+
|
|
894
|
+
target.start = drawRange.start;
|
|
895
|
+
target.count = drawRange.count;
|
|
896
|
+
|
|
897
|
+
return target;
|
|
898
|
+
|
|
899
|
+
}
|
|
900
|
+
|
|
835
901
|
raycast( raycaster, intersects ) {
|
|
836
902
|
|
|
837
903
|
const drawInfo = this._drawInfo;
|
package/src/objects/LOD.js
CHANGED
|
@@ -74,6 +74,27 @@ class LOD extends Object3D {
|
|
|
74
74
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
removeLevel( distance ) {
|
|
78
|
+
|
|
79
|
+
const levels = this.levels;
|
|
80
|
+
|
|
81
|
+
for ( let i = 0; i < levels.length; i ++ ) {
|
|
82
|
+
|
|
83
|
+
if ( levels[ i ].distance === distance ) {
|
|
84
|
+
|
|
85
|
+
const removedElements = levels.splice( i, 1 );
|
|
86
|
+
this.remove( removedElements[ 0 ].object );
|
|
87
|
+
|
|
88
|
+
return true;
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return false;
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
77
98
|
getCurrentLevel() {
|
|
78
99
|
|
|
79
100
|
return this._currentLevel;
|
package/src/objects/Line.js
CHANGED
package/src/objects/Mesh.js
CHANGED
|
@@ -21,14 +21,6 @@ const _vC = /*@__PURE__*/ new Vector3();
|
|
|
21
21
|
const _tempA = /*@__PURE__*/ new Vector3();
|
|
22
22
|
const _morphA = /*@__PURE__*/ new Vector3();
|
|
23
23
|
|
|
24
|
-
const _uvA = /*@__PURE__*/ new Vector2();
|
|
25
|
-
const _uvB = /*@__PURE__*/ new Vector2();
|
|
26
|
-
const _uvC = /*@__PURE__*/ new Vector2();
|
|
27
|
-
|
|
28
|
-
const _normalA = /*@__PURE__*/ new Vector3();
|
|
29
|
-
const _normalB = /*@__PURE__*/ new Vector3();
|
|
30
|
-
const _normalC = /*@__PURE__*/ new Vector3();
|
|
31
|
-
|
|
32
24
|
const _intersectionPoint = /*@__PURE__*/ new Vector3();
|
|
33
25
|
const _intersectionPointWorld = /*@__PURE__*/ new Vector3();
|
|
34
26
|
|
|
@@ -371,33 +363,24 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
|
|
|
371
363
|
|
|
372
364
|
if ( intersection ) {
|
|
373
365
|
|
|
374
|
-
|
|
366
|
+
const barycoord = new Vector3();
|
|
367
|
+
Triangle.getBarycoord( _intersectionPoint, _vA, _vB, _vC, barycoord );
|
|
375
368
|
|
|
376
|
-
|
|
377
|
-
_uvB.fromBufferAttribute( uv, b );
|
|
378
|
-
_uvC.fromBufferAttribute( uv, c );
|
|
369
|
+
if ( uv ) {
|
|
379
370
|
|
|
380
|
-
intersection.uv = Triangle.
|
|
371
|
+
intersection.uv = Triangle.getInterpolatedAttribute( uv, a, b, c, barycoord, new Vector2() );
|
|
381
372
|
|
|
382
373
|
}
|
|
383
374
|
|
|
384
375
|
if ( uv1 ) {
|
|
385
376
|
|
|
386
|
-
|
|
387
|
-
_uvB.fromBufferAttribute( uv1, b );
|
|
388
|
-
_uvC.fromBufferAttribute( uv1, c );
|
|
389
|
-
|
|
390
|
-
intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
|
|
377
|
+
intersection.uv1 = Triangle.getInterpolatedAttribute( uv1, a, b, c, barycoord, new Vector2() );
|
|
391
378
|
|
|
392
379
|
}
|
|
393
380
|
|
|
394
381
|
if ( normal ) {
|
|
395
382
|
|
|
396
|
-
|
|
397
|
-
_normalB.fromBufferAttribute( normal, b );
|
|
398
|
-
_normalC.fromBufferAttribute( normal, c );
|
|
399
|
-
|
|
400
|
-
intersection.normal = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _normalA, _normalB, _normalC, new Vector3() );
|
|
383
|
+
intersection.normal = Triangle.getInterpolatedAttribute( normal, a, b, c, barycoord, new Vector3() );
|
|
401
384
|
|
|
402
385
|
if ( intersection.normal.dot( ray.direction ) > 0 ) {
|
|
403
386
|
|
|
@@ -418,6 +401,7 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
|
|
|
418
401
|
Triangle.getNormal( _vA, _vB, _vC, face.normal );
|
|
419
402
|
|
|
420
403
|
intersection.face = face;
|
|
404
|
+
intersection.barycoord = barycoord;
|
|
421
405
|
|
|
422
406
|
}
|
|
423
407
|
|
package/src/objects/Points.js
CHANGED
|
@@ -56,7 +56,7 @@ import { WebVRManager } from './webvr/WebVRManager.js';
|
|
|
56
56
|
import { WebXRManager } from './webxr/WebXRManager.js';
|
|
57
57
|
import { WebGLMaterials } from './webgl/WebGLMaterials.js';
|
|
58
58
|
import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
|
|
59
|
-
import { createCanvasElement, probeAsync, warnOnce } from '../utils.js';
|
|
59
|
+
import { createCanvasElement, probeAsync, toNormalizedProjectionMatrix, toReversedProjectionMatrix, warnOnce } from '../utils.js';
|
|
60
60
|
import { ColorManagement } from '../math/ColorManagement.js';
|
|
61
61
|
|
|
62
62
|
class WebGLRenderer {
|
|
@@ -199,6 +199,7 @@ class WebGLRenderer {
|
|
|
199
199
|
|
|
200
200
|
// camera matrices cache
|
|
201
201
|
|
|
202
|
+
const _currentProjectionMatrix = new Matrix4();
|
|
202
203
|
const _projScreenMatrix = new Matrix4();
|
|
203
204
|
|
|
204
205
|
const _vector3 = new Vector3();
|
|
@@ -295,6 +296,8 @@ class WebGLRenderer {
|
|
|
295
296
|
|
|
296
297
|
state = new WebGLState( _gl );
|
|
297
298
|
|
|
299
|
+
if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
|
|
300
|
+
|
|
298
301
|
info = new WebGLInfo( _gl );
|
|
299
302
|
properties = new WebGLProperties();
|
|
300
303
|
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
@@ -595,7 +598,13 @@ class WebGLRenderer {
|
|
|
595
598
|
|
|
596
599
|
}
|
|
597
600
|
|
|
598
|
-
if ( depth )
|
|
601
|
+
if ( depth ) {
|
|
602
|
+
|
|
603
|
+
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
604
|
+
_gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
|
|
605
|
+
|
|
606
|
+
}
|
|
607
|
+
|
|
599
608
|
if ( stencil ) {
|
|
600
609
|
|
|
601
610
|
bits |= _gl.STENCIL_BUFFER_BIT;
|
|
@@ -984,6 +993,12 @@ class WebGLRenderer {
|
|
|
984
993
|
|
|
985
994
|
scene.traverse( function ( object ) {
|
|
986
995
|
|
|
996
|
+
if ( ! ( object.isMesh || object.isPoints || object.isLine || object.isSprite ) ) {
|
|
997
|
+
|
|
998
|
+
return;
|
|
999
|
+
|
|
1000
|
+
}
|
|
1001
|
+
|
|
987
1002
|
const material = object.material;
|
|
988
1003
|
|
|
989
1004
|
if ( material ) {
|
|
@@ -2001,7 +2016,21 @@ class WebGLRenderer {
|
|
|
2001
2016
|
|
|
2002
2017
|
} else {
|
|
2003
2018
|
|
|
2004
|
-
|
|
2019
|
+
if ( capabilities.reverseDepthBuffer ) {
|
|
2020
|
+
|
|
2021
|
+
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
2022
|
+
|
|
2023
|
+
toNormalizedProjectionMatrix( _currentProjectionMatrix );
|
|
2024
|
+
toReversedProjectionMatrix( _currentProjectionMatrix );
|
|
2025
|
+
|
|
2026
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
|
|
2027
|
+
|
|
2028
|
+
} else {
|
|
2029
|
+
|
|
2030
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
2031
|
+
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2005
2034
|
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
2006
2035
|
|
|
2007
2036
|
}
|
|
@@ -2519,61 +2548,55 @@ class WebGLRenderer {
|
|
|
2519
2548
|
|
|
2520
2549
|
if ( framebuffer ) {
|
|
2521
2550
|
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
const texture = renderTarget.texture;
|
|
2527
|
-
const textureFormat = texture.format;
|
|
2528
|
-
const textureType = texture.type;
|
|
2529
|
-
|
|
2530
|
-
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2531
|
-
|
|
2532
|
-
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
2551
|
+
const texture = renderTarget.texture;
|
|
2552
|
+
const textureFormat = texture.format;
|
|
2553
|
+
const textureType = texture.type;
|
|
2533
2554
|
|
|
2534
|
-
|
|
2555
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
2535
2556
|
|
|
2536
|
-
|
|
2557
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
2537
2558
|
|
|
2538
|
-
|
|
2559
|
+
}
|
|
2539
2560
|
|
|
2540
|
-
|
|
2561
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
2541
2562
|
|
|
2542
|
-
|
|
2543
|
-
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2563
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
2544
2564
|
|
|
2545
|
-
|
|
2546
|
-
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2547
|
-
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
2548
|
-
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
2549
|
-
_gl.flush();
|
|
2565
|
+
}
|
|
2550
2566
|
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
await probeAsync( _gl, sync, 4 );
|
|
2567
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
2568
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2554
2569
|
|
|
2555
|
-
|
|
2570
|
+
// set the active frame buffer to the one we want to read
|
|
2571
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2556
2572
|
|
|
2557
|
-
|
|
2558
|
-
|
|
2573
|
+
const glBuffer = _gl.createBuffer();
|
|
2574
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2575
|
+
_gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
|
|
2576
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
|
|
2559
2577
|
|
|
2560
|
-
|
|
2578
|
+
// reset the frame buffer to the currently set buffer before waiting
|
|
2579
|
+
const currFramebuffer = _currentRenderTarget !== null ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
2580
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, currFramebuffer );
|
|
2561
2581
|
|
|
2562
|
-
|
|
2563
|
-
|
|
2582
|
+
// check if the commands have finished every 8 ms
|
|
2583
|
+
const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
|
|
2564
2584
|
|
|
2565
|
-
|
|
2585
|
+
_gl.flush();
|
|
2566
2586
|
|
|
2567
|
-
|
|
2587
|
+
await probeAsync( _gl, sync, 4 );
|
|
2568
2588
|
|
|
2569
|
-
|
|
2589
|
+
// read the data and delete the buffer
|
|
2590
|
+
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
2591
|
+
_gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
|
|
2592
|
+
_gl.deleteBuffer( glBuffer );
|
|
2593
|
+
_gl.deleteSync( sync );
|
|
2570
2594
|
|
|
2571
|
-
|
|
2595
|
+
return buffer;
|
|
2572
2596
|
|
|
2573
|
-
|
|
2597
|
+
} else {
|
|
2574
2598
|
|
|
2575
|
-
|
|
2576
|
-
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2599
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.' );
|
|
2577
2600
|
|
|
2578
2601
|
}
|
|
2579
2602
|
|