super-three 0.157.1 → 0.158.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/build/three.cjs +1013 -790
- package/build/three.js +1013 -790
- package/build/three.min.js +1 -1
- package/build/three.module.js +1008 -791
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +290 -0
- package/examples/jsm/controls/FlyControls.js +26 -0
- package/examples/jsm/controls/OrbitControls.js +12 -1
- package/examples/jsm/controls/TransformControls.js +27 -11
- package/examples/jsm/csm/CSMShader.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +72 -2
- package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
- package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
- package/examples/jsm/libs/lottie_canvas.module.js +6 -1
- package/examples/jsm/libs/opentype.module.js +13 -75
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/loaders/GLTFLoader.js +12 -3
- package/examples/jsm/loaders/LUTImageLoader.js +162 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +89 -93
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/Capsule.js +0 -55
- package/examples/jsm/math/Octree.js +70 -3
- package/examples/jsm/modifiers/SimplifyModifier.js +103 -11
- package/examples/jsm/modifiers/TessellateModifier.js +3 -3
- package/examples/jsm/nodes/Nodes.js +6 -6
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstanceNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +68 -31
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -2
- package/examples/jsm/nodes/accessors/MorphNode.js +5 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +13 -3
- package/examples/jsm/nodes/accessors/TextureNode.js +3 -3
- package/examples/jsm/nodes/code/FunctionNode.js +1 -1
- package/examples/jsm/nodes/core/AssignNode.js +72 -0
- package/examples/jsm/nodes/core/LightingModel.js +3 -1
- package/examples/jsm/nodes/core/Node.js +7 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +126 -16
- package/examples/jsm/nodes/core/NodeUtils.js +4 -2
- package/examples/jsm/nodes/core/OutputStructNode.js +1 -1
- package/examples/jsm/nodes/core/ParameterNode.js +33 -0
- package/examples/jsm/nodes/core/PropertyNode.js +4 -10
- package/examples/jsm/nodes/core/StackNode.js +7 -17
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +6 -35
- package/examples/jsm/nodes/core/VaryingNode.js +2 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +35 -13
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportNode.js +14 -4
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +20 -6
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +8 -3
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +8 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +8 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +93 -43
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +19 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -6
- package/examples/jsm/nodes/lighting/LightingContextNode.js +21 -57
- package/examples/jsm/nodes/lighting/LightsNode.js +62 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +1 -1
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +70 -71
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +5 -5
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +47 -20
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/NodeMaterial.js +17 -20
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +5 -5
- package/examples/jsm/nodes/math/OperatorNode.js +5 -21
- package/examples/jsm/nodes/shadernode/ShaderNode.js +128 -9
- package/examples/jsm/nodes/utils/ArrayElementNode.js +2 -0
- package/examples/jsm/nodes/utils/DiscardNode.js +3 -2
- package/examples/jsm/nodes/utils/JoinNode.js +11 -1
- package/examples/jsm/nodes/utils/LoopNode.js +36 -24
- package/examples/jsm/nodes/utils/SplitNode.js +2 -0
- package/examples/jsm/objects/BatchedMesh.js +586 -0
- package/examples/jsm/objects/InstancedPoints.js +21 -0
- package/examples/jsm/objects/Lensflare.js +20 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -0
- package/examples/jsm/objects/Refractor.js +3 -0
- package/examples/jsm/objects/Sky.js +5 -3
- package/examples/jsm/objects/Water.js +5 -2
- package/examples/jsm/objects/Water2.js +3 -0
- package/examples/jsm/physics/AmmoPhysics.js +21 -0
- package/examples/jsm/physics/RapierPhysics.js +21 -0
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/LUTPass.js +2 -1
- package/examples/jsm/postprocessing/OutputPass.js +1 -0
- package/examples/jsm/postprocessing/Pass.js +14 -3
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SMAAPass.js +0 -2
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +3 -9
- package/examples/jsm/renderers/SVGRenderer.js +9 -6
- package/examples/jsm/renderers/common/Bindings.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +8 -1
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +4 -36
- package/examples/jsm/renderers/common/nodes/Nodes.js +53 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +291 -50
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +88 -12
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +40 -5
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +2 -0
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +36 -4
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +2 -0
- package/examples/jsm/shaders/AfterimageShader.js +2 -0
- package/examples/jsm/shaders/BasicShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +2 -0
- package/examples/jsm/shaders/BokehShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +4 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +2 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +2 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +2 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +5 -0
- package/examples/jsm/shaders/FXAAShader.js +2 -0
- package/examples/jsm/shaders/FilmShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +2 -0
- package/examples/jsm/shaders/FreiChenShader.js +2 -0
- package/examples/jsm/shaders/GodRaysShader.js +8 -0
- package/examples/jsm/shaders/HalftoneShader.js +2 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/HueSaturationShader.js +2 -0
- package/examples/jsm/shaders/KaleidoShader.js +2 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +2 -0
- package/examples/jsm/shaders/LuminosityShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +2 -0
- package/examples/jsm/shaders/MirrorShader.js +2 -0
- package/examples/jsm/shaders/NormalMapShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +4 -5
- package/examples/jsm/shaders/SAOShader.js +5 -0
- package/examples/jsm/shaders/SMAAShader.js +6 -0
- package/examples/jsm/shaders/SSAOShader.js +6 -0
- package/examples/jsm/shaders/SSRShader.js +6 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +2 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +2 -0
- package/examples/jsm/shaders/TechnicolorShader.js +2 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +2 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -0
- package/examples/jsm/shaders/VelocityShader.js +2 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +2 -0
- package/examples/jsm/transpiler/AST.js +231 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +899 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
- package/examples/jsm/transpiler/TSLEncoder.js +611 -0
- package/examples/jsm/transpiler/Transpiler.js +18 -0
- package/examples/jsm/webxr/VRButton.js +1 -1
- package/examples/jsm/webxr/XRButton.js +7 -5
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +4 -1
- package/src/constants.js +7 -1
- package/src/extras/PMREMGenerator.js +7 -1
- package/src/loaders/MaterialLoader.js +10 -2
- package/src/materials/Material.js +27 -13
- package/src/math/Box3.js +35 -18
- package/src/math/Vector3.js +11 -12
- package/src/objects/SkinnedMesh.js +6 -7
- package/src/renderers/WebGLRenderer.js +142 -25
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +8 -6
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +80 -50
- package/src/renderers/webgl/WebGLPrograms.js +3 -0
- package/src/renderers/webgl/WebGLState.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -76
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +0 -29
|
@@ -67,6 +67,8 @@ class Water extends Mesh {
|
|
|
67
67
|
|
|
68
68
|
const mirrorShader = {
|
|
69
69
|
|
|
70
|
+
name: 'MirrorShader',
|
|
71
|
+
|
|
70
72
|
uniforms: UniformsUtils.merge( [
|
|
71
73
|
UniformsLib[ 'fog' ],
|
|
72
74
|
UniformsLib[ 'lights' ],
|
|
@@ -188,9 +190,10 @@ class Water extends Mesh {
|
|
|
188
190
|
};
|
|
189
191
|
|
|
190
192
|
const material = new ShaderMaterial( {
|
|
191
|
-
|
|
192
|
-
vertexShader: mirrorShader.vertexShader,
|
|
193
|
+
name: mirrorShader.name,
|
|
193
194
|
uniforms: UniformsUtils.clone( mirrorShader.uniforms ),
|
|
195
|
+
vertexShader: mirrorShader.vertexShader,
|
|
196
|
+
fragmentShader: mirrorShader.fragmentShader,
|
|
194
197
|
lights: true,
|
|
195
198
|
side: side,
|
|
196
199
|
fog: fog
|
|
@@ -88,6 +88,7 @@ class Water extends Mesh {
|
|
|
88
88
|
// material
|
|
89
89
|
|
|
90
90
|
this.material = new ShaderMaterial( {
|
|
91
|
+
name: shader.name,
|
|
91
92
|
uniforms: UniformsUtils.merge( [
|
|
92
93
|
UniformsLib[ 'fog' ],
|
|
93
94
|
shader.uniforms
|
|
@@ -205,6 +206,8 @@ class Water extends Mesh {
|
|
|
205
206
|
|
|
206
207
|
Water.WaterShader = {
|
|
207
208
|
|
|
209
|
+
name: 'WaterShader',
|
|
210
|
+
|
|
208
211
|
uniforms: {
|
|
209
212
|
|
|
210
213
|
'color': {
|
|
@@ -57,6 +57,26 @@ async function AmmoPhysics() {
|
|
|
57
57
|
const meshes = [];
|
|
58
58
|
const meshMap = new WeakMap();
|
|
59
59
|
|
|
60
|
+
function addScene( scene ) {
|
|
61
|
+
|
|
62
|
+
scene.traverse( function ( child ) {
|
|
63
|
+
|
|
64
|
+
if ( child.isMesh ) {
|
|
65
|
+
|
|
66
|
+
const physics = child.userData.physics;
|
|
67
|
+
|
|
68
|
+
if ( physics ) {
|
|
69
|
+
|
|
70
|
+
addMesh( child, physics.mass );
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
60
80
|
function addMesh( mesh, mass = 0 ) {
|
|
61
81
|
|
|
62
82
|
const shape = getShape( mesh.geometry );
|
|
@@ -245,6 +265,7 @@ async function AmmoPhysics() {
|
|
|
245
265
|
setInterval( step, 1000 / frameRate );
|
|
246
266
|
|
|
247
267
|
return {
|
|
268
|
+
addScene: addScene,
|
|
248
269
|
addMesh: addMesh,
|
|
249
270
|
setMeshPosition: setMeshPosition
|
|
250
271
|
// addCompoundMesh
|
|
@@ -55,6 +55,26 @@ async function RapierPhysics() {
|
|
|
55
55
|
const _quaternion = new Quaternion();
|
|
56
56
|
const _matrix = new Matrix4();
|
|
57
57
|
|
|
58
|
+
function addScene( scene ) {
|
|
59
|
+
|
|
60
|
+
scene.traverse( function ( child ) {
|
|
61
|
+
|
|
62
|
+
if ( child.isMesh ) {
|
|
63
|
+
|
|
64
|
+
const physics = child.userData.physics;
|
|
65
|
+
|
|
66
|
+
if ( physics ) {
|
|
67
|
+
|
|
68
|
+
addMesh( child, physics.mass, physics.restitution );
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
} );
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
58
78
|
function addMesh( mesh, mass = 0, restitution = 0 ) {
|
|
59
79
|
|
|
60
80
|
const shape = getCollider( mesh.geometry );
|
|
@@ -189,6 +209,7 @@ async function RapierPhysics() {
|
|
|
189
209
|
setInterval( step, 1000 / frameRate );
|
|
190
210
|
|
|
191
211
|
return {
|
|
212
|
+
addScene: addScene,
|
|
192
213
|
addMesh: addMesh,
|
|
193
214
|
setMeshPosition: setMeshPosition,
|
|
194
215
|
setMeshVelocity: setMeshVelocity
|
|
@@ -26,7 +26,6 @@ class BokehPass extends Pass {
|
|
|
26
26
|
this.camera = camera;
|
|
27
27
|
|
|
28
28
|
const focus = ( params.focus !== undefined ) ? params.focus : 1.0;
|
|
29
|
-
const aspect = ( params.aspect !== undefined ) ? params.aspect : camera.aspect;
|
|
30
29
|
const aperture = ( params.aperture !== undefined ) ? params.aperture : 0.025;
|
|
31
30
|
const maxblur = ( params.maxblur !== undefined ) ? params.maxblur : 1.0;
|
|
32
31
|
|
|
@@ -54,7 +53,7 @@ class BokehPass extends Pass {
|
|
|
54
53
|
bokehUniforms[ 'tDepth' ].value = this.renderTargetDepth.texture;
|
|
55
54
|
|
|
56
55
|
bokehUniforms[ 'focus' ].value = focus;
|
|
57
|
-
bokehUniforms[ 'aspect' ].value = aspect;
|
|
56
|
+
bokehUniforms[ 'aspect' ].value = camera.aspect;
|
|
58
57
|
bokehUniforms[ 'aperture' ].value = aperture;
|
|
59
58
|
bokehUniforms[ 'maxblur' ].value = maxblur;
|
|
60
59
|
bokehUniforms[ 'nearClip' ].value = camera.near;
|
|
@@ -120,6 +119,8 @@ class BokehPass extends Pass {
|
|
|
120
119
|
|
|
121
120
|
setSize( width, height ) {
|
|
122
121
|
|
|
122
|
+
this.materialBokeh.uniforms[ 'aspect' ].value = width / height;
|
|
123
|
+
|
|
123
124
|
this.renderTargetDepth.setSize( width, height );
|
|
124
125
|
|
|
125
126
|
}
|
|
@@ -24,6 +24,7 @@ class OutputPass extends Pass {
|
|
|
24
24
|
this.uniforms = UniformsUtils.clone( shader.uniforms );
|
|
25
25
|
|
|
26
26
|
this.material = new RawShaderMaterial( {
|
|
27
|
+
name: shader.name,
|
|
27
28
|
uniforms: this.uniforms,
|
|
28
29
|
vertexShader: shader.vertexShader,
|
|
29
30
|
fragmentShader: shader.fragmentShader
|
|
@@ -43,9 +43,20 @@ const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
|
43
43
|
|
|
44
44
|
// https://github.com/mrdoob/three.js/pull/21358
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
class FullscreenTriangleGeometry extends BufferGeometry {
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
|
|
50
|
+
super();
|
|
51
|
+
|
|
52
|
+
this.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
|
|
53
|
+
this.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const _geometry = new FullscreenTriangleGeometry();
|
|
49
60
|
|
|
50
61
|
class FullScreenQuad {
|
|
51
62
|
|
|
@@ -314,7 +314,6 @@ class SAOPass extends Pass {
|
|
|
314
314
|
this.blurIntermediateRenderTarget.dispose();
|
|
315
315
|
this.normalRenderTarget.dispose();
|
|
316
316
|
|
|
317
|
-
this.depthMaterial.dispose();
|
|
318
317
|
this.normalMaterial.dispose();
|
|
319
318
|
this.saoMaterial.dispose();
|
|
320
319
|
this.vBlurMaterial.dispose();
|
|
@@ -147,8 +147,7 @@ class TAARenderPass extends SSAARenderPass {
|
|
|
147
147
|
|
|
148
148
|
super.dispose();
|
|
149
149
|
|
|
150
|
-
if ( this.
|
|
151
|
-
if ( this.holdRenderTarget !== undefined ) this.holdRenderTarget.dispose();
|
|
150
|
+
if ( this.holdRenderTarget ) this.holdRenderTarget.dispose();
|
|
152
151
|
|
|
153
152
|
}
|
|
154
153
|
|
|
@@ -95,7 +95,7 @@ class CSS3DRenderer {
|
|
|
95
95
|
let _widthHalf, _heightHalf;
|
|
96
96
|
|
|
97
97
|
const cache = {
|
|
98
|
-
camera: {
|
|
98
|
+
camera: { style: '' },
|
|
99
99
|
objects: new WeakMap()
|
|
100
100
|
};
|
|
101
101
|
|
|
@@ -129,13 +129,6 @@ class CSS3DRenderer {
|
|
|
129
129
|
|
|
130
130
|
const fov = camera.projectionMatrix.elements[ 5 ] * _heightHalf;
|
|
131
131
|
|
|
132
|
-
if ( cache.camera.fov !== fov ) {
|
|
133
|
-
|
|
134
|
-
viewElement.style.perspective = camera.isPerspectiveCamera ? fov + 'px' : '';
|
|
135
|
-
cache.camera.fov = fov;
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
132
|
if ( camera.view && camera.view.enabled ) {
|
|
140
133
|
|
|
141
134
|
// view offset
|
|
@@ -166,8 +159,9 @@ class CSS3DRenderer {
|
|
|
166
159
|
const cameraCSSMatrix = camera.isOrthographicCamera ?
|
|
167
160
|
`scale( ${ scaleByViewOffset } )` + 'scale(' + fov + ')' + 'translate(' + epsilon( tx ) + 'px,' + epsilon( ty ) + 'px)' + getCameraCSSMatrix( camera.matrixWorldInverse ) :
|
|
168
161
|
`scale( ${ scaleByViewOffset } )` + 'translateZ(' + fov + 'px)' + getCameraCSSMatrix( camera.matrixWorldInverse );
|
|
162
|
+
const perspective = camera.isPerspectiveCamera ? 'perspective(' + fov + 'px) ' : '';
|
|
169
163
|
|
|
170
|
-
const style = cameraCSSMatrix +
|
|
164
|
+
const style = perspective + cameraCSSMatrix +
|
|
171
165
|
'translate(' + _widthHalf + 'px,' + _heightHalf + 'px)';
|
|
172
166
|
|
|
173
167
|
if ( cache.camera.style !== style ) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Matrix3,
|
|
6
6
|
Matrix4,
|
|
7
7
|
Object3D,
|
|
8
|
+
SRGBColorSpace,
|
|
8
9
|
Vector3
|
|
9
10
|
} from 'three';
|
|
10
11
|
import { Projector } from '../renderers/Projector.js';
|
|
@@ -75,6 +76,8 @@ class SVGRenderer {
|
|
|
75
76
|
|
|
76
77
|
this.overdraw = 0.5;
|
|
77
78
|
|
|
79
|
+
this.outputColorSpace = SRGBColorSpace;
|
|
80
|
+
|
|
78
81
|
this.info = {
|
|
79
82
|
|
|
80
83
|
render: {
|
|
@@ -155,7 +158,7 @@ class SVGRenderer {
|
|
|
155
158
|
this.clear = function () {
|
|
156
159
|
|
|
157
160
|
removeChildNodes();
|
|
158
|
-
_svg.style.backgroundColor = _clearColor.getStyle();
|
|
161
|
+
_svg.style.backgroundColor = _clearColor.getStyle( _this.outputColorSpace );
|
|
159
162
|
|
|
160
163
|
};
|
|
161
164
|
|
|
@@ -173,7 +176,7 @@ class SVGRenderer {
|
|
|
173
176
|
if ( background && background.isColor ) {
|
|
174
177
|
|
|
175
178
|
removeChildNodes();
|
|
176
|
-
_svg.style.backgroundColor = background.getStyle();
|
|
179
|
+
_svg.style.backgroundColor = background.getStyle( _this.outputColorSpace );
|
|
177
180
|
|
|
178
181
|
} else if ( this.autoClear === true ) {
|
|
179
182
|
|
|
@@ -389,7 +392,7 @@ class SVGRenderer {
|
|
|
389
392
|
|
|
390
393
|
if ( material.isSpriteMaterial || material.isPointsMaterial ) {
|
|
391
394
|
|
|
392
|
-
style = 'fill:' + material.color.getStyle() + ';fill-opacity:' + material.opacity;
|
|
395
|
+
style = 'fill:' + material.color.getStyle( _this.outputColorSpace ) + ';fill-opacity:' + material.opacity;
|
|
393
396
|
|
|
394
397
|
}
|
|
395
398
|
|
|
@@ -403,7 +406,7 @@ class SVGRenderer {
|
|
|
403
406
|
|
|
404
407
|
if ( material.isLineBasicMaterial ) {
|
|
405
408
|
|
|
406
|
-
let style = 'fill:none;stroke:' + material.color.getStyle() + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.linewidth + ';stroke-linecap:' + material.linecap;
|
|
409
|
+
let style = 'fill:none;stroke:' + material.color.getStyle( _this.outputColorSpace ) + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.linewidth + ';stroke-linecap:' + material.linecap;
|
|
407
410
|
|
|
408
411
|
if ( material.isLineDashedMaterial ) {
|
|
409
412
|
|
|
@@ -463,11 +466,11 @@ class SVGRenderer {
|
|
|
463
466
|
|
|
464
467
|
if ( material.wireframe ) {
|
|
465
468
|
|
|
466
|
-
style = 'fill:none;stroke:' + _color.getStyle() + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.wireframeLinewidth + ';stroke-linecap:' + material.wireframeLinecap + ';stroke-linejoin:' + material.wireframeLinejoin;
|
|
469
|
+
style = 'fill:none;stroke:' + _color.getStyle( _this.outputColorSpace ) + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.wireframeLinewidth + ';stroke-linecap:' + material.wireframeLinecap + ';stroke-linejoin:' + material.wireframeLinejoin;
|
|
467
470
|
|
|
468
471
|
} else {
|
|
469
472
|
|
|
470
|
-
style = 'fill:' + _color.getStyle() + ';fill-opacity:' + material.opacity;
|
|
473
|
+
style = 'fill:' + _color.getStyle( _this.outputColorSpace ) + ';fill-opacity:' + material.opacity;
|
|
471
474
|
|
|
472
475
|
}
|
|
473
476
|
|
|
@@ -24,6 +24,7 @@ export default class RenderObject {
|
|
|
24
24
|
this.pipeline = null;
|
|
25
25
|
this.vertexBuffers = null;
|
|
26
26
|
|
|
27
|
+
this.initialNodesCacheKey = this.getNodesCacheKey();
|
|
27
28
|
this.initialCacheKey = this.getCacheKey();
|
|
28
29
|
|
|
29
30
|
this._nodeBuilderState = null;
|
|
@@ -132,6 +133,12 @@ export default class RenderObject {
|
|
|
132
133
|
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
get needsUpdate() {
|
|
137
|
+
|
|
138
|
+
return this.initialNodesCacheKey !== this.getNodesCacheKey();
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
135
142
|
getNodesCacheKey() {
|
|
136
143
|
|
|
137
144
|
// Environment Nodes Cache Key
|
|
@@ -142,7 +149,7 @@ export default class RenderObject {
|
|
|
142
149
|
|
|
143
150
|
getCacheKey() {
|
|
144
151
|
|
|
145
|
-
return
|
|
152
|
+
return this.getMaterialCacheKey() + ',' + this.getNodesCacheKey();
|
|
146
153
|
|
|
147
154
|
}
|
|
148
155
|
|
|
@@ -191,7 +191,7 @@ class Textures extends DataMap {
|
|
|
191
191
|
|
|
192
192
|
for ( const image of texture.images ) {
|
|
193
193
|
|
|
194
|
-
images.push(
|
|
194
|
+
images.push( image );
|
|
195
195
|
|
|
196
196
|
}
|
|
197
197
|
|
|
@@ -199,7 +199,7 @@ class Textures extends DataMap {
|
|
|
199
199
|
|
|
200
200
|
} else {
|
|
201
201
|
|
|
202
|
-
options.image =
|
|
202
|
+
options.image = image;
|
|
203
203
|
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -213,7 +213,7 @@ class Textures extends DataMap {
|
|
|
213
213
|
|
|
214
214
|
backend.updateTexture( texture, options );
|
|
215
215
|
|
|
216
|
-
if ( options.needsMipmaps ) backend.generateMipmaps( texture );
|
|
216
|
+
if ( options.needsMipmaps && texture.mipmaps.length === 0 ) backend.generateMipmaps( texture );
|
|
217
217
|
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -305,7 +305,7 @@ class Textures extends DataMap {
|
|
|
305
305
|
|
|
306
306
|
if ( this.isEnvironmentTexture( texture ) ) return true;
|
|
307
307
|
|
|
308
|
-
return ( texture.isCompressedTexture
|
|
308
|
+
return ( texture.isCompressedTexture === true ) || ( ( texture.minFilter !== NearestFilter ) && ( texture.minFilter !== LinearFilter ) );
|
|
309
309
|
|
|
310
310
|
}
|
|
311
311
|
|
|
@@ -317,38 +317,6 @@ class Textures extends DataMap {
|
|
|
317
317
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
_getUploadImage( image ) {
|
|
321
|
-
|
|
322
|
-
if ( this._isHTMLImage( image ) ) {
|
|
323
|
-
|
|
324
|
-
return this._imageToCanvas( image );
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return image;
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
_imageToCanvas( image ) {
|
|
333
|
-
|
|
334
|
-
const { width, height } = image;
|
|
335
|
-
|
|
336
|
-
// eslint-disable-next-line compat/compat
|
|
337
|
-
const canvas = new OffscreenCanvas( width, height );
|
|
338
|
-
|
|
339
|
-
const context = canvas.getContext( '2d' );
|
|
340
|
-
context.drawImage( image, 0, 0, width, height );
|
|
341
|
-
|
|
342
|
-
return canvas;
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
_isHTMLImage( image ) {
|
|
347
|
-
|
|
348
|
-
return ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement );
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
320
|
_destroyTexture( texture ) {
|
|
353
321
|
|
|
354
322
|
this.backend.destroySampler( texture );
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import DataMap from '../DataMap.js';
|
|
2
|
+
import ChainMap from '../ChainMap.js';
|
|
2
3
|
import NodeBuilderState from './NodeBuilderState.js';
|
|
3
4
|
import { NoToneMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from 'three';
|
|
4
5
|
import { NodeFrame, cubeTexture, texture, rangeFog, densityFog, reference, toneMapping, equirectUV, viewportBottomLeft, normalWorld } from '../../../nodes/Nodes.js';
|
|
@@ -13,6 +14,7 @@ class Nodes extends DataMap {
|
|
|
13
14
|
this.backend = backend;
|
|
14
15
|
this.nodeFrame = new NodeFrame();
|
|
15
16
|
this.nodeBuilderCache = new Map();
|
|
17
|
+
this.frameHashCache = new ChainMap();
|
|
16
18
|
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -145,18 +147,34 @@ class Nodes extends DataMap {
|
|
|
145
147
|
|
|
146
148
|
getCacheKey( scene, lightsNode ) {
|
|
147
149
|
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const toneMappingNode = this.getToneMappingNode();
|
|
150
|
+
const chain = [ scene, lightsNode ];
|
|
151
|
+
const frameId = this.nodeFrame.frameId;
|
|
151
152
|
|
|
152
|
-
|
|
153
|
+
let cacheKeyData = this.frameHashCache.get( chain );
|
|
153
154
|
|
|
154
|
-
if (
|
|
155
|
-
if ( environmentNode ) cacheKey.push( 'environmentNode:' + environmentNode.getCacheKey() );
|
|
156
|
-
if ( fogNode ) cacheKey.push( 'fogNode:' + fogNode.getCacheKey() );
|
|
157
|
-
if ( toneMappingNode ) cacheKey.push( 'toneMappingNode:' + toneMappingNode.getCacheKey() );
|
|
155
|
+
if ( cacheKeyData === undefined || cacheKeyData.frameId !== frameId ) {
|
|
158
156
|
|
|
159
|
-
|
|
157
|
+
const environmentNode = this.getEnvironmentNode( scene );
|
|
158
|
+
const fogNode = this.getFogNode( scene );
|
|
159
|
+
const toneMappingNode = this.getToneMappingNode();
|
|
160
|
+
|
|
161
|
+
const cacheKey = [];
|
|
162
|
+
|
|
163
|
+
if ( lightsNode ) cacheKey.push( lightsNode.getCacheKey() );
|
|
164
|
+
if ( environmentNode ) cacheKey.push( environmentNode.getCacheKey() );
|
|
165
|
+
if ( fogNode ) cacheKey.push( fogNode.getCacheKey() );
|
|
166
|
+
if ( toneMappingNode ) cacheKey.push( toneMappingNode.getCacheKey() );
|
|
167
|
+
|
|
168
|
+
cacheKeyData = {
|
|
169
|
+
frameId,
|
|
170
|
+
cacheKey: cacheKey.join( ',' )
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
this.frameHashCache.set( chain, cacheKeyData );
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return cacheKeyData.cacheKey;
|
|
160
178
|
|
|
161
179
|
}
|
|
162
180
|
|
|
@@ -336,22 +354,28 @@ class Nodes extends DataMap {
|
|
|
336
354
|
|
|
337
355
|
}
|
|
338
356
|
|
|
339
|
-
getNodeFrame(
|
|
357
|
+
getNodeFrame( renderer = this.renderer, scene = null, object = null, camera = null, material = null ) {
|
|
340
358
|
|
|
341
359
|
const nodeFrame = this.nodeFrame;
|
|
342
|
-
nodeFrame.
|
|
343
|
-
nodeFrame.
|
|
344
|
-
nodeFrame.
|
|
345
|
-
nodeFrame.
|
|
346
|
-
nodeFrame.material =
|
|
360
|
+
nodeFrame.renderer = renderer;
|
|
361
|
+
nodeFrame.scene = scene;
|
|
362
|
+
nodeFrame.object = object;
|
|
363
|
+
nodeFrame.camera = camera;
|
|
364
|
+
nodeFrame.material = material;
|
|
347
365
|
|
|
348
366
|
return nodeFrame;
|
|
349
367
|
|
|
350
368
|
}
|
|
351
369
|
|
|
370
|
+
getNodeFrameForRender( renderObject ) {
|
|
371
|
+
|
|
372
|
+
return this.getNodeFrame( renderObject.renderer, renderObject.scene, renderObject.object, renderObject.camera, renderObject.material );
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
|
|
352
376
|
updateBefore( renderObject ) {
|
|
353
377
|
|
|
354
|
-
const nodeFrame = this.
|
|
378
|
+
const nodeFrame = this.getNodeFrameForRender( renderObject );
|
|
355
379
|
const nodeBuilder = renderObject.getNodeBuilderState();
|
|
356
380
|
|
|
357
381
|
for ( const node of nodeBuilder.updateBeforeNodes ) {
|
|
@@ -362,11 +386,22 @@ class Nodes extends DataMap {
|
|
|
362
386
|
|
|
363
387
|
}
|
|
364
388
|
|
|
365
|
-
updateForCompute(
|
|
389
|
+
updateForCompute( computeNode ) {
|
|
390
|
+
|
|
391
|
+
const nodeFrame = this.getNodeFrame();
|
|
392
|
+
const nodeBuilder = this.getForCompute( computeNode );
|
|
393
|
+
|
|
394
|
+
for ( const node of nodeBuilder.updateNodes ) {
|
|
395
|
+
|
|
396
|
+
nodeFrame.updateNode( node );
|
|
397
|
+
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
}
|
|
366
401
|
|
|
367
402
|
updateForRender( renderObject ) {
|
|
368
403
|
|
|
369
|
-
const nodeFrame = this.
|
|
404
|
+
const nodeFrame = this.getNodeFrameForRender( renderObject );
|
|
370
405
|
const nodeBuilder = renderObject.getNodeBuilderState();
|
|
371
406
|
|
|
372
407
|
for ( const node of nodeBuilder.updateNodes ) {
|