Skip to content

Comments

perf(point_cloud): replace legacy Geometry with BufferGeometry + GPU-side ADC transforms#2

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/optimize-point-cloud-rendering
Draft

perf(point_cloud): replace legacy Geometry with BufferGeometry + GPU-side ADC transforms#2
Copilot wants to merge 2 commits intomainfrom
copilot/optimize-point-cloud-rendering

Conversation

Copy link

Copilot AI commented Feb 23, 2026

Point cloud rendering in Dreamview was bottlenecked by THREE.Geometry's per-vertex JS object model and per-frame CPU-side transform updates, causing severe FPS degradation at high point counts.

Key changes

  • THREE.GeometryTHREE.BufferGeometry + Float32Array
    Eliminates 200k Vector3/Color JS object allocations. Direct typed-array writes are ~10× faster; GPU receives a single contiguous DMA transfer instead of incremental uploads.

  • setDrawRange(0, total) replaces the "hide unused points" loop
    The old code ran a second O(MAX_POINTS) loop every frame to move inactive points to (0,0,-10). Now a single metadata write tells the GPU to skip them entirely.

  • ShaderMaterial with GPU-side ADC transform
    ADC position and Z-rotation are passed as uniforms; the vertex shader applies them directly — no more per-frame Object3D matrix decomposition/recomposition on the CPU. Point-size attenuation matches PointsMaterial's built-in formula to preserve visual parity.

    vec3 transformed = vec3(
      position.x * cosR - position.y * sinR + uOffsetX,
      position.x * sinR + position.y * cosR + uOffsetY,
      position.z + uOffsetZ
    );
    vec4 mvPos = modelViewMatrix * vec4(transformed, 1.0);
    gl_PointSize = 0.25 * uPointScale * projectionMatrix[1][1] / (-mvPos.z);
    gl_Position = projectionMatrix * mvPos;
  • BufferAttribute.dynamic = true
    Flags VBOs as DYNAMIC_DRAW, reducing GPU driver stalls on repeated per-frame uploads.

  • Pre-computed height→color RGB table
    Replaces the per-point if/else + object-map lookup with a direct array index into pre-computed [r, g, b] float triplets, eliminating transient allocations inside the hot loop.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.npmmirror.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --frozen-lockfile (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve the rendering performance of point clouds</issue_title>
<issue_description>The point cloud rendering performance in Dreamview is currently too low and needs to be improved.</issue_description>

<agent_instructions>## 🚀 Copilot Task: Point Cloud Rendering Performance Optimization

1. System Design

Task:
Design a high-performance rendering architecture for large-scale point clouds using Three.js.

Goals:

  • Smooth rendering of millions of points
  • Minimize CPU-to-GPU transfer overhead

Design Highlights:

  • BufferGeometry: Store vertex data in BufferGeometry with typed arrays (Float32Array) for efficient GPU upload. ([Aliyun Developer Community][1])
  • InterleavedBuffer: Use interleaved vertex buffers to improve GPU memory layout and reduce overhead.
  • Shader-side transforms: Apply model transforms in vertex shader rather than updating Object3D position/rotation per frame.
  • Spatial culling: Use octree or other chunking structures to cull parts of the point cloud outside the view. ([MoldStud][2])

2. Analysis of Existing Implementation

Task:
Review the current implementation in https://github.com/wheelos/frontend/blob/main/src/renderer/point_cloud.js (assume it uses Object3D hierarchy and normal BufferGeometry).

Focus Points:

  • Draw calls: How many separate draw calls are triggered? High draw calls degrade performance. ([MoldStud][3])
  • Buffer updates: Are BufferAttribute.needsUpdate calls triggering frequent GPU uploads?
  • CPU vs GPU work: Is per-point coordinate transformation done on CPU or offloaded to GPU?

Performance Bottlenecks:
Estimate where FPS drops occur when rendering ≥ 500k points.


3. Optimization & Implementation

Task:
Provide optimized code snippets addressing key performance issues.

Areas to target:

  • Instancing / batching:
    Use InstancedMesh or merge multiple geometries into a single BufferGeometry to reduce draw calls. ([Three.js][4])
  • ShaderMaterial:
    Create custom shaders (ShaderMaterial) to handle transformations in the GPU and minimize CPU work.
  • Typed arrays:
    Maintain data in Float32Array and minimize array copies to reduce upload cost. ([Aliyun Developer Community][1])

4. Execution Plan

Task:
Lay out a detailed 3-phase plan.

Phase 1 — Baseline Benchmark:

  • Write a script to benchmark current implementation at 100k, 500k, 1M points.
  • Record FPS, draw calls, memory usage.

Phase 2 — Refactor Implementation:

  • Replace naive geometry with optimized BufferGeometry.
  • Implement GPU transform logic via shaders.
  • Optionally use PointsMaterial or optimized point drawing logic.

Phase 3 — Validation & Tuning:

  • Run stress tests and verify memory leaks.
  • Compare performance curves before and after optimization.

📌 Acceptance Criteria

  • Architecture supports efficient point cloud rendering at scale
  • Optimized code snippets provided
  • Benchmarks show clear performance gains
  • Shader-side transforms replace per-Object3D updates
    </agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…rMaterial transforms

Co-authored-by: daohu527 <10419854+daohu527@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve rendering performance of point clouds perf(point_cloud): replace legacy Geometry with BufferGeometry + GPU-side ADC transforms Feb 23, 2026
Copilot AI requested a review from daohu527 February 23, 2026 10:47
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.

Improve the rendering performance of point clouds

2 participants