Overview

When there are many annotations in a 3D viewer, backface culling (Raycast) processing becomes a performance bottleneck. This document explains the improvement techniques adopted.

Problem

Backface culling for annotations requires executing a Raycast (ray-mesh intersection test) for each annotation. This processing becomes heavy for the following reasons:

  • Intersection testing with all mesh vertices is required
  • Computation increases proportionally with the number of annotations
  • Executing every frame makes it difficult to maintain 60 FPS

Solution: Execute Raycast Only During Idle

We adopted an approach that executes Raycast processing only when the camera has stopped.

Operation Flow

CCWENaaaxommieeetcrrrueaa3tc0eamslotfRcvorauipaylnmcagdeatessittoe(nSc~okt0nuie.cnpd5etiRslaeycccoaanmsdetsr,aprfmooocrveesssstiaanbggiali(inlziagthitowne)ight)

Implementation Details

ccu}oos)nnecpi}iiin;PssForfdffeettrneinrleraCsv(deeCeW((EdfCImhtCcletaFa!ixsoADeeaaRedumrindeRrML(ccmmeFsreatelcamEE(kaeesrRnrmeeuyRaR_)mrreaa;aeadFtcanAFceaatmyCsreayc_R=arPMeciocRasceMA>maoocCasueamRtaOMeMsvoosnryeaRssVE{roieuutSsttcCyeteESavtdnnRktRaaocft__ei)tteioeisua.ptTBmdoeRfppfntnscriHEon{re.p.RttuonRFv=.fcRecneRrcgEOecw.uaduuferesSRmcohcryrm.foesHEeapiurcrbc.nnsO_nmylreaeeucctiLRte(ernsnrruenDArcetttrr=gYaaacn+oero=Cm.mat=p+fnenfAopemr;tnla0Suore=tof)tyl.Tnsarrcr)s0ti.a0uear<e1=tp;esme;;ioi;setI3ossisuD0ninrL;.tmganEdiof;_CiovtFasnieRmt)nrAeWa;gMransEaictSteo_mTpBotopEvh(iFeipnOmsrgRee,Enmv_taCtRnahAtymeYhenCrfrAeraeSsaPxThmoe)oesclsiurdtteaiet(fouitnRrge)annry;o>crsaetCsoAtspMmpEaiRolnAnlg_cMembOoeVovfEneo_lmrTyeeH)nRtREsaSyHdcOuaLrsDit;ng(~s0c.r5osll@in6g0)fps)

Two-Stage Culling Process

The Raycast processing itself is also optimized:

  1. First pass (lightweight): Frustum culling + camera front/back check

    • Early elimination of annotations outside the field of view
    • Low computational cost
  2. Second pass (heavy): Raycast check

    • Only targets annotations that passed the first pass
    • Executes mesh intersection testing

Benefits

ItemPrevious MethodAfter Optimization
Raycast frequencyEvery frame or every 15 framesOnly when camera stops
Load during draggingHighNearly zero
Backface culling accuracyAlways accurateAccurate after stopping

Limitations

  • During camera movement, backface culling is not updated, so temporarily inaccurate display may occur
  • However, since it updates immediately after stopping, this is not a practical issue