Notebook - Welcome to Notebook

Contact/Report Bugs
You can contact me at: bkenwright@xbdev.net












OBJ to JSON 3D File Version Converter Basic online web conversion program obj to json var script document createElement script script async false script type text javascript script src https cdn jsdelivr net npm webgl obj loader 2 0 8 dist webgl obj loader min js document head appendChild script let p document createElement p p innerHTML select obj file to convert to json file document body appendChild p let input document createElement input document body appendChild input input type file input onchange onFileSelected function onFileSelected event let selectedFile event target files 0 console log file selectedFile name somefile obj let jsonfilename selectedFile name split 0 json let reader new FileReader reader onload function event let objtxt event target result let mesh new OBJ Mesh objtxt console log Num vertices mesh vertices length console log Num indices mesh indices length console log Num normals mesh normals mesh normals length 0 let json vertices mesh vertices faces mesh indices normals mesh vertexNormals mesh vertexNormals console log output json jsonfilename let txt JSON stringify json null 4 let a document createElement a document body appendChild a a href data text plain charset utf 8 encodeURIComponent txt a setAttribute download jsonfilename cheburashka json a click document body removeChild a reader readAsText selectedFile console log ready OBJ to JSON 3D File Version Converter Custom version that allows the mesh to be triangulated or merge multiple meshes into a single mesh let p document createElement p p innerHTML select obj file to convert to json file document body appendChild p let input document createElement input document body appendChild input input type file input onchange onFileSelected function onFileSelected event let selectedFile event target files 0 console log file selectedFile name somefile obj let jsonfilename selectedFile name split 0 json let reader new FileReader reader onload function event let objtxt event target result let mesh new readObj objtxt console log Num vertices mesh 0 v length console log Num indices mesh 0 f length console log Num normals mesh 0 n mesh 0 n length 0 let json vertices mesh 0 v faces mesh 0 f normals mesh 0 n mesh 0 n console log output json jsonfilename let txt JSON stringify json null 4 let a document createElement a document body appendChild a a href data text plain charset utf 8 encodeURIComponent txt a setAttribute download jsonfilename cheburashka json a click document body removeChild a reader readAsText selectedFile console log ready ref https notebook xbdev net index php page obj function readObj txt console log readObj let objects objects push name test v vt vn f usemtl let data v n f txt txt replaceAll let lines txt split n console log num lines lines length for let i 0 i lines length i let line lines i line line trim if line length 2 continue if line 0 continue let parts line split if parts length 1 continue switch parts 0 case v v 0 089624 1 419387 0 052847 objects reverse 0 v push parts 1 objects reverse 0 v push parts 2 objects reverse 0 v push parts 3 break case vt vt 0 818181 0 000000 objects reverse 0 vt push parts 1 objects reverse 0 vt push parts 2 break case vn vn 0 5499 0 7413 0 3847 objects reverse 0 vn push parts 1 objects reverse 0 vn push parts 2 objects reverse 0 vn push parts 3 break case f f 1 1 1 14 2 1 13 3 1 f v1 vt1 vn1 v2 vt2 vn2 v3 vt3 vn3 f v1 vn1 v2 vn2 v3 vn3 double slashes If you have 4 indices e g 0 1 2 3 The division into two triangles would be one with the first 3 indices and one with the first third and fourth In this example 0 1 2 0 2 3 Let s try some ASCII art to illustrate this 3 2 0 1 let i0 parts 1 split 0 1 let i1 parts 2 split 0 1 let i2 parts 3 split 0 1 let i3 parts length 4 undefined parts 4 split 0 1 let n0 parts 1 split 2 1 let n1 parts 2 split 2 1 let n2 parts 3 split 2 1 let n3 parts length 4 undefined parts 4 split 2 1 if parts 1 includes n0 parts 1 split 1 1 n1 parts 2 split 1 1 n2 parts 3 split 1 1 n3 parts length 4 undefined parts 4 split 1 1 if i3 undefined triangles for let g 0 g 3 g let idx i0 i1 i2 g let x0 objects reverse 0 v 3 idx 0 let y0 objects reverse 0 v 3 idx 1 let z0 objects reverse 0 v 3 idx 2 data v push x0 data v push y0 data v push z0 data f push data f length for let g 0 g n0 n1 n2 length g let nx0 objects reverse 0 vn 3 n0 n1 n2 g 0 let ny0 objects reverse 0 vn 3 n0 n1 n2 g 1 let nz0 objects reverse 0 vn 3 n0 n1 n2 g 2 data n push nx0 data n push ny0 data n push nz0 else quads let v for let g 0 g 4 g let idx i0 i1 i2 i3 g let x0 objects reverse 0 v 3 idx 0 let y0 objects reverse 0 v 3 idx 1 let z0 objects reverse 0 v 3 idx 2 v push x x0 y y0 z z0 data v push v 0 x data v push v 0 y data v push v 0 z data v push v 1 x data v push v 1 y data v push v 1 z data v push v 2 x data v push v 2 y data v push v 2 z data f push data f length data v push v 0 x data v push v 0 y data v push v 0 z data v push v 2 x data v push v 2 y data v push v 2 z data v push v 3 x data v push v 3 y data v push v 3 z data f push data f length let n for let g 0 g 4 g let idx n0 n1 n2 n3 g let nx0 objects reverse 0 vn 3 idx 0 let ny0 objects reverse 0 vn 3 idx 1 let nz0 objects reverse 0 vn 3 idx 2 n push x nx0 y ny0 z nz0 data n push n 0 x data n push n 0 y data n push n 0 z data n push n 1 x data n push n 1 y data n push n 1 z data n push n 2 x data n push n 2 y data n push n 2 z data n push n 0 x data n push n 0 y data n push n 0 z data n push n 2 x data n push n 2 y data n push n 2 z data n push n 3 x data n push n 3 y data n push n 3 z break end switch for return data readObj

break case f f 1 1 1 14 2 1 13 3 1 f v1 vt1 vn1 v2 vt2 vn2 v3 vt3 vn3 f v1 vn1 v2 vn2 v3 vn3 double slashes If you have 4 indices e g 0 1 2 3 The division into two triangles would be one with the first 3 indices and one with the first third and fourth In this example 0 1 2 0 2 3 Let s try some ASCII art to illustrate this 3 2 0 1 let i0 parts 1 split 0 1 let i1 parts 2 split 0 1 let i2 parts 3 split 0 1 let i3 parts length 4 undefined parts 4 split 0 1 let n0 parts 1 split 2 1 let n1 parts 2 split 2 1 let n2 parts 3 split 2 1 let n3 parts length 4 undefined parts 4 split 2 1 if parts 1 includes n0 parts 1 split 1 1 n1 parts 2 split 1 1 n2 parts 3 split 1 1 n3 parts length 4 undefined parts 4 split 1 1 if i3 undefined triangles for let g 0 g 3 g let idx i0 i1 i2 g let x0 objects reverse 0 v 3 idx 0 let y0 objects reverse 0 v 3 idx 1 let z0 objects reverse 0 v 3 idx 2 data v push x0 data v push y0 data v push z0 data f push data f length for let g 0 g n0 n1 n2 length g let nx0 objects reverse 0 vn 3 n0 n1 n2 g 0 let ny0 objects reverse 0 vn 3 n0 n1 n2 g 1 let nz0 objects reverse 0 vn 3 n0 n1 n2 g 2 data n push nx0 data n push ny0 data n push nz0 else quads let v for let g 0 g 4 g let idx i0 i1 i2 i3 g let x0 objects reverse 0 v 3 idx 0 let y0 objects reverse 0 v 3 idx 1 let z0 objects reverse 0 v 3 idx 2 v push x x0 y y0 z z0 data v push v 0 x data v push v 0 y data v push v 0 z data v push v 1 x data v push v 1 y data v push v 1 z data v push v 2 x data v push v 2 y data v push v 2 z data f push data f length data v push v 0 x data v push v 0 y data v push v 0 z data v push v 2 x data v push v 2 y data v push v 2 z data v push v 3 x data v push v 3 y data v push v 3 z data f push data f length let n for let g 0 g 4 g let idx n0 n1 n2 n3 g let nx0 objects reverse 0 vn 3 idx 0 let ny0 objects reverse 0 vn 3 idx 1 let nz0 objects reverse 0 vn 3 idx 2 n push x nx0 y ny0 z nz0 data n push n 0 x data n push n 0 y data n push n 0 z data n push n 1 x data n push n 1 y data n push n 1 z data n push n 2 x data n push n 2 y data n push n 2 z data n push n 0 x data n push n 0 y data n push n 0 z data n push n 2 x data n push n 2 y data n push n 2 z data n push n 3 x data n push n 3 y data n push n 3 z break end switch for return data readObj

2dracecargame
3dplot
a4print
about
acejs
acejs2
acejs3
aessecurity
angularjs
animbackgroundimage
aseformat
assert
asteroidsjs
backgrounds01
backgrounds02
backgrounds03
barnsleyfern
base26
base64
bib
binary
bodypix
bouncy
box2dweb
breakoutjs
browserversion
buslanes
busybutton
bvhreader
calendar
candycrush
candycrush2
canvas
canvas2
canvas3
canvasmandelbrot
canvasmandelbrot2
canvasnumbers
canvaszoom
capsule
changingimages
chaosgame
chaosrandom
chaosrandomhisto
chaosrandomhisto2
chatgptusingopenai
chatgptusingopenai2
chatgptusingopenai3
checkboxtoggle
chinesetiles
classes
classfeatures
clipboardbutton
clonenode
codedropdown
codemirror
codemirror2
collada
colorpick
columnresizer
contextmenu
convnet
cookiebanner
countdown
countdown2
countdown3
crop
css3dbarchart
css3dbarchart2
css3dbook
css3dscene
csscube
csscube2
csscube3
csscubevideos
cssfilelist
csshas
csspulse
cssresizeaspect
cssspin
csszooming
csvtoarray
curleffect
customcheckbox
d3datamap
d3js
d3js10
d3js11
d3js2
d3js3
d3js4
d3js5
d3js6
d3js7
d3js8
d3js9
d3jsanimatedgrid
d3jsarctransition
d3jsarctransition2
d3jsaxis
d3jsaxischanging
d3jsbars
d3jsbrushing
d3jsbuslanes
d3jsbuslanes2
d3jscalendar
d3jscheat
d3jsclock
d3jscloudmap
d3jscogs
d3jscolors
d3jscovid
d3jscovid2
d3jscovid3
d3jsdashboard
d3jsdashboard2
d3jsdashboard3
d3jsdatakeyfunction
d3jsdensity
d3jsdragresizing
d3jsdragresizing2
d3jseach
d3jsease
d3jsevents
d3jsflower
d3jsforcegroups
d3jsforces
d3jsforces2
d3jsfractaltree
d3jsgeo
d3jsgroupbars
d3jsgroups
d3jsheatmap
d3jshex
d3jshierarchies
d3jshierarchies2
d3jshistogram
d3jshistogram2
d3jshistogram3
d3jshistogram4
d3jsinterpolate
d3jsjoin
d3jskmean
d3jskmean2
d3jsline
d3jsline2
d3jsline3
d3jsline4
d3jslinetransition
d3jslinetransition0
d3jslinetransition2
d3jsmaplocations
d3jsmaps
d3jsmaps2
d3jsmaps3
d3jsmisc
d3jsmisc2
d3jsmodule
d3jsmodulecolor
d3jsmultistyles
d3jsnobel
d3jsoverlappinggraphs
d3jspanel
d3jspie
d3jspieinterpolate
d3jssankey
d3jssankey2
d3jsscatter
d3jsshapes
d3jsslider
d3jsspending
d3jsspending2
d3jsspiralplot
d3jsspirograph
d3jssquare
d3jsstack
d3jsstackedbar
d3jsstackedbar2
d3jssunburst
d3jssunmoon
d3jssvglines
d3jssymbols
d3jstimelines
d3jsuk
d3jsvoronoi
d3scatterplot
d3timeline
d3timeline2
datalist
datamuse
date
dblclickhighlight
deviceorientation
dictionaryapi
dockermenu
doodlepad
downloadgif
dragdroplistitems
dragrotateresizediv
dragrotateresizediv2
dragrotateresizediv3
dragrotateresizediv4
dragrotateresizefontsize
dragselectbrush
drawlinesdiv
dropdown
dualquaternionimages
dynamicgrid
easefunctions
easeinterpolate3dplots
echart
echart2
echart3
encapsulation
epubviewer
errorstack
excalidraw
excalidraw2
excalidraw3
excalidraw5
expandable
faker
fetchplus
fileupload
fixedtopbar
fluiddynamics
fluiddynamics2
fluiddynamics3
fluidsmokedynamics
fluidsmokedynamics2
fonts
fonts2
footerbar
fractalmaze
fractalmaze2
fractalnoiseimage
fractals
fractals2
fractaltree
freesvg
fresnel
froggerjs
gantt
gifgiphyapi
gifhex
gltffromscratch
gradients
griditems
griditems2
griditems3
griditems4
gridworms
heat
hexview
hexview2
highlight
icons
icons2
iframes
ik
imagetracertosvg
imgur
inputfile
invadersjs
ipynb
ipynb2
ipynb3
ipynb4
isbn13
isbn2
jpghex
jquery
jquery2
jqueryui
jqueryui2
jsdraganddrop
jsfire
jslint
jsobfuscate
jsraytracer
jstree
jstree2
jszip
jszipimages
jszipread
keyframes
l2dwidget
lda
leftmenu
less
less2
lineargradientimage
linenumbers
loadimagefromfile
makepdf
maps
markdown
markdown2
markdownalerts
markdownalerts2
markdownbookmarks
markovimage
markovpixelblocks
mathjax
matrices
matsandvects
mazegamejs
md2tex
metrotiles
metrowindows
milestones
minkowski2dboxes
misc
misc2
modules
myipdetails
mymodplotly
neataptic
networkstructures
networkstructures2
neural_network_drawshape
neural_network_plot_in_vs_out
neuralnetworkarrays
neuralnetworkblocks
neuralnetworksinewave
neuralnetworksnolibs
neuralnetworkvisualization
number
obj
objtojson
openaiimages
opencv
opencv2
opencv3
opencv4
opencv5
outline
p2
p5fractalleaf
p5fractalshape
p5js
p5js2
p5js3
p5jsanimatedcover
p5mengercube
p5snowflakes
palindrome
panel
parallax
paste
paste2
pasteimgfromurl
pdfjs
pdfjs2
pdfkit
pdfkit2
pdfkit3
pdfkit4
pdfkit5
pdfkit6
pdfmake
pdfmake2
pdfmake3
pdfmake4
pdfmake5
pdfmake6
perlin
perlin2
perlin3
perspective
pexels
pixelgridpattern
playground
plotly
plotlynoise
plotlyranddist
plyloader
plyloader2
pngtxtencoder
pongjs
pptxgenjs
prettycode
prism
prn
problems
progress
pseudorandom
px2svg
python
quotes
racergame
random
randomcalcpie
randomgenerator
randomprofilepatterns
randomsinhistogram
randomstring
rating
rayambient
raymonte
raymonteprogressive
raymonteprogressive2
raymontewarmstart
reexpcross
reexpcross2
regex
regexbib
regexpfixbib
regexpmultiline
repeatwordsregexp
resizabletable
resizabletable2
revealjs
revealjs2
revealjsmulti
ritalanguage
ritalanguage2
ritalanguage3
rotateimg
rough
rsapublicprivatekeys
rss
rss2
sankey
scrappingsvg
scrolltext
scrolltext2
scrollwidth
sdf2dcanvas
sdfboxinboxtwist
sdfchessbishop
sdfchessking
sdfchessknight
sdfchesspawn
sdfchessqueen
sdfchessrook
sdfhollowbox
setintervalexception
shareurl
shuffle
sidecomment
similarity
simplehighlighter
simpleplatformgamejs
sinecanvas
sliderpopout
slides
smileys
snowfall
snowman
sound
soundsignal
sphererayintersection
springs
sqljs
steganography
stereogram
stringmatching
sudoku
sudoku2
sudoku3
svg
svgchaos
svgdragresize
svgdragresize2
svgdragresize3
svgdragrotate
svgdrawing
svglines
svglines2
svglines3
svglines4
svglines5
svglinesmandelbrot
svgpathsdragrotate
svgpathsdragrotateresize
svgpie
svgpie2
svgpie3
svgpiepath
svgpiepath2
svgrandomfaces
symbols
synaptic
synaptic2
synonyms
tablerotatecells
tablerotatecells2
tablerotatecells3
tablerotatecells3b
tablerotatecells4
tables
tablezebra
tabularjs
tabularjs2
tabulatordownload
tagcanvas
tensorflowgan
tensorflowjs
tensorflowjsbasic
tensorflowjscnn
tensorflowjssinewave
tensorflowjssound
tensorflowmobilenet
tetrahedronfractal
tetrahedronfractalfolding
tetris
textarea
textareaauto
textareadiv
textareadiv2
textmaskimage
theirorthere
thesaurus
threejs
threejs2
threejs3
threejs4
threejsgltf
threejstokyo
tiles
toaster
tooltip
transition
transitionexpandabledropdown
treeview
treeview2
tricks
tshirt
tshirt2
tshirt3
turningpages
unsplash
urlblob
urlblob2
userdefinepoints
vector
videos
videos2
visualsort
vue
w2ui
w2uientertextdialog
webcam
webgl
webgl2
webgl3
webgl4
webgl5
webglbasic1
webglbasic2
webglcube
webglfov
webglfrustum
webgljson
webglleaves
webgllighting
webglorthographic
webglpoints1
webglpoints2
webglpoints3
webglsquare
webgltexture1
webgltexture2
webgltexture3
webgltransforms
webgltriangle
webgpu
webgpu10
webgpu11
webgpu12
webgpu13
webgpu14
webgpu15
webgpu16
webgpu17
webgpu2
webgpu3
webgpu4
webgpu5
webgpu6
webgpu7
webgpu8
webgpu9
webgpubars
webgpubuffers
webgpubuffers2
webgpucellnoise
webgpuclouds
webgpuclydescope
webgpucompute
webgpucubemap
webgpucubemap2
webgpudeferred
webgpudepth
webgpudof
webgpudrops
webgpuetha
webgpufire
webgpufractalcubes
webgpuglassrain
webgpugltf
webgpugltf2
webgpugrass
webgpugrid
webgpukernel
webgpukleinian
webgpulabupdates
webgpulighting
webgpumandelbrot
webgpumeta3d
webgpumetaballs
webgpumouse
webgpunoise
webgpunormalmapping
webgpuobj
webgpuparallax
webgpuparallax2
webgpuparallax3
webgpuparallaxshadow
webgpuparallaxshadow2
webgpupixel
webgpuquad
webgpuray1
webgpuraytracing
webgpuraytracing2
webgpushadowmaps
webgpushadowmaps2
webgpusierpinski2d
webgpusierpinski3d
webgpusinusoid
webgpussao
webgpustadiumobj
webgpuswirl
webgputestpipe3
webgputoon
webgputopology
webgputt
webgpuvolcloud
webgpuwater
webgpuwireframe
webgpuwireframe2
webpcanvas
webworkers
webxr
webxr2
wiggly
wikipedia