diff --git a/examples/jsm/objects/WaterMesh.js b/examples/jsm/objects/WaterMesh.js index fd756adc8b4d88..25b5a6b305d9d9 100644 --- a/examples/jsm/objects/WaterMesh.js +++ b/examples/jsm/objects/WaterMesh.js @@ -2,10 +2,10 @@ import { Color, Mesh, Vector3, - MeshLambertNodeMaterial + NodeMaterial } from 'three/webgpu'; -import { Fn, add, cameraPosition, div, normalize, positionWorld, sub, time, texture, vec2, vec3, max, dot, reflect, pow, length, float, uniform, reflector, mul, mix, diffuseColor } from 'three/tsl'; +import { Fn, add, cameraPosition, div, normalize, positionWorld, sub, time, texture, vec2, max, dot, reflect, pow, length, float, uniform, reflector, mul, mix } from 'three/tsl'; /** * A basic flat, reflective water effect. @@ -32,7 +32,7 @@ class WaterMesh extends Mesh { */ constructor( geometry, options ) { - const material = new MeshLambertNodeMaterial(); + const material = new NodeMaterial(); super( geometry, material ); @@ -155,8 +155,6 @@ class WaterMesh extends Mesh { material.receivedShadowPositionNode = positionWorld.add( distortion ); - material.setupOutgoingLight = () => diffuseColor.rgb; // backwards compatibility - material.colorNode = Fn( () => { const mirrorSampler = reflector(); diff --git a/src/core/Object3D.js b/src/core/Object3D.js index c07fa3063ccf29..c0973e132fdf53 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -354,6 +354,19 @@ class Object3D extends EventDispatcher { */ this.customDistanceMaterial = undefined; + /** + * Whether the 3D object is supposed to be static or not. If set to `true`, it means + * the 3D object is not going to be changed after the initial renderer. This includes + * geometry and material settings. A static 3D object can be processed by the renderer + * slightly faster since certain state checks can be bypassed. + * + * Only relevant in context of {@link WebGPURenderer}. + * + * @type {boolean} + * @default false + */ + this.static = false; + /** * An object that can be used to store custom data about the 3D object. It * should not hold references to functions as these will not be cloned. @@ -1267,6 +1280,7 @@ class Object3D extends EventDispatcher { if ( this.visible === false ) object.visible = false; if ( this.frustumCulled === false ) object.frustumCulled = false; if ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder; + if ( this.static !== false ) object.static = this.static; if ( Object.keys( this.userData ).length > 0 ) object.userData = this.userData; object.layers = this.layers.mask; @@ -1565,6 +1579,8 @@ class Object3D extends EventDispatcher { this.frustumCulled = source.frustumCulled; this.renderOrder = source.renderOrder; + this.static = source.static; + this.animations = source.animations.slice(); this.userData = JSON.parse( JSON.stringify( source.userData ) ); diff --git a/src/loaders/ObjectLoader.js b/src/loaders/ObjectLoader.js index 4e5076a5a82abb..0d0196e0d764a8 100644 --- a/src/loaders/ObjectLoader.js +++ b/src/loaders/ObjectLoader.js @@ -1131,6 +1131,7 @@ class ObjectLoader extends Loader { if ( data.visible !== undefined ) object.visible = data.visible; if ( data.frustumCulled !== undefined ) object.frustumCulled = data.frustumCulled; if ( data.renderOrder !== undefined ) object.renderOrder = data.renderOrder; + if ( data.static !== undefined ) object.static = data.static; if ( data.userData !== undefined ) object.userData = data.userData; if ( data.layers !== undefined ) object.layers.mask = data.layers; diff --git a/src/renderers/common/BundleGroup.js b/src/renderers/common/BundleGroup.js index b0ba2c64111ebd..4be14ac23b743e 100644 --- a/src/renderers/common/BundleGroup.js +++ b/src/renderers/common/BundleGroup.js @@ -44,7 +44,7 @@ class BundleGroup extends Group { /** * Whether the bundle is static or not. When set to `true`, the structure * is assumed to be static and does not change. E.g. no new objects are - * added to the group + * added to the group. * * If a change is required, an update can still be forced by setting the * `needsUpdate` flag to `true`.