Skip to content

Commit c1bc1bf

Browse files
authored
NodeBuilder: Fix item size if there is no padding (#25934)
* WebGPUBackground: Fix frustumCulled and cleanup * NodeBuilder: Fix item size if there is no padding
1 parent 6a68319 commit c1bc1bf

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

examples/jsm/nodes/core/NodeBuilder.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const typeFromArray = new Map( [
3030
[ Float32Array, 'float' ]
3131
] );
3232

33+
const isNonPaddingElementArray = new Set( [ Int32Array, Uint32Array, Float32Array ] );
34+
3335
const toFloat = ( value ) => {
3436

3537
value = Number( value );
@@ -444,7 +446,7 @@ class NodeBuilder {
444446
if ( attribute.isInterleavedBufferAttribute ) dataAttribute = attribute.data;
445447

446448
const array = dataAttribute.array;
447-
const itemSize = dataAttribute.stride || attribute.itemSize;
449+
const itemSize = isNonPaddingElementArray.has( array.constructor ) ? attribute.itemSize : dataAttribute.stride || attribute.itemSize;
448450
const normalized = attribute.normalized;
449451

450452
let arrayType;

examples/jsm/renderers/webgpu/WebGPUBackground.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ class WebGPUBackground {
6969
nodeMaterial.side = BackSide;
7070
nodeMaterial.depthTest = false;
7171
nodeMaterial.depthWrite = false;
72-
nodeMaterial.frustumCulled = false;
7372
nodeMaterial.fog = false;
7473

7574
this.boxMesh = boxMesh = new Mesh( new BoxGeometry( 1, 1, 1 ), nodeMaterial );
75+
boxMesh.frustumCulled = false;
7676

7777
boxMesh.onBeforeRender = function ( renderer, scene, camera ) {
7878

@@ -86,13 +86,13 @@ class WebGPUBackground {
8686

8787
const backgroundCacheKey = backgroundNode.getCacheKey();
8888

89-
if ( sceneProperties.backgroundMeshCacheKey !== backgroundCacheKey ) {
89+
if ( sceneProperties.backgroundCacheKey !== backgroundCacheKey ) {
9090

9191
this.boxMeshNode.node = backgroundNode;
9292

9393
boxMesh.material.needsUpdate = true;
9494

95-
sceneProperties.backgroundMeshCacheKey = backgroundCacheKey;
95+
sceneProperties.backgroundCacheKey = backgroundCacheKey;
9696

9797
}
9898

0 commit comments

Comments
 (0)