@plastic-software/three 0.183.4 → 0.184.1
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 +775 -287
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +428 -181
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +7 -1
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2979 -1281
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2942 -1281
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +11 -0
- package/examples/jsm/animation/CCDIKSolver.js +5 -1
- package/examples/jsm/controls/ArcballControls.js +4 -1
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +2 -2
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +21 -5
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +169 -114
- package/examples/jsm/inspector/RendererInspector.js +2 -2
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +34 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +105 -3
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +273 -176
- package/examples/jsm/inspector/ui/Style.js +64 -10
- package/examples/jsm/inspector/ui/Tab.js +39 -7
- package/examples/jsm/inspector/ui/Values.js +39 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +682 -43
- package/examples/jsm/loaders/FBXLoader.js +233 -33
- package/examples/jsm/loaders/GLTFLoader.js +24 -7
- package/examples/jsm/loaders/HDRLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +8 -2
- package/examples/jsm/loaders/LDrawLoader.js +39 -47
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/VTKLoader.js +5 -1
- package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
- package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
- package/examples/jsm/loaders/usd/USDAParser.js +6 -0
- package/examples/jsm/loaders/usd/USDCParser.js +26 -0
- package/examples/jsm/loaders/usd/USDComposer.js +656 -103
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +14 -2
- package/examples/jsm/objects/SkyMesh.js +23 -6
- package/examples/jsm/renderers/Projector.js +18 -38
- package/examples/jsm/renderers/SVGRenderer.js +6 -25
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/GTAONode.js +2 -1
- package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
- package/examples/jsm/tsl/display/GodraysNode.js +2 -11
- package/examples/jsm/tsl/display/OutlineNode.js +66 -16
- package/examples/jsm/tsl/display/SSGINode.js +0 -4
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +48 -7
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +13 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +4 -4
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +6 -0
- package/src/Three.WebGPU.Nodes.js +3 -0
- package/src/Three.WebGPU.js +6 -0
- package/src/animation/AnimationAction.js +11 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/Clock.js +1 -1
- package/src/core/Object3D.js +1 -5
- package/src/core/RenderTarget.js +1 -0
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +1 -2
- package/src/loaders/ImageBitmapLoader.js +4 -6
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +25 -4
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +27 -0
- package/src/materials/nodes/NodeMaterial.js +0 -27
- package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
- package/src/math/Line3.js +3 -0
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +13 -9
- package/src/math/Plane.js +4 -3
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +12 -8
- package/src/math/Vector4.js +13 -9
- package/src/nodes/Nodes.js +0 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/BufferAttributeNode.js +9 -3
- package/src/nodes/accessors/CubeTextureNode.js +7 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/SceneProperties.js +2 -8
- package/src/nodes/accessors/StorageBufferNode.js +10 -4
- package/src/nodes/accessors/StorageTextureNode.js +4 -9
- package/src/nodes/accessors/TextureNode.js +10 -2
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +1 -1
- package/src/nodes/core/ArrayNode.js +1 -1
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/Node.js +83 -12
- package/src/nodes/core/NodeBuilder.js +117 -16
- package/src/nodes/core/NodeUtils.js +1 -1
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/ParameterNode.js +1 -1
- package/src/nodes/core/StackNode.js +1 -1
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +1 -1
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +27 -7
- package/src/nodes/display/RenderOutputNode.js +4 -4
- package/src/nodes/display/ScreenNode.js +1 -1
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +18 -7
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +69 -44
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/lighting/LightsNode.js +6 -27
- package/src/nodes/lighting/ShadowNode.js +24 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +73 -1
- package/src/nodes/math/OperatorNode.js +1 -1
- package/src/nodes/math/PackFloatNode.js +1 -1
- package/src/nodes/math/UnpackFloatNode.js +1 -1
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +21 -3
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +30 -0
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/objects/BatchedMesh.js +17 -2
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +147 -48
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +0 -8
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/BindGroup.js +1 -8
- package/src/renderers/common/Bindings.js +2 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Pipelines.js +36 -3
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +5 -2
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/RenderObjects.js +3 -3
- package/src/renderers/common/RenderPipeline.js +35 -6
- package/src/renderers/common/Renderer.js +232 -53
- package/src/renderers/common/Textures.js +72 -3
- package/src/renderers/common/UniformsGroup.js +1 -1
- package/src/renderers/common/XRManager.js +34 -27
- package/src/renderers/common/extras/PMREMGenerator.js +23 -15
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeManager.js +230 -99
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +0 -1
- package/src/renderers/shaders/UniformsLib.js +7 -2
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +13 -13
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +6 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLMaterials.js +12 -13
- package/src/renderers/webgl/WebGLOutput.js +4 -1
- package/src/renderers/webgl/WebGLProgram.js +4 -0
- package/src/renderers/webgl/WebGLPrograms.js +21 -4
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLState.js +43 -0
- package/src/renderers/webgl/WebGLTextures.js +129 -26
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +160 -146
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +13 -2
- package/src/utils.js +23 -1
- package/src/nodes/utils/RemapNode.js +0 -125
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InstancedBufferAttribute,
|
|
3
|
+
InstancedMesh,
|
|
4
|
+
Matrix4,
|
|
5
|
+
ShaderMaterial,
|
|
6
|
+
SphereGeometry,
|
|
7
|
+
Vector3
|
|
8
|
+
} from 'three';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Visualizes an {@link LightProbeGrid} by rendering a sphere at each
|
|
12
|
+
* probe position, shaded with the probe's L1 spherical harmonics.
|
|
13
|
+
*
|
|
14
|
+
* Uses a single `InstancedMesh` draw call for all probes.
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* const helper = new LightProbeGridHelper( probes );
|
|
18
|
+
* scene.add( helper );
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @augments InstancedMesh
|
|
22
|
+
* @three_import import { LightProbeGridHelper } from 'three/addons/helpers/LightProbeGridHelper.js';
|
|
23
|
+
*/
|
|
24
|
+
class LightProbeGridHelper extends InstancedMesh {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Constructs a new irradiance probe grid helper.
|
|
28
|
+
*
|
|
29
|
+
* @param {LightProbeGrid} probes - The probe grid to visualize.
|
|
30
|
+
* @param {number} [sphereSize=0.12] - The radius of each probe sphere.
|
|
31
|
+
*/
|
|
32
|
+
constructor( probes, sphereSize = 0.12 ) {
|
|
33
|
+
|
|
34
|
+
const geometry = new SphereGeometry( sphereSize, 16, 16 );
|
|
35
|
+
|
|
36
|
+
const material = new ShaderMaterial( {
|
|
37
|
+
|
|
38
|
+
uniforms: {
|
|
39
|
+
|
|
40
|
+
probesSH: { value: null },
|
|
41
|
+
probesResolution: { value: new Vector3() },
|
|
42
|
+
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
vertexShader: /* glsl */`
|
|
46
|
+
|
|
47
|
+
attribute vec3 instanceUVW;
|
|
48
|
+
|
|
49
|
+
varying vec3 vWorldNormal;
|
|
50
|
+
varying vec3 vUVW;
|
|
51
|
+
|
|
52
|
+
void main() {
|
|
53
|
+
|
|
54
|
+
vUVW = instanceUVW;
|
|
55
|
+
vWorldNormal = normalize( mat3( modelMatrix ) * normal );
|
|
56
|
+
gl_Position = projectionMatrix * modelViewMatrix * instanceMatrix * vec4( position, 1.0 );
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
`,
|
|
61
|
+
|
|
62
|
+
fragmentShader: /* glsl */`
|
|
63
|
+
|
|
64
|
+
precision highp sampler3D;
|
|
65
|
+
|
|
66
|
+
uniform sampler3D probesSH;
|
|
67
|
+
uniform vec3 probesResolution;
|
|
68
|
+
|
|
69
|
+
varying vec3 vWorldNormal;
|
|
70
|
+
varying vec3 vUVW;
|
|
71
|
+
|
|
72
|
+
void main() {
|
|
73
|
+
|
|
74
|
+
// Atlas UV mapping — must match lightprobes_pars_fragment.glsl.js
|
|
75
|
+
float nz = probesResolution.z;
|
|
76
|
+
float paddedSlices = nz + 2.0;
|
|
77
|
+
float atlasDepth = 7.0 * paddedSlices;
|
|
78
|
+
float uvZBase = vUVW.z * nz + 1.0;
|
|
79
|
+
|
|
80
|
+
vec4 s0 = texture( probesSH, vec3( vUVW.xy, ( uvZBase ) / atlasDepth ) );
|
|
81
|
+
vec4 s1 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
|
|
82
|
+
vec4 s2 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
|
|
83
|
+
vec4 s3 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
|
|
84
|
+
vec4 s4 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
|
|
85
|
+
vec4 s5 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
|
|
86
|
+
vec4 s6 = texture( probesSH, vec3( vUVW.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
|
|
87
|
+
|
|
88
|
+
// Unpack 9 vec3 SH L2 coefficients
|
|
89
|
+
|
|
90
|
+
vec3 c0 = s0.xyz;
|
|
91
|
+
vec3 c1 = vec3( s0.w, s1.xy );
|
|
92
|
+
vec3 c2 = vec3( s1.zw, s2.x );
|
|
93
|
+
vec3 c3 = s2.yzw;
|
|
94
|
+
vec3 c4 = s3.xyz;
|
|
95
|
+
vec3 c5 = vec3( s3.w, s4.xy );
|
|
96
|
+
vec3 c6 = vec3( s4.zw, s5.x );
|
|
97
|
+
vec3 c7 = s5.yzw;
|
|
98
|
+
vec3 c8 = s6.xyz;
|
|
99
|
+
|
|
100
|
+
vec3 n = normalize( vWorldNormal );
|
|
101
|
+
|
|
102
|
+
float x = n.x, y = n.y, z = n.z;
|
|
103
|
+
|
|
104
|
+
// band 0
|
|
105
|
+
vec3 result = c0 * 0.886227;
|
|
106
|
+
|
|
107
|
+
// band 1,
|
|
108
|
+
result += c1 * 2.0 * 0.511664 * y;
|
|
109
|
+
result += c2 * 2.0 * 0.511664 * z;
|
|
110
|
+
result += c3 * 2.0 * 0.511664 * x;
|
|
111
|
+
|
|
112
|
+
// band 2,
|
|
113
|
+
result += c4 * 2.0 * 0.429043 * x * y;
|
|
114
|
+
result += c5 * 2.0 * 0.429043 * y * z;
|
|
115
|
+
result += c6 * ( 0.743125 * z * z - 0.247708 );
|
|
116
|
+
result += c7 * 2.0 * 0.429043 * x * z;
|
|
117
|
+
result += c8 * 0.429043 * ( x * x - y * y );
|
|
118
|
+
|
|
119
|
+
gl_FragColor = vec4( max( result, vec3( 0.0 ) ), 1.0 );
|
|
120
|
+
|
|
121
|
+
#include <tonemapping_fragment>
|
|
122
|
+
#include <colorspace_fragment>
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
`
|
|
127
|
+
|
|
128
|
+
} );
|
|
129
|
+
|
|
130
|
+
const res = probes.resolution;
|
|
131
|
+
const count = res.x * res.y * res.z;
|
|
132
|
+
|
|
133
|
+
super( geometry, material, count );
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The probe grid to visualize.
|
|
137
|
+
*
|
|
138
|
+
* @type {LightProbeGrid}
|
|
139
|
+
*/
|
|
140
|
+
this.probes = probes;
|
|
141
|
+
|
|
142
|
+
this.type = 'LightProbeGridHelper';
|
|
143
|
+
|
|
144
|
+
this.update();
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Rebuilds instance matrices and UVW attributes from the current probe grid.
|
|
150
|
+
* Call this after changing `probes` or after re-baking.
|
|
151
|
+
*/
|
|
152
|
+
update() {
|
|
153
|
+
|
|
154
|
+
const probes = this.probes;
|
|
155
|
+
const res = probes.resolution;
|
|
156
|
+
const count = res.x * res.y * res.z;
|
|
157
|
+
|
|
158
|
+
// Resize instance matrix buffer if needed
|
|
159
|
+
|
|
160
|
+
if ( this.instanceMatrix.count !== count ) {
|
|
161
|
+
|
|
162
|
+
this.instanceMatrix = new InstancedBufferAttribute( new Float32Array( count * 16 ), 16 );
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.count = count;
|
|
167
|
+
|
|
168
|
+
const uvwArray = new Float32Array( count * 3 );
|
|
169
|
+
const matrix = new Matrix4();
|
|
170
|
+
const probePos = new Vector3();
|
|
171
|
+
|
|
172
|
+
let i = 0;
|
|
173
|
+
|
|
174
|
+
for ( let iz = 0; iz < res.z; iz ++ ) {
|
|
175
|
+
|
|
176
|
+
for ( let iy = 0; iy < res.y; iy ++ ) {
|
|
177
|
+
|
|
178
|
+
for ( let ix = 0; ix < res.x; ix ++ ) {
|
|
179
|
+
|
|
180
|
+
// Remap to texel centers (must match lightprobes_pars_fragment.glsl.js)
|
|
181
|
+
uvwArray[ i * 3 ] = ( ix + 0.5 ) / res.x;
|
|
182
|
+
uvwArray[ i * 3 + 1 ] = ( iy + 0.5 ) / res.y;
|
|
183
|
+
uvwArray[ i * 3 + 2 ] = ( iz + 0.5 ) / res.z;
|
|
184
|
+
|
|
185
|
+
probes.getProbePosition( ix, iy, iz, probePos );
|
|
186
|
+
matrix.makeTranslation( probePos.x, probePos.y, probePos.z );
|
|
187
|
+
this.setMatrixAt( i, matrix );
|
|
188
|
+
|
|
189
|
+
i ++;
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this.instanceMatrix.needsUpdate = true;
|
|
198
|
+
|
|
199
|
+
this.geometry.setAttribute( 'instanceUVW', new InstancedBufferAttribute( uvwArray, 3 ) );
|
|
200
|
+
|
|
201
|
+
// Update texture uniforms
|
|
202
|
+
|
|
203
|
+
this.material.uniforms.probesSH.value = probes.texture;
|
|
204
|
+
this.material.uniforms.probesResolution.value.copy( probes.resolution );
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Frees the GPU-related resources allocated by this instance. Call this
|
|
210
|
+
* method whenever this instance is no longer used in your app.
|
|
211
|
+
*/
|
|
212
|
+
dispose() {
|
|
213
|
+
|
|
214
|
+
this.geometry.dispose();
|
|
215
|
+
this.material.dispose();
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export { LightProbeGridHelper };
|
|
@@ -2,35 +2,15 @@
|
|
|
2
2
|
import { RendererInspector } from './RendererInspector.js';
|
|
3
3
|
import { Profiler } from './ui/Profiler.js';
|
|
4
4
|
import { Performance } from './tabs/Performance.js';
|
|
5
|
+
import { Memory } from './tabs/Memory.js';
|
|
5
6
|
import { Console } from './tabs/Console.js';
|
|
6
7
|
import { Parameters } from './tabs/Parameters.js';
|
|
8
|
+
import { Settings } from './tabs/Settings.js';
|
|
7
9
|
import { Viewer } from './tabs/Viewer.js';
|
|
8
|
-
import {
|
|
10
|
+
import { Timeline } from './tabs/Timeline.js';
|
|
11
|
+
import { setText } from './ui/utils.js';
|
|
9
12
|
|
|
10
|
-
import {
|
|
11
|
-
import { renderOutput, vec2, vec3, vec4, Fn, screenUV, step, OnMaterialUpdate, uniform } from 'three/tsl';
|
|
12
|
-
|
|
13
|
-
const aspectRatioUV = /*@__PURE__*/ Fn( ( [ uv, textureNode ] ) => {
|
|
14
|
-
|
|
15
|
-
const aspect = uniform( 0 );
|
|
16
|
-
|
|
17
|
-
OnMaterialUpdate( () => {
|
|
18
|
-
|
|
19
|
-
const { width, height } = textureNode.value;
|
|
20
|
-
|
|
21
|
-
aspect.value = width / height;
|
|
22
|
-
|
|
23
|
-
} );
|
|
24
|
-
|
|
25
|
-
const centered = uv.sub( 0.5 );
|
|
26
|
-
const corrected = vec2( centered.x.div( aspect ), centered.y );
|
|
27
|
-
const finalUV = corrected.add( 0.5 );
|
|
28
|
-
|
|
29
|
-
const inBounds = step( 0.0, finalUV.x ).mul( step( finalUV.x, 1.0 ) ).mul( step( 0.0, finalUV.y ) ).mul( step( finalUV.y, 1.0 ) );
|
|
30
|
-
|
|
31
|
-
return vec3( finalUV, inBounds );
|
|
32
|
-
|
|
33
|
-
} );
|
|
13
|
+
import { setConsoleFunction, REVISION } from 'three/webgpu';
|
|
34
14
|
|
|
35
15
|
class Inspector extends RendererInspector {
|
|
36
16
|
|
|
@@ -40,7 +20,8 @@ class Inspector extends RendererInspector {
|
|
|
40
20
|
|
|
41
21
|
// init profiler
|
|
42
22
|
|
|
43
|
-
const profiler = new Profiler();
|
|
23
|
+
const profiler = new Profiler( this );
|
|
24
|
+
profiler.addEventListener( 'resize', ( e ) => this.dispatchEvent( e ) );
|
|
44
25
|
|
|
45
26
|
const parameters = new Parameters( {
|
|
46
27
|
builtin: true,
|
|
@@ -56,9 +37,18 @@ class Inspector extends RendererInspector {
|
|
|
56
37
|
const performance = new Performance();
|
|
57
38
|
profiler.addTab( performance );
|
|
58
39
|
|
|
40
|
+
const memory = new Memory();
|
|
41
|
+
profiler.addTab( memory );
|
|
42
|
+
|
|
43
|
+
const timeline = new Timeline();
|
|
44
|
+
profiler.addTab( timeline );
|
|
45
|
+
|
|
59
46
|
const consoleTab = new Console();
|
|
60
47
|
profiler.addTab( consoleTab );
|
|
61
48
|
|
|
49
|
+
const settings = new Settings();
|
|
50
|
+
profiler.addTab( settings );
|
|
51
|
+
|
|
62
52
|
profiler.loadLayout();
|
|
63
53
|
|
|
64
54
|
if ( ! profiler.activeTabId ) {
|
|
@@ -68,13 +58,16 @@ class Inspector extends RendererInspector {
|
|
|
68
58
|
}
|
|
69
59
|
|
|
70
60
|
this.statsData = new Map();
|
|
71
|
-
this.canvasNodes = new Map();
|
|
72
61
|
this.profiler = profiler;
|
|
73
62
|
this.performance = performance;
|
|
63
|
+
this.memory = memory;
|
|
74
64
|
this.console = consoleTab;
|
|
75
65
|
this.parameters = parameters;
|
|
76
66
|
this.viewer = viewer;
|
|
67
|
+
this.timeline = timeline;
|
|
68
|
+
this.settings = settings;
|
|
77
69
|
this.once = {};
|
|
70
|
+
this.extensionsData = new WeakMap();
|
|
78
71
|
|
|
79
72
|
this.displayCycle = {
|
|
80
73
|
text: {
|
|
@@ -97,6 +90,84 @@ class Inspector extends RendererInspector {
|
|
|
97
90
|
|
|
98
91
|
}
|
|
99
92
|
|
|
93
|
+
onExtension( name, callback ) {
|
|
94
|
+
|
|
95
|
+
const extensionAdded = ( e ) => {
|
|
96
|
+
|
|
97
|
+
if ( e.name === name ) {
|
|
98
|
+
|
|
99
|
+
callback( e.tab );
|
|
100
|
+
|
|
101
|
+
this.settings.removeEventListener( 'extensionadded', extensionAdded );
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
if ( this.settings.extensions[ name ] && this.settings.extensions[ name ].loaded ) {
|
|
108
|
+
|
|
109
|
+
callback( this.settings.extensions[ name ] );
|
|
110
|
+
|
|
111
|
+
} else {
|
|
112
|
+
|
|
113
|
+
this.settings.addEventListener( 'extensionadded', extensionAdded );
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return this;
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
hide() {
|
|
122
|
+
|
|
123
|
+
this.profiler.hide();
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
show() {
|
|
128
|
+
|
|
129
|
+
this.profiler.show();
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getSize() {
|
|
134
|
+
|
|
135
|
+
return this.profiler.getSize();
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
setActiveTab( tab ) {
|
|
140
|
+
|
|
141
|
+
this.profiler.setActiveTab( tab.id );
|
|
142
|
+
|
|
143
|
+
return this;
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
addTab( tab ) {
|
|
148
|
+
|
|
149
|
+
this.profiler.addTab( tab );
|
|
150
|
+
|
|
151
|
+
return this;
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
removeTab( tab ) {
|
|
156
|
+
|
|
157
|
+
this.profiler.removeTab( tab );
|
|
158
|
+
|
|
159
|
+
return this;
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setActiveExtension( name, value ) {
|
|
164
|
+
|
|
165
|
+
this.settings.setActiveExtension( name, value );
|
|
166
|
+
|
|
167
|
+
return this;
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
100
171
|
resolveConsoleOnce( type, message ) {
|
|
101
172
|
|
|
102
173
|
const key = type + message;
|
|
@@ -210,6 +281,8 @@ class Inspector extends RendererInspector {
|
|
|
210
281
|
|
|
211
282
|
} );
|
|
212
283
|
|
|
284
|
+
this.timeline.setRenderer( renderer );
|
|
285
|
+
|
|
213
286
|
}
|
|
214
287
|
|
|
215
288
|
}
|
|
@@ -224,12 +297,6 @@ class Inspector extends RendererInspector {
|
|
|
224
297
|
|
|
225
298
|
this.parameters.show();
|
|
226
299
|
|
|
227
|
-
if ( this.parameters.isDetached === false ) {
|
|
228
|
-
|
|
229
|
-
this.profiler.setActiveTab( this.parameters.id );
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
300
|
}
|
|
234
301
|
|
|
235
302
|
return this.parameters.createGroup( name );
|
|
@@ -298,115 +365,62 @@ class Inspector extends RendererInspector {
|
|
|
298
365
|
|
|
299
366
|
}
|
|
300
367
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
let canvasData = this.canvasNodes.get( node );
|
|
368
|
+
getNodes() {
|
|
304
369
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const renderer = this.getRenderer();
|
|
308
|
-
|
|
309
|
-
const canvas = document.createElement( 'canvas' );
|
|
310
|
-
|
|
311
|
-
const canvasTarget = new CanvasTarget( canvas );
|
|
312
|
-
canvasTarget.setPixelRatio( window.devicePixelRatio );
|
|
313
|
-
canvasTarget.setSize( 140, 140 );
|
|
314
|
-
|
|
315
|
-
const id = node.id;
|
|
316
|
-
|
|
317
|
-
const { path, name } = splitPath( splitCamelCase( node.getName() || '(unnamed)' ) );
|
|
318
|
-
|
|
319
|
-
const target = node.context( { getUV: ( textureNode ) => {
|
|
320
|
-
|
|
321
|
-
const uvData = aspectRatioUV( screenUV, textureNode );
|
|
322
|
-
const correctedUV = uvData.xy;
|
|
323
|
-
const mask = uvData.z;
|
|
324
|
-
|
|
325
|
-
return correctedUV.mul( mask );
|
|
326
|
-
|
|
327
|
-
} } );
|
|
328
|
-
|
|
329
|
-
let output = vec4( vec3( target ), 1 );
|
|
330
|
-
output = renderOutput( output, NoToneMapping, renderer.outputColorSpace );
|
|
331
|
-
output = output.context( { inspector: true } );
|
|
332
|
-
|
|
333
|
-
const material = new NodeMaterial();
|
|
334
|
-
material.outputNode = output;
|
|
335
|
-
|
|
336
|
-
const quad = new QuadMesh( material );
|
|
337
|
-
quad.name = 'Viewer - ' + name;
|
|
338
|
-
|
|
339
|
-
canvasData = {
|
|
340
|
-
id,
|
|
341
|
-
name,
|
|
342
|
-
path,
|
|
343
|
-
node,
|
|
344
|
-
quad,
|
|
345
|
-
canvasTarget,
|
|
346
|
-
material
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
this.canvasNodes.set( node, canvasData );
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return canvasData;
|
|
370
|
+
return this.currentNodes;
|
|
354
371
|
|
|
355
372
|
}
|
|
356
373
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const nodes = this.currentNodes;
|
|
360
|
-
const renderer = this.getRenderer();
|
|
374
|
+
getAverageDeltaTime( statsData, property, frames = this.fps ) {
|
|
361
375
|
|
|
362
|
-
|
|
376
|
+
const statsArray = statsData.stats;
|
|
363
377
|
|
|
364
|
-
|
|
378
|
+
let sum = 0;
|
|
379
|
+
let count = 0;
|
|
365
380
|
|
|
366
|
-
|
|
381
|
+
for ( let i = statsArray.length - 1; i >= 0 && count < frames; i -- ) {
|
|
367
382
|
|
|
368
|
-
|
|
383
|
+
const stats = statsArray[ i ];
|
|
384
|
+
const value = stats[ property ];
|
|
369
385
|
|
|
370
|
-
|
|
386
|
+
if ( value > 0 ) {
|
|
371
387
|
|
|
372
|
-
|
|
388
|
+
// ignore invalid values
|
|
373
389
|
|
|
374
|
-
|
|
390
|
+
sum += value;
|
|
391
|
+
count ++;
|
|
375
392
|
|
|
376
|
-
|
|
393
|
+
}
|
|
377
394
|
|
|
378
395
|
}
|
|
379
396
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
this.viewer.update( renderer, canvasDataList );
|
|
397
|
+
return count > 0 ? sum / count : 0;
|
|
383
398
|
|
|
384
399
|
}
|
|
385
400
|
|
|
386
|
-
|
|
401
|
+
updateTabs() {
|
|
387
402
|
|
|
388
|
-
|
|
403
|
+
// tabs
|
|
389
404
|
|
|
390
|
-
|
|
391
|
-
let count = 0;
|
|
405
|
+
const tabs = Object.values( this.profiler.tabs );
|
|
392
406
|
|
|
393
|
-
for (
|
|
407
|
+
for ( const tab of tabs ) {
|
|
394
408
|
|
|
395
|
-
|
|
396
|
-
const value = stats[ property ];
|
|
409
|
+
let tabData = this.extensionsData.get( tab );
|
|
397
410
|
|
|
398
|
-
if (
|
|
411
|
+
if ( tabData === undefined ) {
|
|
399
412
|
|
|
400
|
-
|
|
413
|
+
tab.init( this );
|
|
401
414
|
|
|
402
|
-
|
|
403
|
-
|
|
415
|
+
tabData = {};
|
|
416
|
+
|
|
417
|
+
this.extensionsData.set( tab, tabData );
|
|
404
418
|
|
|
405
419
|
}
|
|
406
420
|
|
|
407
|
-
|
|
421
|
+
tab.update( this );
|
|
408
422
|
|
|
409
|
-
|
|
423
|
+
}
|
|
410
424
|
|
|
411
425
|
}
|
|
412
426
|
|
|
@@ -455,12 +469,14 @@ class Inspector extends RendererInspector {
|
|
|
455
469
|
setText( 'fps-counter', this.fps.toFixed() );
|
|
456
470
|
|
|
457
471
|
this.performance.updateText( this, frame );
|
|
472
|
+
this.memory.updateText( this );
|
|
458
473
|
|
|
459
474
|
}
|
|
460
475
|
|
|
461
476
|
if ( this.displayCycle.graph.needsUpdate ) {
|
|
462
477
|
|
|
463
478
|
this.performance.updateGraph( this, frame );
|
|
479
|
+
this.memory.updateGraph( this );
|
|
464
480
|
|
|
465
481
|
}
|
|
466
482
|
|
|
@@ -482,6 +498,45 @@ class Inspector extends RendererInspector {
|
|
|
482
498
|
|
|
483
499
|
}
|
|
484
500
|
|
|
501
|
+
static getItem( id ) {
|
|
502
|
+
|
|
503
|
+
console.warn( 'Inspector.getItem is deprecated. Use getItem directly instead.' );
|
|
504
|
+
return getItem( id );
|
|
505
|
+
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
static setItem( id, state ) {
|
|
509
|
+
|
|
510
|
+
console.warn( 'Inspector.setItem is deprecated. Use setItem directly instead.' );
|
|
511
|
+
setItem( id, state );
|
|
512
|
+
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function getItem( id ) {
|
|
518
|
+
|
|
519
|
+
const data = JSON.parse( localStorage.getItem( 'threejs-inspector' ) || '{}' );
|
|
520
|
+
return data[ id ] || {};
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function setItem( id, state ) {
|
|
525
|
+
|
|
526
|
+
const data = JSON.parse( localStorage.getItem( 'threejs-inspector' ) || '{}' );
|
|
527
|
+
|
|
528
|
+
if ( state === null ) {
|
|
529
|
+
|
|
530
|
+
delete data[ id ];
|
|
531
|
+
|
|
532
|
+
} else {
|
|
533
|
+
|
|
534
|
+
data[ id ] = state;
|
|
535
|
+
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
localStorage.setItem( 'threejs-inspector', JSON.stringify( data ) );
|
|
539
|
+
|
|
485
540
|
}
|
|
486
541
|
|
|
487
|
-
export { Inspector };
|
|
542
|
+
export { Inspector, getItem, setItem };
|
|
@@ -173,7 +173,7 @@ export class RendererInspector extends InspectorBase {
|
|
|
173
173
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
updateTabs() { }
|
|
177
177
|
|
|
178
178
|
resolveFrame( /*frame*/ ) { }
|
|
179
179
|
|
|
@@ -321,7 +321,7 @@ export class RendererInspector extends InspectorBase {
|
|
|
321
321
|
|
|
322
322
|
if ( this.isAvailable ) {
|
|
323
323
|
|
|
324
|
-
this.
|
|
324
|
+
this.updateTabs();
|
|
325
325
|
this.resolveTimestamp();
|
|
326
326
|
|
|
327
327
|
}
|