瀏覽代碼

NodeBuilder: Fix item size if there is no padding (#25934)

* WebGPUBackground: Fix frustumCulled and cleanup

* NodeBuilder: Fix item size if there is no padding
sunag 2 年之前
父節點
當前提交
c1bc1bfcb6
共有 2 個文件被更改,包括 6 次插入4 次删除
  1. 3 1
      examples/jsm/nodes/core/NodeBuilder.js
  2. 3 3
      examples/jsm/renderers/webgpu/WebGPUBackground.js

+ 3 - 1
examples/jsm/nodes/core/NodeBuilder.js

@@ -30,6 +30,8 @@ const typeFromArray = new Map( [
 	[ Float32Array, 'float' ]
 	[ Float32Array, 'float' ]
 ] );
 ] );
 
 
+const isNonPaddingElementArray = new Set( [ Int32Array, Uint32Array, Float32Array ] );
+
 const toFloat = ( value ) => {
 const toFloat = ( value ) => {
 
 
 	value = Number( value );
 	value = Number( value );
@@ -444,7 +446,7 @@ class NodeBuilder {
 		if ( attribute.isInterleavedBufferAttribute ) dataAttribute = attribute.data;
 		if ( attribute.isInterleavedBufferAttribute ) dataAttribute = attribute.data;
 
 
 		const array = dataAttribute.array;
 		const array = dataAttribute.array;
-		const itemSize = dataAttribute.stride || attribute.itemSize;
+		const itemSize = isNonPaddingElementArray.has( array.constructor ) ? attribute.itemSize : dataAttribute.stride || attribute.itemSize;
 		const normalized = attribute.normalized;
 		const normalized = attribute.normalized;
 
 
 		let arrayType;
 		let arrayType;

+ 3 - 3
examples/jsm/renderers/webgpu/WebGPUBackground.js

@@ -69,10 +69,10 @@ class WebGPUBackground {
 				nodeMaterial.side = BackSide;
 				nodeMaterial.side = BackSide;
 				nodeMaterial.depthTest = false;
 				nodeMaterial.depthTest = false;
 				nodeMaterial.depthWrite = false;
 				nodeMaterial.depthWrite = false;
-				nodeMaterial.frustumCulled = false;
 				nodeMaterial.fog = false;
 				nodeMaterial.fog = false;
 
 
 				this.boxMesh = boxMesh = new Mesh( new BoxGeometry( 1, 1, 1 ), nodeMaterial );
 				this.boxMesh = boxMesh = new Mesh( new BoxGeometry( 1, 1, 1 ), nodeMaterial );
+				boxMesh.frustumCulled = false;
 
 
 				boxMesh.onBeforeRender = function ( renderer, scene, camera ) {
 				boxMesh.onBeforeRender = function ( renderer, scene, camera ) {
 
 
@@ -86,13 +86,13 @@ class WebGPUBackground {
 
 
 			const backgroundCacheKey = backgroundNode.getCacheKey();
 			const backgroundCacheKey = backgroundNode.getCacheKey();
 
 
-			if ( sceneProperties.backgroundMeshCacheKey !== backgroundCacheKey ) {
+			if ( sceneProperties.backgroundCacheKey !== backgroundCacheKey ) {
 
 
 				this.boxMeshNode.node = backgroundNode;
 				this.boxMeshNode.node = backgroundNode;
 
 
 				boxMesh.material.needsUpdate = true;
 				boxMesh.material.needsUpdate = true;
 
 
-				sceneProperties.backgroundMeshCacheKey = backgroundCacheKey;
+				sceneProperties.backgroundCacheKey = backgroundCacheKey;
 
 
 			}
 			}