super-three 0.164.0 → 0.165.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 +3 -3
- package/build/three.cjs +664 -217
- package/build/three.module.js +664 -217
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +6 -4
- package/examples/jsm/helpers/ViewHelper.js +32 -67
- package/examples/jsm/libs/tween.module.js +75 -64
- package/examples/jsm/lines/LineMaterial.js +1 -15
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/loaders/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/FBXLoader.js +24 -13
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/nodes/Nodes.js +12 -11
- package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -0
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
- package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
- package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
- package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
- package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
- package/examples/jsm/nodes/accessors/UVNode.js +2 -46
- package/examples/jsm/nodes/core/AttributeNode.js +15 -3
- package/examples/jsm/nodes/core/ContextNode.js +6 -0
- package/examples/jsm/nodes/core/Node.js +15 -2
- package/examples/jsm/nodes/core/NodeBuilder.js +20 -9
- package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +1 -5
- package/examples/jsm/nodes/core/PropertyNode.js +1 -0
- package/examples/jsm/nodes/core/VaryingNode.js +40 -9
- package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
- package/examples/jsm/nodes/display/PassNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportNode.js +1 -1
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +61 -17
- package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +17 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/Materials.js +3 -0
- package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +21 -4
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +13 -5
- package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/examples/jsm/nodes/math/HashNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +55 -33
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/common/Attributes.js +2 -0
- package/examples/jsm/renderers/common/Bindings.js +17 -0
- package/examples/jsm/renderers/common/ChainMap.js +18 -48
- package/examples/jsm/renderers/common/ClippingContext.js +4 -4
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderBundle.js +18 -0
- package/examples/jsm/renderers/common/RenderBundles.js +38 -0
- package/examples/jsm/renderers/common/RenderList.js +9 -0
- package/examples/jsm/renderers/common/RenderObject.js +6 -0
- package/examples/jsm/renderers/common/Renderer.js +139 -11
- package/examples/jsm/renderers/common/Uniform.js +1 -1
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +17 -5
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +93 -6
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +50 -4
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +69 -11
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/package.json +3 -2
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/constants.js +1 -1
- package/src/core/Object3D.js +2 -0
- package/src/core/Raycaster.js +6 -2
- package/src/loaders/FileLoader.js +4 -0
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/objects/BatchedMesh.js +91 -1
- package/src/renderers/WebGLRenderer.js +288 -57
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/webgl/WebGLBackground.js +6 -0
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +9 -12
- package/src/renderers/webgl/WebGLMaterials.js +1 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +2 -31
- package/src/renderers/webgl/WebGLPrograms.js +14 -14
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLTextures.js +139 -70
- package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +6 -2
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import { varying } from '../core/VaryingNode.js';
|
|
3
|
+
import { property } from '../core/PropertyNode.js';
|
|
4
|
+
import { materialReference } from '../accessors/MaterialReferenceNode.js';
|
|
5
|
+
import { modelWorldMatrixInverse } from '../accessors/ModelNode.js';
|
|
6
|
+
import { cameraPosition } from '../accessors/CameraNode.js';
|
|
7
|
+
import { positionGeometry } from '../accessors/PositionNode.js';
|
|
8
|
+
import { tslFn, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
9
|
+
import { min, max } from '../math/MathNode.js';
|
|
10
|
+
import { loop, Break } from '../utils/LoopNode.js';
|
|
11
|
+
import { texture3D } from '../accessors/Texture3DNode.js';
|
|
12
|
+
|
|
13
|
+
class VolumeNodeMaterial extends NodeMaterial {
|
|
14
|
+
|
|
15
|
+
constructor( params = {} ) {
|
|
16
|
+
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
this.normals = false;
|
|
20
|
+
this.lights = false;
|
|
21
|
+
this.isVolumeNodeMaterial = true;
|
|
22
|
+
this.testNode = null;
|
|
23
|
+
|
|
24
|
+
this.setValues( params );
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setup( builder ) {
|
|
29
|
+
|
|
30
|
+
const map = texture3D( this.map, null, 0 );
|
|
31
|
+
|
|
32
|
+
const hitBox = tslFn( ( { orig, dir } ) => {
|
|
33
|
+
|
|
34
|
+
const box_min = vec3( - 0.5 );
|
|
35
|
+
const box_max = vec3( 0.5 );
|
|
36
|
+
|
|
37
|
+
const inv_dir = dir.reciprocal();
|
|
38
|
+
|
|
39
|
+
const tmin_tmp = box_min.sub( orig ).mul( inv_dir );
|
|
40
|
+
const tmax_tmp = box_max.sub( orig ).mul( inv_dir );
|
|
41
|
+
|
|
42
|
+
const tmin = min( tmin_tmp, tmax_tmp );
|
|
43
|
+
const tmax = max( tmin_tmp, tmax_tmp );
|
|
44
|
+
|
|
45
|
+
const t0 = max( tmin.x, max( tmin.y, tmin.z ) );
|
|
46
|
+
const t1 = min( tmax.x, min( tmax.y, tmax.z ) );
|
|
47
|
+
|
|
48
|
+
return vec2( t0, t1 );
|
|
49
|
+
|
|
50
|
+
} );
|
|
51
|
+
|
|
52
|
+
this.fragmentNode = tslFn( () => {
|
|
53
|
+
|
|
54
|
+
const vOrigin = varying( vec3( modelWorldMatrixInverse.mul( vec4( cameraPosition, 1.0 ) ) ) );
|
|
55
|
+
const vDirection = varying( positionGeometry.sub( vOrigin ) );
|
|
56
|
+
|
|
57
|
+
const rayDir = vDirection.normalize();
|
|
58
|
+
const bounds = property( 'vec2', 'bounds' ).assign( hitBox( { orig: vOrigin, dir: rayDir } ) );
|
|
59
|
+
|
|
60
|
+
bounds.x.greaterThan( bounds.y ).discard();
|
|
61
|
+
|
|
62
|
+
bounds.assign( vec2( max( bounds.x, 0.0 ), bounds.y ) );
|
|
63
|
+
|
|
64
|
+
const p = property( 'vec3', 'p' ).assign( vOrigin.add( bounds.x.mul( rayDir ) ) );
|
|
65
|
+
const inc = property( 'vec3', 'inc' ).assign( vec3( rayDir.abs().reciprocal() ) );
|
|
66
|
+
const delta = property( 'float', 'delta' ).assign( min( inc.x, min( inc.y, inc.z ) ) );
|
|
67
|
+
|
|
68
|
+
delta.divAssign( materialReference( 'steps', 'float' ) );
|
|
69
|
+
|
|
70
|
+
const ac = property( 'vec4', 'ac' ).assign( vec4( materialReference( 'base', 'color' ), 0.0 ) );
|
|
71
|
+
|
|
72
|
+
loop( { type: 'float', start: bounds.x, end: bounds.y, update: '+= delta' }, () => {
|
|
73
|
+
|
|
74
|
+
const d = property( 'float', 'd' ).assign( map.uv( p.add( 0.5 ) ).r );
|
|
75
|
+
|
|
76
|
+
if ( this.testNode !== null ) {
|
|
77
|
+
|
|
78
|
+
this.testNode( { map: map, mapValue: d, probe: p, finalColor: ac } ).append();
|
|
79
|
+
|
|
80
|
+
} else {
|
|
81
|
+
|
|
82
|
+
// default to show surface of mesh
|
|
83
|
+
ac.a.assign( 1 );
|
|
84
|
+
Break();
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
p.addAssign( rayDir.mul( delta ) );
|
|
89
|
+
|
|
90
|
+
} );
|
|
91
|
+
|
|
92
|
+
ac.a.equal( 0 ).discard();
|
|
93
|
+
|
|
94
|
+
return vec4( ac );
|
|
95
|
+
|
|
96
|
+
} )();
|
|
97
|
+
|
|
98
|
+
super.setup( builder );
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default VolumeNodeMaterial;
|
|
105
|
+
|
|
106
|
+
addNodeMaterial( 'VolumeNodeMaterial', VolumeNodeMaterial );
|
|
@@ -15,11 +15,11 @@ class HashNode extends Node {
|
|
|
15
15
|
|
|
16
16
|
// Taken from https://www.shadertoy.com/view/XlGcRh, originally from pcg-random.org
|
|
17
17
|
|
|
18
|
-
const state = this.seedNode.
|
|
18
|
+
const state = this.seedNode.toUint().mul( 747796405 ).add( 2891336453 );
|
|
19
19
|
const word = state.shiftRight( state.shiftRight( 28 ).add( 4 ) ).bitXor( state ).mul( 277803737 );
|
|
20
20
|
const result = word.shiftRight( 22 ).bitXor( word );
|
|
21
21
|
|
|
22
|
-
return result.
|
|
22
|
+
return result.toFloat().mul( 1 / 2 ** 32 ); // Convert to range [0, 1)
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -251,9 +251,15 @@ class ShaderCallNodeInternal extends Node {
|
|
|
251
251
|
|
|
252
252
|
getNodeType( builder ) {
|
|
253
253
|
|
|
254
|
-
const
|
|
254
|
+
const properties = builder.getNodeProperties( this );
|
|
255
|
+
|
|
256
|
+
if ( properties.outputNode === null ) {
|
|
257
|
+
|
|
258
|
+
properties.outputNode = this.setupOutput( builder );
|
|
259
|
+
|
|
260
|
+
}
|
|
255
261
|
|
|
256
|
-
return outputNode
|
|
262
|
+
return properties.outputNode.getNodeType( builder );
|
|
257
263
|
|
|
258
264
|
}
|
|
259
265
|
|
|
@@ -302,6 +308,14 @@ class ShaderCallNodeInternal extends Node {
|
|
|
302
308
|
|
|
303
309
|
setup( builder ) {
|
|
304
310
|
|
|
311
|
+
const { outputNode } = builder.getNodeProperties( this );
|
|
312
|
+
|
|
313
|
+
return outputNode || this.setupOutput( builder );
|
|
314
|
+
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
setupOutput( builder ) {
|
|
318
|
+
|
|
305
319
|
builder.addStack();
|
|
306
320
|
|
|
307
321
|
builder.stack.outputNode = this.call( builder );
|
|
@@ -517,6 +531,16 @@ addNodeClass( 'ShaderNode', ShaderNode );
|
|
|
517
531
|
|
|
518
532
|
//
|
|
519
533
|
|
|
534
|
+
addNodeElement( 'toGlobal', ( node ) => {
|
|
535
|
+
|
|
536
|
+
node.global = true;
|
|
537
|
+
|
|
538
|
+
return node;
|
|
539
|
+
|
|
540
|
+
} );
|
|
541
|
+
|
|
542
|
+
//
|
|
543
|
+
|
|
520
544
|
export const setCurrentStack = ( stack ) => {
|
|
521
545
|
|
|
522
546
|
if ( currentStack === stack ) {
|
|
@@ -586,37 +610,35 @@ export const bmat4 = new ConvertType( 'bmat4' );
|
|
|
586
610
|
export const string = ( value = '' ) => nodeObject( new ConstNode( value, 'string' ) );
|
|
587
611
|
export const arrayBuffer = ( value ) => nodeObject( new ConstNode( value, 'ArrayBuffer' ) );
|
|
588
612
|
|
|
589
|
-
addNodeElement( '
|
|
590
|
-
addNodeElement( '
|
|
591
|
-
addNodeElement( '
|
|
592
|
-
addNodeElement( '
|
|
593
|
-
addNodeElement( '
|
|
594
|
-
addNodeElement( '
|
|
595
|
-
addNodeElement( '
|
|
596
|
-
addNodeElement( '
|
|
597
|
-
addNodeElement( '
|
|
598
|
-
addNodeElement( '
|
|
599
|
-
addNodeElement( '
|
|
600
|
-
addNodeElement( '
|
|
601
|
-
addNodeElement( '
|
|
602
|
-
addNodeElement( '
|
|
603
|
-
addNodeElement( '
|
|
604
|
-
addNodeElement( '
|
|
605
|
-
addNodeElement( '
|
|
606
|
-
addNodeElement( '
|
|
607
|
-
addNodeElement( '
|
|
608
|
-
addNodeElement( '
|
|
609
|
-
addNodeElement( '
|
|
610
|
-
addNodeElement( '
|
|
611
|
-
addNodeElement( '
|
|
612
|
-
addNodeElement( '
|
|
613
|
-
addNodeElement( '
|
|
614
|
-
addNodeElement( '
|
|
615
|
-
addNodeElement( '
|
|
616
|
-
addNodeElement( '
|
|
617
|
-
addNodeElement( '
|
|
618
|
-
addNodeElement( 'string', string );
|
|
619
|
-
addNodeElement( 'arrayBuffer', arrayBuffer );
|
|
613
|
+
addNodeElement( 'toColor', color );
|
|
614
|
+
addNodeElement( 'toFloat', float );
|
|
615
|
+
addNodeElement( 'toInt', int );
|
|
616
|
+
addNodeElement( 'toUint', uint );
|
|
617
|
+
addNodeElement( 'toBool', bool );
|
|
618
|
+
addNodeElement( 'toVec2', vec2 );
|
|
619
|
+
addNodeElement( 'toIvec2', ivec2 );
|
|
620
|
+
addNodeElement( 'toUvec2', uvec2 );
|
|
621
|
+
addNodeElement( 'toBvec2', bvec2 );
|
|
622
|
+
addNodeElement( 'toVec3', vec3 );
|
|
623
|
+
addNodeElement( 'toIvec3', ivec3 );
|
|
624
|
+
addNodeElement( 'toUvec3', uvec3 );
|
|
625
|
+
addNodeElement( 'toBvec3', bvec3 );
|
|
626
|
+
addNodeElement( 'toVec4', vec4 );
|
|
627
|
+
addNodeElement( 'toIvec4', ivec4 );
|
|
628
|
+
addNodeElement( 'toUvec4', uvec4 );
|
|
629
|
+
addNodeElement( 'toBvec4', bvec4 );
|
|
630
|
+
addNodeElement( 'toMat2', mat2 );
|
|
631
|
+
addNodeElement( 'toImat2', imat2 );
|
|
632
|
+
addNodeElement( 'toUmat2', umat2 );
|
|
633
|
+
addNodeElement( 'toBmat2', bmat2 );
|
|
634
|
+
addNodeElement( 'toMat3', mat3 );
|
|
635
|
+
addNodeElement( 'toImat3', imat3 );
|
|
636
|
+
addNodeElement( 'toUmat3', umat3 );
|
|
637
|
+
addNodeElement( 'toBmat3', bmat3 );
|
|
638
|
+
addNodeElement( 'toMat4', mat4 );
|
|
639
|
+
addNodeElement( 'toImat4', imat4 );
|
|
640
|
+
addNodeElement( 'toUmat4', umat4 );
|
|
641
|
+
addNodeElement( 'toBmat4', bmat4 );
|
|
620
642
|
|
|
621
643
|
// basic nodes
|
|
622
644
|
// HACK - we cannot export them from the corresponding files because of the cyclic dependency
|
|
@@ -17,7 +17,7 @@ class MatcapUVNode extends TempNode {
|
|
|
17
17
|
const x = vec3( positionViewDirection.z, 0, positionViewDirection.x.negate() ).normalize();
|
|
18
18
|
const y = positionViewDirection.cross( x );
|
|
19
19
|
|
|
20
|
-
return vec2( x.dot( transformedNormalView ), y.dot( transformedNormalView ) ).mul( 0.495 ).add( 0.5 );
|
|
20
|
+
return vec2( x.dot( transformedNormalView ), y.dot( transformedNormalView ) ).mul( 0.495 ).add( 0.5 ); // 0.495 to remove artifacts caused by undersized matcap disks
|
|
21
21
|
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -89,6 +89,6 @@ export default TimerNode;
|
|
|
89
89
|
export const timerLocal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.LOCAL, timeScale, value ) );
|
|
90
90
|
export const timerGlobal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.GLOBAL, timeScale, value ) );
|
|
91
91
|
export const timerDelta = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.DELTA, timeScale, value ) );
|
|
92
|
-
export const frameId = nodeImmutable( TimerNode, TimerNode.FRAME ).
|
|
92
|
+
export const frameId = nodeImmutable( TimerNode, TimerNode.FRAME ).toUint();
|
|
93
93
|
|
|
94
94
|
addNodeClass( 'TimerNode', TimerNode );
|
|
@@ -210,7 +210,7 @@ class Lensflare extends Mesh {
|
|
|
210
210
|
|
|
211
211
|
// save current RGB to temp texture
|
|
212
212
|
|
|
213
|
-
renderer.copyFramebufferToTexture(
|
|
213
|
+
renderer.copyFramebufferToTexture( tempMap, screenPositionPixels );
|
|
214
214
|
|
|
215
215
|
// render pink quad
|
|
216
216
|
|
|
@@ -222,7 +222,7 @@ class Lensflare extends Mesh {
|
|
|
222
222
|
|
|
223
223
|
// copy result to occlusionMap
|
|
224
224
|
|
|
225
|
-
renderer.copyFramebufferToTexture(
|
|
225
|
+
renderer.copyFramebufferToTexture( occlusionMap, screenPositionPixels );
|
|
226
226
|
|
|
227
227
|
// restore graphics
|
|
228
228
|
|
|
@@ -114,22 +114,42 @@ class CSS2DRenderer {
|
|
|
114
114
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
+
function hideObject( object ) {
|
|
118
|
+
|
|
119
|
+
if ( object.isCSS2DObject ) object.element.style.display = 'none';
|
|
120
|
+
|
|
121
|
+
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
|
|
122
|
+
|
|
123
|
+
hideObject( object.children[ i ] );
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
117
129
|
function renderObject( object, scene, camera ) {
|
|
118
130
|
|
|
131
|
+
if ( object.visible === false ) {
|
|
132
|
+
|
|
133
|
+
hideObject( object );
|
|
134
|
+
|
|
135
|
+
return;
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
119
139
|
if ( object.isCSS2DObject ) {
|
|
120
140
|
|
|
121
141
|
_vector.setFromMatrixPosition( object.matrixWorld );
|
|
122
142
|
_vector.applyMatrix4( _viewProjectionMatrix );
|
|
123
143
|
|
|
124
|
-
const visible = (
|
|
125
|
-
|
|
144
|
+
const visible = ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );
|
|
145
|
+
|
|
146
|
+
const element = object.element;
|
|
147
|
+
element.style.display = visible === true ? '' : 'none';
|
|
126
148
|
|
|
127
149
|
if ( visible === true ) {
|
|
128
150
|
|
|
129
151
|
object.onBeforeRender( _this, scene, camera );
|
|
130
152
|
|
|
131
|
-
const element = object.element;
|
|
132
|
-
|
|
133
153
|
element.style.transform = 'translate(' + ( - 100 * object.center.x ) + '%,' + ( - 100 * object.center.y ) + '%)' + 'translate(' + ( _vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - _vector.y * _heightHalf + _heightHalf ) + 'px)';
|
|
134
154
|
|
|
135
155
|
if ( element.parentNode !== domElement ) {
|
|
@@ -171,7 +191,7 @@ class CSS2DRenderer {
|
|
|
171
191
|
|
|
172
192
|
const result = [];
|
|
173
193
|
|
|
174
|
-
scene.
|
|
194
|
+
scene.traverseVisible( function ( object ) {
|
|
175
195
|
|
|
176
196
|
if ( object.isCSS2DObject ) result.push( object );
|
|
177
197
|
|
|
@@ -251,12 +251,34 @@ class CSS3DRenderer {
|
|
|
251
251
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
function hideObject( object ) {
|
|
255
|
+
|
|
256
|
+
if ( object.isCSS3DObject ) object.element.style.display = 'none';
|
|
257
|
+
|
|
258
|
+
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
|
|
259
|
+
|
|
260
|
+
hideObject( object.children[ i ] );
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
254
266
|
function renderObject( object, scene, camera, cameraCSSMatrix ) {
|
|
255
267
|
|
|
268
|
+
if ( object.visible === false ) {
|
|
269
|
+
|
|
270
|
+
hideObject( object );
|
|
271
|
+
|
|
272
|
+
return;
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
256
276
|
if ( object.isCSS3DObject ) {
|
|
257
277
|
|
|
258
|
-
const visible = ( object.
|
|
259
|
-
|
|
278
|
+
const visible = ( object.layers.test( camera.layers ) === true );
|
|
279
|
+
|
|
280
|
+
const element = object.element;
|
|
281
|
+
element.style.display = visible === true ? '' : 'none';
|
|
260
282
|
|
|
261
283
|
if ( visible === true ) {
|
|
262
284
|
|
|
@@ -290,7 +312,6 @@ class CSS3DRenderer {
|
|
|
290
312
|
|
|
291
313
|
}
|
|
292
314
|
|
|
293
|
-
const element = object.element;
|
|
294
315
|
const cachedObject = cache.objects.get( object );
|
|
295
316
|
|
|
296
317
|
if ( cachedObject === undefined || cachedObject.style !== style ) {
|
|
@@ -122,6 +122,10 @@ class Bindings extends DataMap {
|
|
|
122
122
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
} else if ( binding.isSampler ) {
|
|
126
|
+
|
|
127
|
+
binding.update();
|
|
128
|
+
|
|
125
129
|
} else if ( binding.isSampledTexture ) {
|
|
126
130
|
|
|
127
131
|
const texture = binding.texture;
|
|
@@ -136,6 +140,19 @@ class Bindings extends DataMap {
|
|
|
136
140
|
|
|
137
141
|
}
|
|
138
142
|
|
|
143
|
+
const textureData = backend.get( binding.texture );
|
|
144
|
+
|
|
145
|
+
if ( backend.isWebGPUBackend === true && textureData.texture === undefined && textureData.externalTexture === undefined ) {
|
|
146
|
+
|
|
147
|
+
// TODO: Remove this once we found why updated === false isn't bound to a texture in the WebGPU backend
|
|
148
|
+
console.error( 'Bindings._update: binding should be available:', binding, updated, binding.texture, binding.textureNode.value );
|
|
149
|
+
|
|
150
|
+
this.textures.updateTexture( binding.texture );
|
|
151
|
+
needsBindingsUpdate = true;
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
139
156
|
if ( texture.isStorageTexture === true ) {
|
|
140
157
|
|
|
141
158
|
const textureData = this.get( texture );
|
|
@@ -8,81 +8,51 @@ export default class ChainMap {
|
|
|
8
8
|
|
|
9
9
|
get( keys ) {
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
let map = this.weakMap;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
for ( let i = 0; i < keys.length; i ++ ) {
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
map = map.get( keys[ i ] );
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if ( map === undefined ) return undefined;
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return map.get( keys[ keys.length - 1 ] );
|
|
24
|
-
|
|
25
|
-
} else {
|
|
26
|
-
|
|
27
|
-
return super.get( keys );
|
|
17
|
+
if ( map === undefined ) return undefined;
|
|
28
18
|
|
|
29
19
|
}
|
|
30
20
|
|
|
21
|
+
return map.get( keys[ keys.length - 1 ] );
|
|
22
|
+
|
|
31
23
|
}
|
|
32
24
|
|
|
33
25
|
set( keys, value ) {
|
|
34
26
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let map = this.weakMap;
|
|
38
|
-
|
|
39
|
-
for ( let i = 0; i < keys.length; i ++ ) {
|
|
40
|
-
|
|
41
|
-
const key = keys[ i ];
|
|
42
|
-
|
|
43
|
-
if ( map.has( key ) === false ) map.set( key, new WeakMap() );
|
|
27
|
+
let map = this.weakMap;
|
|
44
28
|
|
|
45
|
-
|
|
29
|
+
for ( let i = 0; i < keys.length; i ++ ) {
|
|
46
30
|
|
|
47
|
-
|
|
31
|
+
const key = keys[ i ];
|
|
48
32
|
|
|
49
|
-
|
|
33
|
+
if ( map.has( key ) === false ) map.set( key, new WeakMap() );
|
|
50
34
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return super.set( keys, value );
|
|
35
|
+
map = map.get( key );
|
|
54
36
|
|
|
55
37
|
}
|
|
56
38
|
|
|
39
|
+
return map.set( keys[ keys.length - 1 ], value );
|
|
40
|
+
|
|
57
41
|
}
|
|
58
42
|
|
|
59
43
|
delete( keys ) {
|
|
60
44
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
let map = this.weakMap;
|
|
64
|
-
|
|
65
|
-
for ( let i = 0; i < keys.length; i ++ ) {
|
|
66
|
-
|
|
67
|
-
map = map.get( keys[ i ] );
|
|
45
|
+
let map = this.weakMap;
|
|
68
46
|
|
|
69
|
-
|
|
47
|
+
for ( let i = 0; i < keys.length; i ++ ) {
|
|
70
48
|
|
|
71
|
-
|
|
49
|
+
map = map.get( keys[ i ] );
|
|
72
50
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} else {
|
|
76
|
-
|
|
77
|
-
return super.delete( keys );
|
|
51
|
+
if ( map === undefined ) return false;
|
|
78
52
|
|
|
79
53
|
}
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
dispose() {
|
|
84
|
-
|
|
85
|
-
this.weakMap.clear();
|
|
55
|
+
return map.delete( keys[ keys.length - 1 ] );
|
|
86
56
|
|
|
87
57
|
}
|
|
88
58
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Matrix3, Plane, Vector4 } from 'three';
|
|
2
2
|
|
|
3
3
|
const _plane = new Plane();
|
|
4
|
-
const _viewNormalMatrix = new Matrix3();
|
|
5
4
|
|
|
6
5
|
let _clippingContextVersion = 0;
|
|
7
6
|
|
|
@@ -20,6 +19,7 @@ class ClippingContext {
|
|
|
20
19
|
this.planes = [];
|
|
21
20
|
|
|
22
21
|
this.parentVersion = 0;
|
|
22
|
+
this.viewNormalMatrix = new Matrix3();
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -30,7 +30,7 @@ class ClippingContext {
|
|
|
30
30
|
|
|
31
31
|
for ( let i = 0; i < l; i ++ ) {
|
|
32
32
|
|
|
33
|
-
_plane.copy( source[ i ] ).applyMatrix4( this.viewMatrix,
|
|
33
|
+
_plane.copy( source[ i ] ).applyMatrix4( this.viewMatrix, this.viewNormalMatrix );
|
|
34
34
|
|
|
35
35
|
const v = planes[ offset + i ];
|
|
36
36
|
const normal = _plane.normal;
|
|
@@ -49,7 +49,7 @@ class ClippingContext {
|
|
|
49
49
|
const rendererClippingPlanes = renderer.clippingPlanes;
|
|
50
50
|
this.viewMatrix = camera.matrixWorldInverse;
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
this.viewNormalMatrix.getNormalMatrix( this.viewMatrix );
|
|
53
53
|
|
|
54
54
|
let update = false;
|
|
55
55
|
|
|
@@ -106,7 +106,7 @@ class ClippingContext {
|
|
|
106
106
|
this.planes = Array.from( parent.planes );
|
|
107
107
|
this.parentVersion = parent.version;
|
|
108
108
|
this.viewMatrix = parent.viewMatrix;
|
|
109
|
-
|
|
109
|
+
this.viewNormalMatrix = parent.viewNormalMatrix;
|
|
110
110
|
|
|
111
111
|
update = true;
|
|
112
112
|
|
|
@@ -67,7 +67,7 @@ class Pipelines extends DataMap {
|
|
|
67
67
|
|
|
68
68
|
if ( pipeline === undefined ) {
|
|
69
69
|
|
|
70
|
-
if ( previousPipeline && previousPipeline.usedTimes === 0 ) this._releasePipeline(
|
|
70
|
+
if ( previousPipeline && previousPipeline.usedTimes === 0 ) this._releasePipeline( previousPipeline );
|
|
71
71
|
|
|
72
72
|
pipeline = this._getComputePipeline( computeNode, stageCompute, cacheKey, bindings );
|
|
73
73
|
|
|
@@ -205,7 +205,7 @@ class Pipelines extends DataMap {
|
|
|
205
205
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
super.delete( object );
|
|
208
|
+
return super.delete( object );
|
|
209
209
|
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ChainMap from './ChainMap.js';
|
|
2
|
+
import RenderBundle from './RenderBundle.js';
|
|
3
|
+
|
|
4
|
+
class RenderBundles {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
|
|
8
|
+
this.lists = new ChainMap();
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get( scene, camera ) {
|
|
13
|
+
|
|
14
|
+
const lists = this.lists;
|
|
15
|
+
const keys = [ scene, camera ];
|
|
16
|
+
|
|
17
|
+
let list = lists.get( keys );
|
|
18
|
+
|
|
19
|
+
if ( list === undefined ) {
|
|
20
|
+
|
|
21
|
+
list = new RenderBundle( scene, camera );
|
|
22
|
+
lists.set( keys, list );
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return list;
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
dispose() {
|
|
31
|
+
|
|
32
|
+
this.lists = new ChainMap();
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default RenderBundles;
|
|
@@ -57,6 +57,7 @@ class RenderList {
|
|
|
57
57
|
|
|
58
58
|
this.opaque = [];
|
|
59
59
|
this.transparent = [];
|
|
60
|
+
this.bundles = [];
|
|
60
61
|
|
|
61
62
|
this.lightsNode = new LightsNode( [] );
|
|
62
63
|
this.lightsArray = [];
|
|
@@ -71,6 +72,8 @@ class RenderList {
|
|
|
71
72
|
|
|
72
73
|
this.opaque.length = 0;
|
|
73
74
|
this.transparent.length = 0;
|
|
75
|
+
this.bundles.length = 0;
|
|
76
|
+
|
|
74
77
|
this.lightsArray.length = 0;
|
|
75
78
|
|
|
76
79
|
this.occlusionQueryCount = 0;
|
|
@@ -135,6 +138,12 @@ class RenderList {
|
|
|
135
138
|
|
|
136
139
|
}
|
|
137
140
|
|
|
141
|
+
pushBundle( group ) {
|
|
142
|
+
|
|
143
|
+
this.bundles.push( group );
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
138
147
|
pushLight( light ) {
|
|
139
148
|
|
|
140
149
|
this.lightsArray.push( light );
|