@plastic-software/three 0.183.4 → 0.184.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 +773 -286
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +426 -180
- 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 +19 -3
- 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,281 @@
|
|
|
1
|
+
import { FileLoader, error } from 'three';
|
|
2
|
+
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import * as TSL from 'three/tsl';
|
|
5
|
+
|
|
6
|
+
const _library = {
|
|
7
|
+
'three/tsl': { ...TSL }
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const STORAGE_PREFIX = 'tsl-graph';
|
|
11
|
+
const STORAGE_CODE = 'tsl-graph-code';
|
|
12
|
+
|
|
13
|
+
function _storageKey( graphId ) {
|
|
14
|
+
|
|
15
|
+
return `${STORAGE_PREFIX}:${graphId}`;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class TSLGraphLoaderApplier {
|
|
20
|
+
|
|
21
|
+
constructor( tslGraphFns ) {
|
|
22
|
+
|
|
23
|
+
this.tslGraphFns = tslGraphFns;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
apply( scene ) {
|
|
28
|
+
|
|
29
|
+
const tslGraphFns = this.tslGraphFns;
|
|
30
|
+
|
|
31
|
+
scene.traverse( ( object ) => {
|
|
32
|
+
|
|
33
|
+
if ( object.material && object.material.userData.graphId ) {
|
|
34
|
+
|
|
35
|
+
if ( tslGraphFns[ object.material.userData.graphId ] ) {
|
|
36
|
+
|
|
37
|
+
tslGraphFns[ object.material.userData.graphId ]( object.material );
|
|
38
|
+
|
|
39
|
+
object.material.needsUpdate = true;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class TSLGraphLoader extends FileLoader {
|
|
52
|
+
|
|
53
|
+
constructor( manager ) {
|
|
54
|
+
|
|
55
|
+
super( manager );
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
load( url, onLoad, onProgress, onError ) {
|
|
60
|
+
|
|
61
|
+
super.load( url, ( text ) => {
|
|
62
|
+
|
|
63
|
+
let json;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
|
|
67
|
+
json = JSON.parse( text );
|
|
68
|
+
|
|
69
|
+
} catch ( e ) {
|
|
70
|
+
|
|
71
|
+
if ( onError ) onError( e );
|
|
72
|
+
|
|
73
|
+
return;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const applier = this.parse( json );
|
|
78
|
+
|
|
79
|
+
if ( onLoad ) onLoad( applier );
|
|
80
|
+
|
|
81
|
+
}, onProgress, onError );
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
parseMaterial( json ) {
|
|
86
|
+
|
|
87
|
+
const baseFn = 'tslGraph';
|
|
88
|
+
|
|
89
|
+
const imports = {};
|
|
90
|
+
const materials = [ this._generateMaterialCode( json, baseFn, imports ) ];
|
|
91
|
+
const code = this._generateCode( materials, imports );
|
|
92
|
+
|
|
93
|
+
const tslFunction = new Function( code )()( THREE, imports );
|
|
94
|
+
|
|
95
|
+
return tslFunction;
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
parseMaterials( json ) {
|
|
100
|
+
|
|
101
|
+
const imports = {};
|
|
102
|
+
const materials = [];
|
|
103
|
+
|
|
104
|
+
for ( const [ name, material ] of Object.entries( json ) ) {
|
|
105
|
+
|
|
106
|
+
materials.push( this._generateMaterialCode( material, name, imports ) );
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const code = this._generateCode( materials, imports );
|
|
111
|
+
|
|
112
|
+
const tslFunction = new Function( code )()( THREE, imports );
|
|
113
|
+
|
|
114
|
+
return tslFunction;
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
parse( json ) {
|
|
119
|
+
|
|
120
|
+
let result;
|
|
121
|
+
|
|
122
|
+
if ( json.material && json.material.code ) {
|
|
123
|
+
|
|
124
|
+
result = this.parseMaterial( json.material );
|
|
125
|
+
|
|
126
|
+
} else if ( json.materials ) {
|
|
127
|
+
|
|
128
|
+
result = this.parseMaterials( json.materials );
|
|
129
|
+
|
|
130
|
+
} else if ( json.codes && json.graphs ) {
|
|
131
|
+
|
|
132
|
+
result = this.parseMaterials( json.codes.materials );
|
|
133
|
+
|
|
134
|
+
TSLGraphLoader.setGraphs( json );
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return new TSLGraphLoaderApplier( result );
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
_generateMaterialCode( json, name = 'tslGraph', imports = {} ) {
|
|
143
|
+
|
|
144
|
+
const code = json.code.replace( 'function tslGraph', `materials[ '${ name }' ] = function` ).replace( /\n|^/g, '\n\t' );
|
|
145
|
+
|
|
146
|
+
for ( const importData of json.imports ) {
|
|
147
|
+
|
|
148
|
+
if ( _library[ importData.from ] ) {
|
|
149
|
+
|
|
150
|
+
for ( const importName of importData.imports ) {
|
|
151
|
+
|
|
152
|
+
if ( _library[ importData.from ][ importName ] ) {
|
|
153
|
+
|
|
154
|
+
imports[ importName ] = _library[ importData.from ][ importName ];
|
|
155
|
+
|
|
156
|
+
} else {
|
|
157
|
+
|
|
158
|
+
error( `TSLGraph: Import ${ importName } not found in ${ importData.from }.` );
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
} else {
|
|
165
|
+
|
|
166
|
+
error( `TSLGraph: Library ${ importData.from } not found.` );
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return code;
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
_generateCode( materials, imports ) {
|
|
177
|
+
|
|
178
|
+
const fnCode = `return ( THREE, { ${ Object.keys( imports ).join( ', ' ) } } ) => {\n\n\tconst materials = {};\n${ materials.join( '\n' ) }\n\n\treturn materials;\n\n}`;
|
|
179
|
+
|
|
180
|
+
return fnCode;
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static get hasGraphs() {
|
|
185
|
+
|
|
186
|
+
return Object.keys( TSLGraphLoader.getCodes().materials ).length > 0;
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static getCodes() {
|
|
191
|
+
|
|
192
|
+
const code = window.localStorage.getItem( STORAGE_CODE );
|
|
193
|
+
|
|
194
|
+
return code ? JSON.parse( code ) : { materials: {} };
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static setCodes( codes ) {
|
|
199
|
+
|
|
200
|
+
window.localStorage.setItem( STORAGE_CODE, JSON.stringify( codes ) );
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
static setGraph( graphId, graphData ) {
|
|
205
|
+
|
|
206
|
+
window.localStorage.setItem( _storageKey( graphId ), JSON.stringify( graphData ) );
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static getGraph( graphId ) {
|
|
211
|
+
|
|
212
|
+
const raw = window.localStorage.getItem( _storageKey( graphId ) );
|
|
213
|
+
|
|
214
|
+
if ( ! raw ) return null;
|
|
215
|
+
|
|
216
|
+
try {
|
|
217
|
+
|
|
218
|
+
return JSON.parse( raw );
|
|
219
|
+
|
|
220
|
+
} catch ( e ) {
|
|
221
|
+
|
|
222
|
+
error( 'TSLGraph: Invalid graph JSON in localStorage, ignoring.', e );
|
|
223
|
+
return null;
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
static deleteGraph( graphId ) {
|
|
230
|
+
|
|
231
|
+
window.localStorage.removeItem( _storageKey( graphId ) );
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static setGraphs( json ) {
|
|
236
|
+
|
|
237
|
+
if ( ! json.codes || ! json.graphs ) {
|
|
238
|
+
|
|
239
|
+
throw new Error( 'TSLGraph: Invalid import file structure.' );
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
TSLGraphLoader.clearGraphs();
|
|
244
|
+
|
|
245
|
+
// Save imported graph visualizations
|
|
246
|
+
for ( const [ id, graphData ] of Object.entries( json.graphs ) ) {
|
|
247
|
+
|
|
248
|
+
TSLGraphLoader.setGraph( id, graphData );
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Fully overwrite codes
|
|
253
|
+
TSLGraphLoader.setCodes( json.codes );
|
|
254
|
+
|
|
255
|
+
return json;
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static clearGraphs() {
|
|
260
|
+
|
|
261
|
+
const keysToRemove = [];
|
|
262
|
+
for ( let i = 0; i < window.localStorage.length; i ++ ) {
|
|
263
|
+
|
|
264
|
+
const key = window.localStorage.key( i );
|
|
265
|
+
if ( key.startsWith( STORAGE_PREFIX ) ) {
|
|
266
|
+
|
|
267
|
+
keysToRemove.push( key );
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
for ( const key of keysToRemove ) {
|
|
274
|
+
|
|
275
|
+
window.localStorage.removeItem( key );
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Tab } from '../ui/Tab.js';
|
|
2
|
+
import { List } from '../ui/List.js';
|
|
3
|
+
import { Graph } from '../ui/Graph.js';
|
|
4
|
+
import { Item } from '../ui/Item.js';
|
|
5
|
+
import { createValueSpan, setText, formatBytes } from '../ui/utils.js';
|
|
6
|
+
|
|
7
|
+
class Memory extends Tab {
|
|
8
|
+
|
|
9
|
+
constructor( options = {} ) {
|
|
10
|
+
|
|
11
|
+
super( 'Memory', options );
|
|
12
|
+
|
|
13
|
+
const memoryList = new List( 'Name', 'Count', 'Size' );
|
|
14
|
+
memoryList.setGridStyle( 'minmax(200px, 2fr) 60px 100px' );
|
|
15
|
+
memoryList.domElement.style.minWidth = '300px';
|
|
16
|
+
|
|
17
|
+
const scrollWrapper = document.createElement( 'div' );
|
|
18
|
+
scrollWrapper.className = 'list-scroll-wrapper';
|
|
19
|
+
scrollWrapper.appendChild( memoryList.domElement );
|
|
20
|
+
this.content.appendChild( scrollWrapper );
|
|
21
|
+
|
|
22
|
+
// graph
|
|
23
|
+
|
|
24
|
+
const graphContainer = document.createElement( 'div' );
|
|
25
|
+
graphContainer.className = 'graph-container';
|
|
26
|
+
|
|
27
|
+
const graph = new Graph();
|
|
28
|
+
graph.addLine( 'total', 'var( --color-yellow )' );
|
|
29
|
+
graphContainer.append( graph.domElement );
|
|
30
|
+
|
|
31
|
+
// stats
|
|
32
|
+
|
|
33
|
+
const graphStats = new Item( 'Graph Stats', '', '' );
|
|
34
|
+
memoryList.add( graphStats );
|
|
35
|
+
|
|
36
|
+
const graphItem = new Item( graphContainer );
|
|
37
|
+
graphItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';
|
|
38
|
+
graphStats.add( graphItem );
|
|
39
|
+
|
|
40
|
+
// info
|
|
41
|
+
|
|
42
|
+
this.memoryStats = new Item( 'Renderer Info', '', createValueSpan() );
|
|
43
|
+
this.memoryStats.domElement.firstChild.classList.add( 'no-hover' );
|
|
44
|
+
memoryList.add( this.memoryStats );
|
|
45
|
+
|
|
46
|
+
this.attributes = new Item( 'Attributes', createValueSpan(), createValueSpan() );
|
|
47
|
+
this.memoryStats.add( this.attributes );
|
|
48
|
+
|
|
49
|
+
this.geometries = new Item( 'Geometries', createValueSpan(), 'N/A' );
|
|
50
|
+
this.memoryStats.add( this.geometries );
|
|
51
|
+
|
|
52
|
+
this.indexAttributes = new Item( 'Index Attributes', createValueSpan(), createValueSpan() );
|
|
53
|
+
this.memoryStats.add( this.indexAttributes );
|
|
54
|
+
|
|
55
|
+
this.indirectStorageAttributes = new Item( 'Indirect Storage Attributes', createValueSpan(), createValueSpan() );
|
|
56
|
+
this.memoryStats.add( this.indirectStorageAttributes );
|
|
57
|
+
|
|
58
|
+
this.programs = new Item( 'Programs', createValueSpan(), createValueSpan() );
|
|
59
|
+
this.memoryStats.add( this.programs );
|
|
60
|
+
|
|
61
|
+
this.readbackBuffers = new Item( 'Readback Buffers', createValueSpan(), createValueSpan() );
|
|
62
|
+
this.memoryStats.add( this.readbackBuffers );
|
|
63
|
+
|
|
64
|
+
this.renderTargets = new Item( 'Render Targets', createValueSpan(), 'N/A' );
|
|
65
|
+
this.memoryStats.add( this.renderTargets );
|
|
66
|
+
|
|
67
|
+
this.storageAttributes = new Item( 'Storage Attributes', createValueSpan(), createValueSpan() );
|
|
68
|
+
this.memoryStats.add( this.storageAttributes );
|
|
69
|
+
|
|
70
|
+
this.textures = new Item( 'Textures', createValueSpan(), createValueSpan() );
|
|
71
|
+
this.memoryStats.add( this.textures );
|
|
72
|
+
|
|
73
|
+
this.graph = graph;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
updateGraph( inspector ) {
|
|
78
|
+
|
|
79
|
+
const renderer = inspector.getRenderer();
|
|
80
|
+
if ( ! renderer ) return;
|
|
81
|
+
|
|
82
|
+
const memory = renderer.info.memory;
|
|
83
|
+
|
|
84
|
+
this.graph.addPoint( 'total', memory.total );
|
|
85
|
+
|
|
86
|
+
if ( this.graph.limit === 0 ) this.graph.limit = 1;
|
|
87
|
+
|
|
88
|
+
this.graph.update();
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
updateText( inspector ) {
|
|
93
|
+
|
|
94
|
+
const renderer = inspector.getRenderer();
|
|
95
|
+
if ( ! renderer ) return;
|
|
96
|
+
|
|
97
|
+
const memory = renderer.info.memory;
|
|
98
|
+
|
|
99
|
+
setText( this.memoryStats.data[ 2 ], formatBytes( memory.total ) );
|
|
100
|
+
|
|
101
|
+
setText( this.attributes.data[ 1 ], memory.attributes.toString() );
|
|
102
|
+
setText( this.attributes.data[ 2 ], formatBytes( memory.attributesSize ) );
|
|
103
|
+
setText( this.geometries.data[ 1 ], memory.geometries.toString() );
|
|
104
|
+
|
|
105
|
+
setText( this.indexAttributes.data[ 1 ], memory.indexAttributes.toString() );
|
|
106
|
+
setText( this.indexAttributes.data[ 2 ], formatBytes( memory.indexAttributesSize ) );
|
|
107
|
+
|
|
108
|
+
setText( this.indirectStorageAttributes.data[ 1 ], memory.indirectStorageAttributes.toString() );
|
|
109
|
+
setText( this.indirectStorageAttributes.data[ 2 ], formatBytes( memory.indirectStorageAttributesSize ) );
|
|
110
|
+
|
|
111
|
+
setText( this.programs.data[ 1 ], memory.programs.toString() );
|
|
112
|
+
setText( this.programs.data[ 2 ], formatBytes( memory.programsSize ) );
|
|
113
|
+
|
|
114
|
+
setText( this.readbackBuffers.data[ 1 ], memory.readbackBuffers.toString() );
|
|
115
|
+
setText( this.readbackBuffers.data[ 2 ], formatBytes( memory.readbackBuffersSize ) );
|
|
116
|
+
|
|
117
|
+
setText( this.renderTargets.data[ 1 ], memory.renderTargets.toString() );
|
|
118
|
+
|
|
119
|
+
setText( this.storageAttributes.data[ 1 ], memory.storageAttributes.toString() );
|
|
120
|
+
setText( this.storageAttributes.data[ 2 ], formatBytes( memory.storageAttributesSize ) );
|
|
121
|
+
setText( this.textures.data[ 1 ], memory.textures.toString() );
|
|
122
|
+
setText( this.textures.data[ 2 ], formatBytes( memory.texturesSize ) );
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { Memory };
|
|
@@ -2,7 +2,7 @@ import { Tab } from '../ui/Tab.js';
|
|
|
2
2
|
import { List } from '../ui/List.js';
|
|
3
3
|
import { Item } from '../ui/Item.js';
|
|
4
4
|
import { createValueSpan } from '../ui/utils.js';
|
|
5
|
-
import { ValueNumber, ValueSlider, ValueSelect, ValueCheckbox, ValueColor, ValueButton } from '../ui/Values.js';
|
|
5
|
+
import { ValueString, ValueNumber, ValueSlider, ValueSelect, ValueCheckbox, ValueColor, ValueButton } from '../ui/Values.js';
|
|
6
6
|
|
|
7
7
|
class ParametersGroup {
|
|
8
8
|
|
|
@@ -52,6 +52,10 @@ class ParametersGroup {
|
|
|
52
52
|
|
|
53
53
|
item = this.addBoolean( object, property );
|
|
54
54
|
|
|
55
|
+
} else if ( type === 'string' ) {
|
|
56
|
+
|
|
57
|
+
item = this.addString( object, property );
|
|
58
|
+
|
|
55
59
|
} else if ( type === 'function' ) {
|
|
56
60
|
|
|
57
61
|
item = this.addButton( object, property, ...params );
|
|
@@ -106,6 +110,34 @@ class ParametersGroup {
|
|
|
106
110
|
|
|
107
111
|
}
|
|
108
112
|
|
|
113
|
+
addString( object, property ) {
|
|
114
|
+
|
|
115
|
+
const value = object[ property ];
|
|
116
|
+
|
|
117
|
+
const editor = new ValueString( { value } );
|
|
118
|
+
editor.addEventListener( 'change', ( { value } ) => {
|
|
119
|
+
|
|
120
|
+
object[ property ] = value;
|
|
121
|
+
|
|
122
|
+
} );
|
|
123
|
+
|
|
124
|
+
const description = createValueSpan();
|
|
125
|
+
description.textContent = property;
|
|
126
|
+
|
|
127
|
+
const subItem = new Item( description, editor.domElement );
|
|
128
|
+
this.paramList.add( subItem );
|
|
129
|
+
|
|
130
|
+
const itemRow = subItem.domElement.firstChild;
|
|
131
|
+
itemRow.classList.add( 'actionable' );
|
|
132
|
+
|
|
133
|
+
// extend object property
|
|
134
|
+
|
|
135
|
+
this._addParameter( object, property, editor, subItem );
|
|
136
|
+
|
|
137
|
+
return editor;
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
109
141
|
addFolder( name ) {
|
|
110
142
|
|
|
111
143
|
const group = new ParametersGroup( this.parameters, name );
|
|
@@ -314,7 +346,7 @@ class Parameters extends Tab {
|
|
|
314
346
|
|
|
315
347
|
constructor( options = {} ) {
|
|
316
348
|
|
|
317
|
-
super( 'Parameters', options );
|
|
349
|
+
super( options.name || 'Parameters', options );
|
|
318
350
|
|
|
319
351
|
const paramList = new List( 'Property', 'Value' );
|
|
320
352
|
paramList.domElement.classList.add( 'parameters' );
|
|
@@ -25,8 +25,8 @@ class Performance extends Tab {
|
|
|
25
25
|
graphContainer.className = 'graph-container';
|
|
26
26
|
|
|
27
27
|
const graph = new Graph();
|
|
28
|
-
graph.addLine( 'fps', '--
|
|
29
|
-
//graph.addLine( 'gpu', '--color-yellow' );
|
|
28
|
+
graph.addLine( 'fps', 'var( --color-fps )' );
|
|
29
|
+
//graph.addLine( 'gpu', 'var( --color-yellow )' );
|
|
30
30
|
graphContainer.append( graph.domElement );
|
|
31
31
|
|
|
32
32
|
//
|