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

Nodes: cleanup #30225

Closed
wants to merge 1 commit into from
Closed

Nodes: cleanup #30225

wants to merge 1 commit into from

Conversation

linbingquan
Copy link
Contributor

Related issue: #XXXX

Description

Reduced variable access and reduced packaging volume

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.44
79.06
339.44
79.06
+0 B
+0 B
WebGPU 489.24
135.78
489.23
135.79
-13 B
+6 B
WebGPU Nodes 488.71
135.66
488.69
135.67
-13 B
+6 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.3
112.11
465.3
112.11
+0 B
+0 B
WebGPU 558.8
151.3
558.78
151.3
-13 B
+5 B
WebGPU Nodes 514.87
141.07
514.86
141.08
-13 B
+5 B

@linbingquan
Copy link
Contributor Author

linbingquan commented Dec 28, 2024

The code length is smaller, I don't know why the compression report shows an increase...

before

getForRender(e){const t=this.get(e);let r=t.nodeBuilderState;if(void 0===r){const{nodeBuilderCache:s}=this,i=this.getForRenderCacheKey(e);if(r=s.get(i),void 0===r){const t=this.backend.createNodeBuilder(e.object,this.renderer);t.scene=e.scene,t.material=e.material,t.camera=e.camera,t.context.material=e.material,t.lightsNode=e.lightsNode,t.environmentNode=this.getEnvironmentNode(e.scene),t.fogNode=this.getFogNode(e.scene),t.clippingContext=e.clippingContext,t.build(),r=this._createNodeBuilderState(t),s.set(i,r)}r.usedTimes++,t.nodeBuilderState=r}return r}

after

getForRender(e){const t=this.get(e);let r=t.nodeBuilderState;if(void 0===r){const{nodeBuilderCache:s}=this,i=this.getForRenderCacheKey(e);if(r=s.get(i),void 0===r){const t=this.backend.createNodeBuilder(e.object,this.renderer),n=e.scene,o=e.material;t.scene=n,t.material=o,t.camera=e.camera,t.context.material=o,t.lightsNode=e.lightsNode,t.environmentNode=this.getEnvironmentNode(n),t.fogNode=this.getFogNode(n),t.clippingContext=e.clippingContext,t.build(),r=this._createNodeBuilderState(t),s.set(i,r)}r.usedTimes++,t.nodeBuilderState=r}return r}

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 2, 2025

Sorry, I do not vote to apply such changes on that granularity level. I fear this will lead to an endless series of PRs with many minor modifications. I mean I get the idea behind the suggested change but the tiny benefits do not justify the related effort.

@Mugen87 Mugen87 closed this Jan 2, 2025
@Mugen87 Mugen87 added this to the r173 milestone Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants