Cov txheej txheem:

3D Viewer: 4 Kauj Ruam
3D Viewer: 4 Kauj Ruam

Video: 3D Viewer: 4 Kauj Ruam

Video: 3D Viewer: 4 Kauj Ruam
Video: КОМПАС-3D Viewer (Руководство по программе) 2024, Hlis ntuj nqeg
Anonim
3D Viewer
3D Viewer

Nyob zoo! Txhawm rau kom txaus siab rau kuv txoj kev nyiam ua haujlwm thiab vam tias yuav pab txaus siab rau koj, Kuv xav qhia koj li 3D Viewer uas kuv tau sau rau hauv javascript. Yog tias koj xav txuas ntxiv koj qhov kev nkag siab ntawm 3D kev ua si lossis txawm tias tsim koj tus kheej 3D game, qhov qauv 3D saib no zoo tshaj rau koj.

Kauj Ruam 1: Txoj Kev Xav

Theory
Theory

Txhawm rau nkag siab txoj kev xav ntawm tus saib 3D no, koj tuaj yeem yooj yim tshuaj xyuas txoj hauv kev uas koj saib koj ib puag ncig (nws pab kom muaj ib qho tseem ceeb ntawm lub teeb). Ceeb toom tias:

  1. Cov hom phiaj uas nyob deb dua ntawm koj coj ib feem me me ntawm koj lub zeem muag.
  2. Cov khoom uas nyob deb dua ntawm lub teeb pom kev tsaus xim.
  3. Raws li cov npoo dhau los ua qhov sib luag (tsawg dua ib puag ncig) rau lub teeb pom kev, lawv pom xim tsaus dua.

Kuv txiav txim siab los sawv cev rau lub zeem muag pom nrog ib pawg ntawm txoj kab los ntawm ib qho taw tes (zoo ib yam rau lub qhov muag). Zoo li lub pob ntsia hlau loj, cov kab yuav tsum tau sib nrug sib nrug kom ntseeg tau tias txhua feem ntawm lub zeem muag pom tau zoo ib yam. Hauv daim duab saum toj no, ceeb toom li cas cov kab uas los ntawm lub pob ntsia hlau loj zuj zus thaum lawv txav mus deb ntawm qhov nruab nrab ntawm lub pob. Qhov no pab pom qhov kev zov me nyuam ua qhov kev soj ntsuam 1 txij li qhov ntom ntom ntawm cov kab txo qis vim cov khoom txav mus deb ntawm qhov chaw nruab nrab.

Cov kab yog lub hauv paus tseem ceeb ntawm kev pom kev hauv qhov haujlwm, thiab lawv txhua tus tau teeb tsa rau pixel ntawm cov zaub. Thaum ib txoj kab hla ib qho khoom, nws cov pixel sib xws yog xim raws nws qhov deb ntawm lub teeb ci thiab nws lub kaum sab xis los ntawm lub teeb ci.

Kauj Ruam 2: Siv Txoj Kev Xav

Kev Siv Txoj Haujlwm
Kev Siv Txoj Haujlwm

Txhawm rau kom yooj yim rau txoj haujlwm, lub teeb pom kev zoo ib yam li qhov chaw nruab nrab (lub qhov muag: taw tes los ntawm qhov uas daim duab qhia chaw tau saib thiab qhov twg cov kab pib los ntawm). Zoo sib xws los tuav lub teeb nyob ib sab ntawm koj lub ntsej muag, qhov no tshem tawm cov duab ntxoov ntxoo thiab tso cai rau qhov ci ntawm txhua lub pixel kom suav tau yooj yim dua.

Qhov kev zov me nyuam tseem siv kev sib koom ua ke, nrog lub hauv paus ntsiab lus ntawm lub zeem muag ntawm keeb kwm. Qhov no ua rau cov kab tsim tau yooj yim (txhua qhov tshwj xeeb theta: kab rov tav thiab phi: lub kaum ntse ntse ntsug), thiab muab lub hauv paus ntawm kev suav. Kab nrog tib theta tau teeb tsa rau pixels hauv tib kab. Phis ntawm cov ces kaum sib luag nce thoob txhua kab ntawm pixels.

Txhawm rau ua kom yooj yim rau kev ua lej, daim duab qhia 3D tau tsim los ntawm cov dav hlau nrog qhov sib txawv sib txawv (sib xws x, y, lossis z), thaum lwm qhov ob qhov tsis sib xws uas tsis sib xws raug kaw nyob hauv ib thaj tsam, ua tiav cov ntsiab lus ntawm txhua lub dav hlau.

Txhawm rau saib ib puag ncig nrog nas, qhov kev zov me nyuam qhov sib npaug hauv kev sib hloov ntsug thiab kab rov tav thaum hloov pauv ntawm kheej kheej thiab xyz kev sib koom tes. Qhov no muaj qhov cuam tshuam ntawm preforming kev sib hloov ntawm "pob spike" txheej ntawm kab pom kev.

Kauj Ruam 3: Lej

Cov kab zauv hauv qab no pab kom txoj haujlwm txiav txim siab kab twg cuam tshuam txhua yam khoom thiab cov ntaub ntawv hais txog txhua qhov kev sib tshuam. Kuv tau txais cov kev sib npaug no los ntawm kev sib koom ua haujlwm kheej kheej yooj yim thiab 2D sib npaug sib npaug:

r = nrug, t = theta (kab rov tav), p = phi (ntsug lub kaum ntse ntse), A = kev sib hloov txog Y axis (kev sib hloov ntsug), B = kev sib hloov txog Z axis (kev hloov kab rov tav)

Kx = (sin (p)*cos (t)*cos (A)+cos (p)*sin (A))*cos (B) -sin (p)*sin (t)*sin (B)

Ky = (sin (p)*cos (t)*cos (A)+cos (p)*sin (A))*sin (B)+sin (p)*sin (t)*cos (B)

Kz = -sin (p)*cos (t)*sin (A)+cos (p)*cos (A)

x = r*Kx

y = r*Ky

z = r*Kz

r^2 = x^2+y^2+z^2

teeb pom kev zoo = Klight/r*(Kx lossis Ky lossis Kz)

p = arccos ((x*sin (A)*cos (B)+y*sin (A)*sin (B)+z*cos (A))/r)

t = arccos ((x*cos (B)+y*sin (B) -p*sin (A)*cos (p))/(r*cos (A)*sin (p)))

Kauj Ruam 4: Txoj Haujlwm

Program
Program

Kuv vam tias tsab ntawv pom 3D no pab koj nkag siab txog kev ua haujlwm ntawm 3D qhov tseeb tiag. Nrog qee qhov ua kom zoo dua qub thiab coding, tus saib no yeej muaj peev xwm muab tso rau siv hauv 3D kev txhim kho game.

Pom zoo: