Przeglądaj źródła

Nodes: Fixes and clean up (#26931)

sunag 1 rok temu
rodzic
commit
9116475e17

+ 10 - 0
examples/jsm/nodes/accessors/SkinningNode.js

@@ -78,6 +78,16 @@ class SkinningNode extends Node {
 
 	}
 
+	generate( builder, output ) {
+
+		if ( output !== 'void' ) {
+
+			return positionLocal.build( builder, output );
+
+		}
+
+	}
+
 	update() {
 
 		this.skinnedMesh.skeleton.update();

+ 28 - 21
examples/jsm/nodes/core/AssignNode.js

@@ -4,16 +4,16 @@ import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
 
 class AssignNode extends TempNode {
 
-	constructor( aNode, bNode ) {
+	constructor( targetNode, sourceNode ) {
 
 		super();
 
-		this.aNode = aNode;
-		this.bNode = bNode;
+		this.targetNode = targetNode;
+		this.sourceNode = sourceNode;
 
 	}
 
-	hasDependencies( builder ) {
+	hasDependencies() {
 
 		return false;
 
@@ -21,34 +21,41 @@ class AssignNode extends TempNode {
 
 	getNodeType( builder, output ) {
 
-		const aNode = this.aNode;
-		const bNode = this.bNode;
-
-		const typeA = aNode.getNodeType( builder );
-		const typeB = bNode.getNodeType( builder );
-
-		return typeB === 'void' ? 'void' : typeA;
+		return output !== 'void' ? this.targetNode.getNodeType( builder ) : 'void';
 
 	}
 
 	generate( builder, output ) {
 
-		const aNode = this.aNode;
-		const bNode = this.bNode;
+		const targetNode = this.targetNode;
+		const sourceNode = this.sourceNode;
+
+		const targetType = targetNode.getNodeType( builder );
+
+		const target = targetNode.build( builder );
+		const source = sourceNode.build( builder, targetType );
+
+		const snippet = `${ target } = ${ source }`;
+
+		if ( output === 'void' ) {
+
+			builder.addLineFlowCode( snippet );
+
+			return;
+
+		} else {
 
-		const type = this.getNodeType( builder, output );
+			const sourceType = sourceNode.getNodeType( builder );
 
-		const a = aNode.build( builder, type );
-		const b = bNode.build( builder, type );
+			if ( sourceType === 'void' ) {
 
-		if ( output !== 'void' ) {
+				builder.addLineFlowCode( snippet );
 
-			builder.addLineFlowCode( `${a} = ${b}` );
-			return a;
+				return target;
 
-		} else if ( type !== 'void' ) {
+			}
 
-			return builder.format( `${a} = ${b}`, type, output );
+			return builder.format( snippet, targetType, output );
 
 		}
 

+ 3 - 6
examples/jsm/renderers/common/Background.js

@@ -1,6 +1,6 @@
 import DataMap from './DataMap.js';
 import { Color, Mesh, SphereGeometry, BackSide } from 'three';
-import { context, normalWorld, backgroundBlurriness, backgroundIntensity, NodeMaterial, modelViewProjection, tslFn } from '../../nodes/Nodes.js';
+import { context, normalWorld, backgroundBlurriness, backgroundIntensity, NodeMaterial, modelViewProjection } from '../../nodes/Nodes.js';
 
 let _clearAlpha;
 const _clearColor = new Color();
@@ -59,11 +59,8 @@ class Background extends DataMap {
 					getSamplerLevelNode: () => backgroundBlurriness
 				} ).mul( backgroundIntensity );
 
-				const viewProj = tslFn( () => {
-					const matrix = modelViewProjection();
-					matrix.z = matrix.w;
-					return matrix;
-				} )();
+				let viewProj = modelViewProjection();
+				viewProj = viewProj.setZ( viewProj.w );
 
 				const nodeMaterial = new NodeMaterial();
 				nodeMaterial.outputNode = this.backgroundMeshNode;

+ 2 - 2
examples/jsm/renderers/common/Textures.js

@@ -213,7 +213,7 @@ class Textures extends DataMap {
 
 					backend.updateTexture( texture, options );
 
-					if ( options.needsMipmaps ) backend.generateMipmaps( texture );
+					if ( options.needsMipmaps && texture.mipmaps.length === 0 ) backend.generateMipmaps( texture );
 
 				}
 
@@ -305,7 +305,7 @@ class Textures extends DataMap {
 
 		if ( this.isEnvironmentTexture( texture ) ) return true;
 
-		return ( texture.isCompressedTexture !== true ) /*&& ( texture.generateMipmaps === true )*/ && ( texture.minFilter !== NearestFilter ) && ( texture.minFilter !== LinearFilter );
+		return ( texture.isCompressedTexture === true ) || ( ( texture.minFilter !== NearestFilter ) && ( texture.minFilter !== LinearFilter ) );
 
 	}
 

+ 10 - 10
examples/webgpu_compute_particles.html

@@ -90,9 +90,9 @@
 					const randY = instanceIndex.add( 2 ).hash();
 					const randZ = instanceIndex.add( 3 ).hash();
 
-					position.x.assign( randX.mul( 60 ).add( - 30 ) );
-					position.y.assign( randY.mul( 10 ) );
-					position.z.assign( randZ.mul( 60 ).add( - 30 ) );
+					position.x = randX.mul( 60 ).add( - 30 );
+					position.y = randY.mul( 10 );
+					position.z = randZ.mul( 60 ).add( - 30 );
 
 					color.assign( vec3( randX, randY, randZ ) );
 
@@ -105,22 +105,22 @@
 					const position = positionBuffer.element( instanceIndex );
 					const velocity = velocityBuffer.element( instanceIndex );
 
-					velocity.assign( velocity.add( vec3( 0.00, gravity, 0.00 ) ) );
-					position.assign( position, position.add( velocity ) );
+					velocity.addAssign( vec3( 0.00, gravity, 0.00 ) );
+					position.addAssign( velocity );
 
-					velocity.assign( velocity.mul( friction ) );
+					velocity.mulAssign( friction );
 
 					// floor
 
 					If( position.y.lessThan( 0 ), () => {
 
-						position.y.assign( 0 );
-						velocity.y.assign( velocity.y.negate().mul( bounce ) );
+						position.y = 0;
+						velocity.y = velocity.y.negate().mul( bounce );
 
 						// floor friction
 
-						velocity.x.assign( velocity.x.mul( .9 ) );
-						velocity.z.assign( velocity.z.mul( .9 ) );
+						velocity.x = velocity.x.mul( .9 );
+						velocity.z = velocity.z.mul( .9 );
 
 					} );
 

+ 3 - 3
examples/webgpu_compute_points.html

@@ -82,8 +82,8 @@
 
 					const position = particle.add( velocity ).temp();
 
-					velocity.x.assign( position.x.abs().greaterThanEqual( limit.x ).cond( velocity.x.negate(), velocity.x ) );
-					velocity.y.assign( position.y.abs().greaterThanEqual( limit.y ).cond( velocity.y.negate(), velocity.y ) );
+					velocity.x = position.x.abs().greaterThanEqual( limit.x ).cond( velocity.x.negate(), velocity.x );
+					velocity.y = position.y.abs().greaterThanEqual( limit.y ).cond( velocity.y.negate(), velocity.y );
 
 					position.assign( position.min( limit ).max( limit.negate() ) );
 
@@ -111,7 +111,7 @@
 
 						const velocity = velocityBufferNode.element( instanceIndex );
 
-						velocity.xy.assign( vec2( velX, velY ) );
+						velocity.xy = vec2( velX, velY );
 
 					} );