Skip to content

Commit

Permalink
RenderObject: Added .setGeometry()
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Nov 7, 2024
1 parent 3728a0a commit 21f4f53
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/renderers/common/RenderObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ export default class RenderObject {

}

setGeometry( geometry ) {

this.geometry = geometry;
this.attributes = null;

}

getAttributes() {

if ( this.attributes !== null ) return this.attributes;
Expand Down Expand Up @@ -376,6 +383,12 @@ export default class RenderObject {

}

get needsGeometryUpdate() {

return this.geometry.id !== this.object.geometry.id;

}

get needsUpdate() {

return /*this.object.static !== true &&*/ ( this.initialNodesCacheKey !== this.getDynamicCacheKey() || this.clippingNeedsUpdate );
Expand Down
13 changes: 9 additions & 4 deletions src/renderers/common/RenderObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ class RenderObjects {

renderObject.updateClipping( clippingContext );

// force update if geometry has changed
const forceUpdate = renderObject.geometry.id !== renderObject.object.geometry.id;
const needsGeometryUpdate = renderObject.needsGeometryUpdate;

if ( forceUpdate || renderObject.version !== material.version || renderObject.needsUpdate ) {
if ( renderObject.version !== material.version || renderObject.needsUpdate || needsGeometryUpdate ) {

if ( forceUpdate || renderObject.initialCacheKey !== renderObject.getCacheKey() ) {
if ( renderObject.initialCacheKey !== renderObject.getCacheKey() ) {

renderObject.dispose();

Expand All @@ -55,6 +54,12 @@ class RenderObjects {

renderObject.version = material.version;

if ( needsGeometryUpdate ) {

renderObject.setGeometry( object.geometry );

}

}

}
Expand Down

0 comments on commit 21f4f53

Please sign in to comment.