Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpriteNodeMaterial: Add sizeAttenuation #29394

Merged
merged 22 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/materials/nodes/SpriteNodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SpriteNodeMaterial extends NodeMaterial {
this.isSpriteNodeMaterial = true;

this.lights = false;
this._useSizeAttenuation = true;

this.positionNode = null;
this.rotationNode = null;
Expand All @@ -37,7 +38,9 @@ class SpriteNodeMaterial extends NodeMaterial {

}

setupPosition( { object, context } ) {
setupPosition( { object, camera, context } ) {

const useSizeAttenuation = this.sizeAttenuation;
WestLangley marked this conversation as resolved.
Show resolved Hide resolved

// < VERTEX STAGE >

Expand All @@ -55,6 +58,13 @@ class SpriteNodeMaterial extends NodeMaterial {

}


if ( ! useSizeAttenuation && camera.isPerspectiveCamera ) {

scale = scale.mul( mvPosition.z.negate() );

}

let alignedPosition = vertex.xy;

if ( object.center && object.center.isVector2 === true ) {
Expand Down Expand Up @@ -89,6 +99,23 @@ class SpriteNodeMaterial extends NodeMaterial {

}

get sizeAttenuation() {

return this._useSizeAttenuation;

}

set sizeAttenuation( value ) {

if ( this._useSizeAttenuation !== value ) {

this._useSizeAttenuation = value;
this.needsUpdate = true;

}

}

}

export default SpriteNodeMaterial;
6 changes: 6 additions & 0 deletions src/renderers/common/RenderObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ export default class RenderObject {

}

if ( object.center ) {

cacheKey += object.center.x + ',' + object.center.y + ',';
sunag marked this conversation as resolved.
Show resolved Hide resolved

}

if ( object.count > 1 ) {

cacheKey += object.count + ',' + object.uuid + ',';
Expand Down