{"version":3,"file":"bundle.js","mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;ACt3aA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC3MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACpFA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;AC5DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACtEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;AC96BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC3IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;AChIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;AC/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;ACpQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;AC/KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;AC9XA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;AChHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC9JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AC3GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;AC3HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;AChKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;AClLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACpEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AC9HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACrHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;AC9BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;AC1QA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;AC3aA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACxIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC/FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACNA;;;;;;;;;;;;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":["webpack://Multi_Poc/./node_modules/babylonjs-loaders/babylonjs.loaders.min.js","webpack://Multi_Poc/./node_modules/babylonjs-materials/babylonjs.materials.min.js","webpack://Multi_Poc/./node_modules/babylonjs/babylon.js","webpack://Multi_Poc/./node_modules/cannon/build/cannon.js","webpack://Multi_Poc/./src/index.css","webpack://Multi_Poc/./node_modules/css-loader/dist/runtime/api.js","webpack://Multi_Poc/./node_modules/css-loader/dist/runtime/noSourceMaps.js","webpack://Multi_Poc/./src/index.css?cfe4","webpack://Multi_Poc/./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js","webpack://Multi_Poc/./node_modules/style-loader/dist/runtime/insertBySelector.js","webpack://Multi_Poc/./node_modules/style-loader/dist/runtime/insertStyleElement.js","webpack://Multi_Poc/./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js","webpack://Multi_Poc/./node_modules/style-loader/dist/runtime/styleDomAPI.js","webpack://Multi_Poc/./node_modules/style-loader/dist/runtime/styleTagTransform.js","webpack://Multi_Poc/./src/scripts/BallonAnim.js","webpack://Multi_Poc/./src/scripts/CarManager.js","webpack://Multi_Poc/./src/scripts/Common.js","webpack://Multi_Poc/./src/scripts/Components/FanComponentGenerator.js","webpack://Multi_Poc/./src/scripts/Components/LightComponent.js","webpack://Multi_Poc/./src/scripts/Effects/FlameEffectGenerator.js","webpack://Multi_Poc/./src/scripts/GameManager.js","webpack://Multi_Poc/./src/scripts/Helper/ColorSensorGenerator.js","webpack://Multi_Poc/./src/scripts/Helper/DistanceSensorGenerator.js","webpack://Multi_Poc/./src/scripts/Helper/DistanceSensorGenerator2.js","webpack://Multi_Poc/./src/scripts/Helper/FanSensor.js","webpack://Multi_Poc/./src/scripts/Helper/FlameSensorGenerator.js","webpack://Multi_Poc/./src/scripts/Helper/MyJoints.js","webpack://Multi_Poc/./src/scripts/Helper/ObstacleGenerator.js","webpack://Multi_Poc/./src/scripts/LoaderManager.js","webpack://Multi_Poc/./src/scripts/Map.js","webpack://Multi_Poc/./src/scripts/MyRecorder.js","webpack://Multi_Poc/./src/scripts/SceneConfig.js","webpack://Multi_Poc/./src/scripts/SceneManager.js","webpack://Multi_Poc/./src/scripts/SceneOptimiser.js","webpack://Multi_Poc/./src/scripts/WorldManager.js","webpack://Multi_Poc/./src/scripts/Wrapper/MyRobo.js","webpack://Multi_Poc/./src/scripts/scene/FireFightingScene.js","webpack://Multi_Poc/./src/scripts/scene/MazeScene.js","webpack://Multi_Poc/./src/scripts/scene/demoscene.js","webpack://Multi_Poc/./src/scripts/units.js","webpack://Multi_Poc/./src/scripts/utils.js","webpack://Multi_Poc/webpack/bootstrap","webpack://Multi_Poc/webpack/runtime/compat get default export","webpack://Multi_Poc/webpack/runtime/define property getters","webpack://Multi_Poc/webpack/runtime/global","webpack://Multi_Poc/webpack/runtime/hasOwnProperty shorthand","webpack://Multi_Poc/webpack/runtime/make namespace object","webpack://Multi_Poc/webpack/runtime/nonce","webpack://Multi_Poc/./src/index.js"],"sourcesContent":["!function(e,t){\"object\"==typeof exports&&\"object\"==typeof module?module.exports=t(require(\"babylonjs\")):\"function\"==typeof define&&define.amd?define(\"babylonjs-loaders\",[\"babylonjs\"],t):\"object\"==typeof exports?exports[\"babylonjs-loaders\"]=t(require(\"babylonjs\")):e.LOADERS=t(e.BABYLON)}(\"undefined\"!=typeof self?self:\"undefined\"!=typeof global?global:this,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,\"a\",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=\"\",n(n.s=20)}([function(t,n){t.exports=e},function(e,t,n){\"use strict\";n.d(t,\"a\",(function(){return a})),n.d(t,\"b\",(function(){return i}));var r=n(0),o=n(2),a=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error(e+\": Failed to find index (\"+n+\")\");return t[n]},e.Assign=function(e){if(e)for(var t=0;t \"+o.GLTFLoaderState[o.GLTFLoaderState.READY],s=o.GLTFLoaderState[o.GLTFLoaderState.LOADING]+\" => \"+o.GLTFLoaderState[o.GLTFLoaderState.COMPLETE];n._parent._startPerformanceCounter(i),n._parent._startPerformanceCounter(s),n._setState(o.GLTFLoaderState.LOADING),n._extensionsOnLoading();var l=new Array,u=n._babylonScene.blockMaterialDirtyMechanism;if(n._babylonScene.blockMaterialDirtyMechanism=!0,e)l.push(n.loadSceneAsync(\"/nodes\",{nodes:e,index:-1}));else if(null!=n._gltf.scene||n._gltf.scenes&&n._gltf.scenes[0]){var c=a.Get(\"/scene\",n._gltf.scenes,n._gltf.scene||0);l.push(n.loadSceneAsync(\"/scenes/\"+c.index,c))}if(n.parent.loadAllMaterials&&n._gltf.materials)for(var d=0;de.bin.byteLength)&&r.Logger.Warn(\"Binary buffer length (\"+n.byteLength+\") from JSON does not match chunk length (\"+e.bin.byteLength+\")\"),this._bin=e.bin}else r.Logger.Warn(\"Unexpected BIN chunk\")}},e.prototype._setupData=function(){if(a.Assign(this._gltf.accessors),a.Assign(this._gltf.animations),a.Assign(this._gltf.buffers),a.Assign(this._gltf.bufferViews),a.Assign(this._gltf.cameras),a.Assign(this._gltf.images),a.Assign(this._gltf.materials),a.Assign(this._gltf.meshes),a.Assign(this._gltf.nodes),a.Assign(this._gltf.samplers),a.Assign(this._gltf.scenes),a.Assign(this._gltf.skins),a.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t=2)throw new Error(t+\"/texCoord: Invalid value (\"+n.texCoord+\")\");var s=a.Get(t+\"/index\",this._gltf.textures,n.index);s._textureInfo=n;var l=this._loadTextureAsync(\"/textures/\"+n.index,s,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),l},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen(t+\" \"+(n.name||\"\"));var i=null==n.sampler?e.DefaultSampler:a.Get(t+\"/sampler\",this._gltf.samplers,n.sampler),s=a.Get(t+\"/source\",this._gltf.images,n.source),l=this._createTextureAsync(t,i,s,r);return this.logClose(),l},e.prototype._createTextureAsync=function(e,t,n,o,a){var i=this;void 0===o&&(o=function(){});var s=this._loadSampler(\"/samplers/\"+t.index,t),l=new Array,u=new r.Deferred;this._babylonScene._blockEntityCollection=this._forAssetContainer;var c=new r.Texture(null,this._babylonScene,s.noMipMaps,!1,s.samplingMode,(function(){i._disposed||u.resolve()}),(function(t,n){i._disposed||u.reject(new Error(e+\": \"+(n&&n.message?n.message:t||\"Failed to load texture\")))}),void 0,void 0,void 0,n.mimeType,a);return this._babylonScene._blockEntityCollection=!1,l.push(u.promise),l.push(this.loadImageAsync(\"/images/\"+n.index,n).then((function(e){var t=n.uri||i._fileName+\"#image\"+n.index,r=\"data:\"+i._uniqueRootUrl+t;c.updateURL(r,e)}))),c.wrapU=s.wrapU,c.wrapV=s.wrapV,o(c),Promise.all(l).then((function(){return c}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode(t+\"/wrapS\",n.wrapS),wrapV:e._GetTextureWrapMode(t+\"/wrapT\",n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen(e+\" \"+(t.name||\"\")),t.uri)t._data=this.loadUriAsync(e+\"/uri\",t,t.uri);else{var n=a.Get(e+\"/bufferView\",this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(\"/bufferViews/\"+n.index,n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,o){var a=this,i=this._extensionsLoadUriAsync(t,n,o);if(i)return i;if(!e._ValidateUri(o))throw new Error(t+\": '\"+o+\"' is invalid\");if(r.Tools.IsBase64(o)){var s=new Uint8Array(r.Tools.DecodeBase64(o));return this.log(\"Decoded \"+o.substr(0,64)+\"... (\"+s.length+\" bytes)\"),Promise.resolve(s)}return this.log(\"Loading \"+o),this._parent.preprocessUrlAsync(this._rootUrl+o).then((function(e){return new Promise((function(n,i){a._parent._loadFile(e,a._babylonScene,(function(e){a._disposed||(a.log(\"Loaded \"+o+\" (\"+e.byteLength+\" bytes)\"),n(new Uint8Array(e)))}),!0,(function(e){i(new r.LoadFileError(t+\": Failed to load '\"+o+\"'\"+(e?\": \"+e.status+\" \"+e.statusText:\"\"),e))}))}))}))},e.AddPointerMetadata=function(e,t){var n=e.metadata=e.metadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return r.Texture.CLAMP_ADDRESSMODE;case 33648:return r.Texture.MIRROR_ADDRESSMODE;case 10497:return r.Texture.WRAP_ADDRESSMODE;default:return r.Logger.Warn(e+\": Invalid value (\"+t+\")\"),r.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,o=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(o){case 9728:return r.Texture.LINEAR_NEAREST;case 9729:return r.Texture.LINEAR_LINEAR;case 9984:return r.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return r.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return r.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return r.Texture.LINEAR_LINEAR_MIPLINEAR;default:return r.Logger.Warn(e+\"/minFilter: Invalid value (\"+o+\")\"),r.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&r.Logger.Warn(e+\"/magFilter: Invalid value (\"+n+\")\"),o){case 9728:return r.Texture.NEAREST_NEAREST;case 9729:return r.Texture.NEAREST_LINEAR;case 9984:return r.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return r.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return r.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return r.Texture.NEAREST_LINEAR_MIPLINEAR;default:return r.Logger.Warn(e+\"/minFilter: Invalid value (\"+o+\")\"),r.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error(e+\": Invalid component type \"+t)}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor(t+\"/componentType\",n);try{return new s(i,o,a)}catch(e){throw new Error(t+\": \"+e)}},e._GetNumComponents=function(e,t){switch(t){case\"SCALAR\":return 1;case\"VEC2\":return 2;case\"VEC3\":return 3;case\"VEC4\":case\"MAT2\":return 4;case\"MAT3\":return 9;case\"MAT4\":return 16}throw new Error(e+\": Invalid type (\"+t+\")\")},e._ValidateUri=function(e){return r.Tools.IsBase64(e)||-1===e.indexOf(\"..\")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return r.Material.PointListDrawMode;case 1:return r.Material.LineListDrawMode;case 2:return r.Material.LineLoopDrawMode;case 3:return r.Material.LineStripDrawMode;case 4:return r.Material.TriangleFillMode;case 5:return r.Material.TriangleStripDrawMode;case 6:return r.Material.TriangleFanDrawMode}throw new Error(e+\": Invalid mesh primitive mode (\"+t+\")\")},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter(\"Compile materials\");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n-1&&s.materials.splice(t,1),(t=l.indexOf(e))>-1&&l.splice(t,1)}))}));var u=[];a.onTextureLoadedObservable.add((function(e){u.push(e),e.onDisposeObservable.addOnce((function(){var t=s.textures.indexOf(e);t>-1&&s.textures.splice(t,1),(t=u.indexOf(e))>-1&&u.splice(t,1)}))}));var c=[];return a.onCameraLoadedObservable.add((function(e){c.push(e)})),a._loader.importMeshAsync(null,e,!0,t,n,r,o).then((function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,l),Array.prototype.push.apply(s.textures,u),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),s}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf(\"asset\")&&-1!==t.indexOf(\"version\")||i.StringTools.StartsWith(t,\"data:base64,\"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,\"data:application/octet-stream;base64,\"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,\"data:model/gltf-binary;base64,\"+e.magicBase64Encoded)},e.prototype.directLoad=function(t,n){if(i.StringTools.StartsWith(n,\"base64,\"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,\"application/octet-stream;base64,\"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,\"model/gltf-binary;base64,\"+e.magicBase64Encoded)){var r=i.Tools.DecodeBase64(n);return this._validate(t,r),this._unpackBinaryAsync(new i.DataReader({readAsync:function(e,t){return Promise.resolve(new Uint8Array(r,e,t))},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,\"loaderState\",{get:function(){return this._loader?this._loader.state:null},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._loadFile=function(e,t,n,r,o){var a=this,i=t._loadFile(e,n,(function(e){a._onProgress(e,i)}),void 0,r,o);return i.onCompleteObservable.add((function(e){a._requests.splice(a._requests.indexOf(e),1)})),this._requests.push(i),i},e.prototype._requestFile=function(e,t,n,r,o,a){var i=this,s=t._requestFile(e,n,(function(e){i._onProgress(e,s)}),void 0,r,o,a);return s.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a0)throw new Error(\"Incompatible minimum version: \"+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error(\"Unsupported version: \"+n.version);return a(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter(\"Parse JSON\"),this._log(\"JSON length: \"+e.length);var t=JSON.parse(e);return this._endPerformanceCounter(\"Parse JSON\"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter(\"Unpack Binary\"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new Error(\"Unexpected magic: \"+n);var r=e.readUint32();t.loggingEnabled&&t._log(\"Binary version: \"+r);var o,a=e.readUint32();if(0!==e.buffer.byteLength&&a!==e.buffer.byteLength)throw new Error(\"Length in header does not match actual data length: \"+a+\" != \"+e.buffer.byteLength);switch(r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error(\"Unsupported version: \"+r)}return t._endPerformanceCounter(\"Unpack Binary\"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error(\"Unexpected content format: \"+r);var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=5130562,a=e.readUint32();if(e.readUint32()!==r)throw new Error(\"First chunk format is not JSON\");return e.byteOffset+a===t?e.loadAsync(a).then((function(){return{json:n._parseJson(e.readString(a)),bin:null}})):e.loadAsync(a+8).then((function(){var i={json:n._parseJson(e.readString(a)),bin:null},s=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error(\"Unexpected JSON chunk\");case o:var a=e.byteOffset;i.bin={readAsync:function(t,n){return e.buffer.readAsync(a+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(s):Promise.resolve(i)};return s()}))},e._parseVersion=function(e){if(\"1.0\"===e||\"1.0.1\"===e)return{major:1,minor:0};var t=(e+\"\").match(/^(\\d+)\\.(\\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},e._compareVersion=function(e,t){return e.major>t.major?1:e.majort.minor?1:e.minor=0&&l.renderTargetTextures.splice(a,1)}if(this._opaqueRenderTarget&&(t=this._scene.customRenderTargets.indexOf(this._opaqueRenderTarget),this._opaqueRenderTarget.dispose()),this._opaqueRenderTarget=new r.RenderTargetTexture(\"opaqueSceneTexture\",this._options.renderSize,this._scene,!0),this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.gammaSpace=!0,this._opaqueRenderTarget.lodGenerationScale=1,this._opaqueRenderTarget.lodGenerationOffset=-4,t>=0?this._scene.customRenderTargets.splice(t,0,this._opaqueRenderTarget):(t=this._scene.customRenderTargets.length,this._scene.customRenderTargets.push(this._opaqueRenderTarget)),this._scene.layers&&this._opaqueRenderTarget)for(var i=0,s=this._scene.layers;i=0;i--)if(a.push(o.a.Get(e+\"/ids/\"+r[i],n,r[i])),a.length===this.maxLODsToLoad)return a;return a.push(t),a},e.prototype._disposeTransformNode=function(e){var t=this,n=new Array,r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();o.b.RegisterExtension(\"ExtrasAsMetadata\",(function(e){return new w(e)}))},function(e,t,n){\"use strict\";n.r(t),n.d(t,\"GLTFBinaryExtension\",(function(){return k})),n.d(t,\"GLTFLoaderBase\",(function(){return D})),n.d(t,\"GLTFLoader\",(function(){return G})),n.d(t,\"GLTFLoaderExtension\",(function(){return U})),n.d(t,\"EComponentType\",(function(){return r})),n.d(t,\"EShaderType\",(function(){return o})),n.d(t,\"EParameterType\",(function(){return a})),n.d(t,\"ETextureWrapMode\",(function(){return i})),n.d(t,\"ETextureFilterType\",(function(){return s})),n.d(t,\"ETextureFormat\",(function(){return l})),n.d(t,\"ECullingType\",(function(){return u})),n.d(t,\"EBlendingFunction\",(function(){return c})),n.d(t,\"GLTFUtils\",(function(){return p})),n.d(t,\"GLTFMaterialsCommonExtension\",(function(){return H}));var r,o,a,i,s,l,u,c,d=n(4);!function(e){e[e.BYTE=5120]=\"BYTE\",e[e.UNSIGNED_BYTE=5121]=\"UNSIGNED_BYTE\",e[e.SHORT=5122]=\"SHORT\",e[e.UNSIGNED_SHORT=5123]=\"UNSIGNED_SHORT\",e[e.FLOAT=5126]=\"FLOAT\"}(r||(r={})),function(e){e[e.FRAGMENT=35632]=\"FRAGMENT\",e[e.VERTEX=35633]=\"VERTEX\"}(o||(o={})),function(e){e[e.BYTE=5120]=\"BYTE\",e[e.UNSIGNED_BYTE=5121]=\"UNSIGNED_BYTE\",e[e.SHORT=5122]=\"SHORT\",e[e.UNSIGNED_SHORT=5123]=\"UNSIGNED_SHORT\",e[e.INT=5124]=\"INT\",e[e.UNSIGNED_INT=5125]=\"UNSIGNED_INT\",e[e.FLOAT=5126]=\"FLOAT\",e[e.FLOAT_VEC2=35664]=\"FLOAT_VEC2\",e[e.FLOAT_VEC3=35665]=\"FLOAT_VEC3\",e[e.FLOAT_VEC4=35666]=\"FLOAT_VEC4\",e[e.INT_VEC2=35667]=\"INT_VEC2\",e[e.INT_VEC3=35668]=\"INT_VEC3\",e[e.INT_VEC4=35669]=\"INT_VEC4\",e[e.BOOL=35670]=\"BOOL\",e[e.BOOL_VEC2=35671]=\"BOOL_VEC2\",e[e.BOOL_VEC3=35672]=\"BOOL_VEC3\",e[e.BOOL_VEC4=35673]=\"BOOL_VEC4\",e[e.FLOAT_MAT2=35674]=\"FLOAT_MAT2\",e[e.FLOAT_MAT3=35675]=\"FLOAT_MAT3\",e[e.FLOAT_MAT4=35676]=\"FLOAT_MAT4\",e[e.SAMPLER_2D=35678]=\"SAMPLER_2D\"}(a||(a={})),function(e){e[e.CLAMP_TO_EDGE=33071]=\"CLAMP_TO_EDGE\",e[e.MIRRORED_REPEAT=33648]=\"MIRRORED_REPEAT\",e[e.REPEAT=10497]=\"REPEAT\"}(i||(i={})),function(e){e[e.NEAREST=9728]=\"NEAREST\",e[e.LINEAR=9728]=\"LINEAR\",e[e.NEAREST_MIPMAP_NEAREST=9984]=\"NEAREST_MIPMAP_NEAREST\",e[e.LINEAR_MIPMAP_NEAREST=9985]=\"LINEAR_MIPMAP_NEAREST\",e[e.NEAREST_MIPMAP_LINEAR=9986]=\"NEAREST_MIPMAP_LINEAR\",e[e.LINEAR_MIPMAP_LINEAR=9987]=\"LINEAR_MIPMAP_LINEAR\"}(s||(s={})),function(e){e[e.ALPHA=6406]=\"ALPHA\",e[e.RGB=6407]=\"RGB\",e[e.RGBA=6408]=\"RGBA\",e[e.LUMINANCE=6409]=\"LUMINANCE\",e[e.LUMINANCE_ALPHA=6410]=\"LUMINANCE_ALPHA\"}(l||(l={})),function(e){e[e.FRONT=1028]=\"FRONT\",e[e.BACK=1029]=\"BACK\",e[e.FRONT_AND_BACK=1032]=\"FRONT_AND_BACK\"}(u||(u={})),function(e){e[e.ZERO=0]=\"ZERO\",e[e.ONE=1]=\"ONE\",e[e.SRC_COLOR=768]=\"SRC_COLOR\",e[e.ONE_MINUS_SRC_COLOR=769]=\"ONE_MINUS_SRC_COLOR\",e[e.DST_COLOR=774]=\"DST_COLOR\",e[e.ONE_MINUS_DST_COLOR=775]=\"ONE_MINUS_DST_COLOR\",e[e.SRC_ALPHA=770]=\"SRC_ALPHA\",e[e.ONE_MINUS_SRC_ALPHA=771]=\"ONE_MINUS_SRC_ALPHA\",e[e.DST_ALPHA=772]=\"DST_ALPHA\",e[e.ONE_MINUS_DST_ALPHA=773]=\"ONE_MINUS_DST_ALPHA\",e[e.CONSTANT_COLOR=32769]=\"CONSTANT_COLOR\",e[e.ONE_MINUS_CONSTANT_COLOR=32770]=\"ONE_MINUS_CONSTANT_COLOR\",e[e.CONSTANT_ALPHA=32771]=\"CONSTANT_ALPHA\",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]=\"ONE_MINUS_CONSTANT_ALPHA\",e[e.SRC_ALPHA_SATURATE=776]=\"SRC_ALPHA_SATURATE\"}(c||(c={}));var f,h=n(0),p=function(){function e(){}return e.SetMatrix=function(e,t,n,r,o){var i=null;if(\"MODEL\"===n.semantic?i=t.getWorldMatrix():\"PROJECTION\"===n.semantic?i=e.getProjectionMatrix():\"VIEW\"===n.semantic?i=e.getViewMatrix():\"MODELVIEWINVERSETRANSPOSE\"===n.semantic?i=h.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):\"MODELVIEW\"===n.semantic?i=t.getWorldMatrix().multiply(e.getViewMatrix()):\"MODELVIEWPROJECTION\"===n.semantic?i=t.getWorldMatrix().multiply(e.getTransformMatrix()):\"MODELINVERSE\"===n.semantic?i=t.getWorldMatrix().invert():\"VIEWINVERSE\"===n.semantic?i=e.getViewMatrix().invert():\"PROJECTIONINVERSE\"===n.semantic?i=e.getProjectionMatrix().invert():\"MODELVIEWINVERSE\"===n.semantic?i=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():\"MODELVIEWPROJECTIONINVERSE\"===n.semantic?i=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():\"MODELINVERSETRANSPOSE\"===n.semantic&&(i=h.Matrix.Transpose(t.getWorldMatrix().invert())),i)switch(n.type){case a.FLOAT_MAT2:o.setMatrix2x2(r,h.Matrix.GetAsMatrix2x2(i));break;case a.FLOAT_MAT3:o.setMatrix3x3(r,h.Matrix.GetAsMatrix3x3(i));break;case a.FLOAT_MAT4:o.setMatrix(r,i)}},e.SetUniform=function(e,t,n,r){switch(r){case a.FLOAT:return e.setFloat(t,n),!0;case a.FLOAT_VEC2:return e.setVector2(t,h.Vector2.FromArray(n)),!0;case a.FLOAT_VEC3:return e.setVector3(t,h.Vector3.FromArray(n)),!0;case a.FLOAT_VEC4:return e.setVector4(t,h.Vector4.FromArray(n)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case i.CLAMP_TO_EDGE:return h.Texture.CLAMP_ADDRESSMODE;case i.MIRRORED_REPEAT:return h.Texture.MIRROR_ADDRESSMODE;case i.REPEAT:default:return h.Texture.WRAP_ADDRESSMODE}},e.GetByteStrideFromType=function(e){switch(e.type){case\"VEC2\":return 2;case\"VEC3\":return 3;case\"VEC4\":case\"MAT2\":return 4;case\"MAT3\":return 9;case\"MAT4\":return 16;default:return 1}},e.GetTextureFilterMode=function(e){switch(e){case s.LINEAR:case s.LINEAR_MIPMAP_NEAREST:case s.LINEAR_MIPMAP_LINEAR:return h.Texture.TRILINEAR_SAMPLINGMODE;case s.NEAREST:case s.NEAREST_MIPMAP_NEAREST:return h.Texture.NEAREST_SAMPLINGMODE;default:return h.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,o,a){n=t.byteOffset+n;var i=e.loadedBufferViews[t.buffer];if(n+o>i.byteLength)throw new Error(\"Buffer access is out of range\");var s=i.buffer;switch(n+=i.byteOffset,a){case r.BYTE:return new Int8Array(s,n,o);case r.UNSIGNED_BYTE:return new Uint8Array(s,n,o);case r.SHORT:return new Int16Array(s,n,o);case r.UNSIGNED_SHORT:return new Uint16Array(s,n,o);default:return new Float32Array(s,n,o)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t=\"\",n=e.byteLength,r=0;r=this._maxPos},e}(),y=[\"MODEL\",\"VIEW\",\"PROJECTION\",\"MODELVIEW\",\"MODELVIEWPROJECTION\",\"JOINTMATRIX\"],b=[\"world\",\"view\",\"projection\",\"worldView\",\"worldViewProjection\",\"mBones\"],v=[\"translation\",\"rotation\",\"scale\"],g=[\"position\",\"rotationQuaternion\",\"scaling\"],A=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},T=function(e){if(e)for(var t=0;t0&&(d=O(a,o))&&-1===i.indexOf(d)&&i.push(d),new h.Bone(l.jointName||\"\",r,d,b).id=o}}else h.Tools.Warn(\"Joint named \"+t.jointNames[s]+\" does not exist\")}}var v=r.bones;r.bones=[];for(s=0;s1?(a=new h.MultiMaterial(\"multimat\"+r,e.scene)).subMaterials=i:a=new h.StandardMaterial(\"multimat\"+r,e.scene),1===i.length&&(a=i[0]),o.material||(o.material=a),new h.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var C=0;for(f=0;f0&&-1===e.importMeshesNames.indexOf(t.name||\"\"))return null;if(t.skin){if(t.meshes){var a=e.skins[t.skin];(i=R(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonByID(t.skin),null===i.skeleton&&(i.skeleton=w(e,a,0,a.babylonSkeleton,t.skin),a.babylonSkeleton||(a.babylonSkeleton=i.skeleton)),o=i}}else if(t.meshes){var i;o=i=R(e,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode)}else if(!t.light||t.babylonNode||e.importOnlyMeshes){if(t.camera&&!t.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[t.camera];if(s){if(e.scene._blockEntityCollection=e.forAssetContainer,\"orthographic\"===s.type){var l=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);l.name=t.name||\"\",l.mode=h.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(),o=l}else if(\"perspective\"===s.type){var u=s[s.type],c=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);c.name=t.name||\"\",c.attachControl(),u.aspectRatio||(u.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),u.znear&&u.zfar&&(c.maxZ=u.zfar,c.minZ=u.znear),o=c}e.scene._blockEntityCollection=!1}}}else{var d=e.lights[t.light];if(d)if(\"ambient\"===d.type){var f=d[d.type],p=new h.HemisphericLight(t.light,h.Vector3.Zero(),e.scene);p.name=t.name||\"\",f.color&&(p.diffuse=h.Color3.FromArray(f.color)),o=p}else if(\"directional\"===d.type){var _=d[d.type],m=new h.DirectionalLight(t.light,h.Vector3.Zero(),e.scene);m.name=t.name||\"\",_.color&&(m.diffuse=h.Color3.FromArray(_.color)),o=m}else if(\"point\"===d.type){var y=d[d.type],b=new h.PointLight(t.light,h.Vector3.Zero(),e.scene);b.name=t.name||\"\",y.color&&(b.diffuse=h.Color3.FromArray(y.color)),o=b}else if(\"spot\"===d.type){var v=d[d.type],g=new h.SpotLight(t.light,h.Vector3.Zero(),h.Vector3.Zero(),0,0,e.scene);g.name=t.name||\"\",v.color&&(g.diffuse=h.Color3.FromArray(v.color)),v.fallOfAngle&&(g.angle=v.fallOfAngle),v.fallOffExponent&&(g.exponent=v.fallOffExponent),o=g}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===o){e.scene._blockEntityCollection=e.forAssetContainer;var A=new h.Mesh(t.name||\"\",e.scene);e.scene._blockEntityCollection=!1,t.babylonNode=A,o=A}}if(null!==o){if(t.matrix&&o instanceof h.Mesh)!function(e,t,n){if(t.matrix){var r=new h.Vector3(0,0,0),o=new h.Quaternion,a=new h.Vector3(0,0,0);h.Matrix.FromArray(t.matrix).decompose(a,o,r),C(e,r,o,a)}else t.translation&&t.rotation&&t.scale&&C(e,h.Vector3.FromArray(t.translation),h.Quaternion.FromArray(t.rotation),h.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(o,t);else{var T=t.translation||[0,0,0],x=t.rotation||[0,0,0,1],E=t.scale||[1,1,1];C(o,h.Vector3.FromArray(T),h.Quaternion.FromArray(x),h.Vector3.FromArray(E))}o.updateCache(!0),t.babylonNode=o}return o},P=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(o.name||\"\")||0===e.importMeshesNames.length),!o.jointName&&r&&null!==(a=N(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i=0?d.substring(0,f):d;h=h.toLowerCase();var p=f>=0?d.substring(f+1).trim():\"\";\"newmtl\"===h?(u&&this.materials.push(u),t._blockEntityCollection=a,u=new r.StandardMaterial(p,t),t._blockEntityCollection=!1):\"kd\"===h&&u?(i=p.split(l,3).map(parseFloat),u.diffuseColor=r.Color3.FromArray(i)):\"ka\"===h&&u?(i=p.split(l,3).map(parseFloat),u.ambientColor=r.Color3.FromArray(i)):\"ks\"===h&&u?(i=p.split(l,3).map(parseFloat),u.specularColor=r.Color3.FromArray(i)):\"ke\"===h&&u?(i=p.split(l,3).map(parseFloat),u.emissiveColor=r.Color3.FromArray(i)):\"ns\"===h&&u?u.specularPower=parseFloat(p):\"d\"===h&&u?u.alpha=parseFloat(p):\"map_ka\"===h&&u?u.ambientTexture=e._getTexture(o,p,t):\"map_kd\"===h&&u?u.diffuseTexture=e._getTexture(o,p,t):\"map_ks\"===h&&u?u.specularTexture=e._getTexture(o,p,t):\"map_ns\"===h||(\"map_bump\"===h&&u?u.bumpTexture=e._getTexture(o,p,t):\"map_d\"===h&&u&&(u.opacityTexture=e._getTexture(o,p,t)))}}u&&this.materials.push(u)}},e._getTexture=function(t,n,o){if(!n)return null;var a=t;if(\"file:\"===t){var i=n.lastIndexOf(\"\\\\\");-1===i&&(i=n.lastIndexOf(\"/\")),a+=i>-1?n.substr(i+1):n}else a+=n;return new r.Texture(a,o,!1,e.INVERT_TEXTURE_Y)},e.INVERT_TEXTURE_Y=!0,e}(),a=function(){function e(t){this.name=\"obj\",this.extensions=\".obj\",this.obj=/^o/,this.group=/^g/,this.mtllib=/^mtllib /,this.usemtl=/^usemtl /,this.smooth=/^s /,this.vertexPattern=/v(\\s+[\\d|\\.|\\+|\\-|e|E]+){3,7}/,this.normalPattern=/vn(\\s+[\\d|\\.|\\+|\\-|e|E]+)( +[\\d|\\.|\\+|\\-|e|E]+)( +[\\d|\\.|\\+|\\-|e|E]+)/,this.uvPattern=/vt(\\s+[\\d|\\.|\\+|\\-|e|E]+)( +[\\d|\\.|\\+|\\-|e|E]+)/,this.facePattern1=/f\\s+(([\\d]{1,}[\\s]?){3,})+/,this.facePattern2=/f\\s+((([\\d]{1,}\\/[\\d]{1,}[\\s]?){3,})+)/,this.facePattern3=/f\\s+((([\\d]{1,}\\/[\\d]{1,}\\/[\\d]{1,}[\\s]?){3,})+)/,this.facePattern4=/f\\s+((([\\d]{1,}\\/\\/[\\d]{1,}[\\s]?){3,})+)/,this.facePattern5=/f\\s+(((-[\\d]{1,}\\/-[\\d]{1,}\\/-[\\d]{1,}[\\s]?){3,})+)/,this._forAssetContainer=!1,this._meshLoadOptions=t||e.currentMeshLoadOptions}return Object.defineProperty(e,\"INVERT_TEXTURE_Y\",{get:function(){return o.INVERT_TEXTURE_Y},set:function(e){o.INVERT_TEXTURE_Y=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"currentMeshLoadOptions\",{get:function(){return{ComputeNormals:e.COMPUTE_NORMALS,ImportVertexColors:e.IMPORT_VERTEX_COLORS,InvertY:e.INVERT_Y,InvertTextureY:e.INVERT_TEXTURE_Y,UVScaling:e.UV_SCALING,MaterialLoadingFailsSilently:e.MATERIAL_LOADING_FAILS_SILENTLY,OptimizeWithUV:e.OPTIMIZE_WITH_UV,SkipMaterials:e.SKIP_MATERIALS}},enumerable:!1,configurable:!0}),e.prototype._loadMTL=function(e,t,n,o){var a=r.Tools.BaseUrl+t+e;r.Tools.LoadFile(a,n,void 0,void 0,!1,(function(e,t){o(a,t)}))},e.prototype.createPlugin=function(){return new e(e.currentMeshLoadOptions)},e.prototype.canDirectLoad=function(e){return!1},e.prototype.importMeshAsync=function(e,t,n,r,o,a){return this._parseSolid(e,t,n,r).then((function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[]}}))},e.prototype.loadAsync=function(e,t,n,r,o){return this.importMeshAsync(null,e,t,n,r).then((function(){}))},e.prototype.loadAssetContainerAsync=function(e,t,n,o,a){var i=this;return this._forAssetContainer=!0,this.importMeshAsync(null,e,t,n).then((function(t){var n=new r.AssetContainer(e);return t.meshes.forEach((function(e){return n.meshes.push(e)})),t.meshes.forEach((function(e){var t=e.material;t&&(-1==n.materials.indexOf(t)&&(n.materials.push(t),t.getActiveTextures().forEach((function(e){-1==n.textures.indexOf(e)&&n.textures.push(e)}))))})),i._forAssetContainer=!1,n})).catch((function(e){throw i._forAssetContainer=!1,e}))},e.prototype._parseSolid=function(t,n,a,i){for(var s,l=this,u=[],c=[],d=[],f=[],h=[],p=[],_=[],m=[],y=[],b=[],v=[],g=0,A=!1,T=[],x=[],E=[],L=[],O=[],M=\"\",S=\"\",w=new o,R=1,C=!0,N=new r.Color4(.5,.5,.5,1),P=function(e,t,n,r,o,a,i){var s;-1===(s=l._meshLoadOptions.OptimizeWithUV?function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var n=e[t[0]].normals.indexOf(t[1]);return 1!=n&&t[2]===e[t[0]].uv[n]?e[t[0]].idx[n]:-1}(v,[e,n,t]):function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var n=e[t[0]].normals.indexOf(t[1]);return-1===n?-1:e[t[0]].idx[n]}(v,[e,n]))?(p.push(_.length),_.push(r),m.push(o),b.push(a),void 0!==i&&y.push(i),v[e].normals.push(n),v[e].idx.push(g++),l._meshLoadOptions.OptimizeWithUV&&v[e].uv.push(t)):p.push(s)},I=function(){for(var e=0;e<_.length;e++)T.push(_[e].x,_[e].y,_[e].z),E.push(b[e].x,b[e].y,b[e].z),L.push(m[e].x,m[e].y),!0===l._meshLoadOptions.ImportVertexColors&&x.push(y[e].r,y[e].g,y[e].b,y[e].a);_=[],b=[],m=[],y=[],v=[],g=0},F=function(e,t){for(var n=t;n0&&(s=h[h.length-1],I(),p.reverse(),s.indices=p.slice(),s.positions=T.slice(),s.normals=E.slice(),s.uvs=L.slice(),!0===l._meshLoadOptions.ImportVertexColors&&(s.colors=x.slice()),p=[],T=[],x=[],E=[],L=[])},H=a.split(\"\\n\"),K=0;K=7?f.push(new r.Color4(parseFloat(j[4]),parseFloat(j[5]),parseFloat(j[6]),7===j.length||void 0===j[7]?1:parseFloat(j[7]))):f.push(N));else if(null!==(j=this.normalPattern.exec(W)))c.push(new r.Vector3(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3])));else if(null!==(j=this.uvPattern.exec(W)))d.push(new r.Vector2(parseFloat(j[1])*e.UV_SCALING.x,parseFloat(j[2])*e.UV_SCALING.y));else if(null!==(j=this.facePattern3.exec(W)))D(j[1].trim().split(\" \"),1);else if(null!==(j=this.facePattern4.exec(W)))G(j[1].trim().split(\" \"),1);else if(null!==(j=this.facePattern5.exec(W)))U(j[1].trim().split(\" \"),1);else if(null!==(j=this.facePattern2.exec(W)))V(j[1].trim().split(\" \"),1);else if(null!==(j=this.facePattern1.exec(W)))B(j[1].trim().split(\" \"),1);else if(this.group.test(W)||this.obj.test(W)){var q={name:W.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:\"\"};k(),h.push(q),A=!0,C=!0,R=1}else if(this.usemtl.test(W)){if(M=W.substring(7).trim(),!C||!A){k();q={name:\"mesh_mm\"+R.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:M};R++,h.push(q),A=!0}A&&C&&(h[h.length-1].materialName=M,C=!1)}else this.mtllib.test(W)?S=W.substring(7).trim():this.smooth.test(W)||console.log(\"Unhandled expression at line : \"+W)}A&&(s=h[h.length-1],p.reverse(),I(),s.indices=p,s.positions=T,s.normals=E,s.uvs=L,!0===this._meshLoadOptions.ImportVertexColors&&(s.colors=x)),A||(p.reverse(),I(),h.push({name:r.Geometry.RandomId(),indices:p,positions:T,colors:x,normals:E,uvs:L,materialName:M}));for(var Y=[],X=new Array,J=0;J-1;)c.push(s),u=s+1;if(-1===s&&0===c.length)w.materials[a].dispose();else for(var d=0;d127)return!0;return!1},e.prototype._parseBinary=function(e,t){for(var n=new DataView(t),o=n.getUint32(80,!0),a=0,i=new Float32Array(3*o*3),s=new Float32Array(3*o*3),l=new Uint32Array(3*o),u=0,c=0;c-1||(s.GLTF2[u]=a[u])}}).call(this,n(5))},function(e,t,n){\"use strict\";n.r(t),function(e){var r=n(10);n.d(t,\"MTLFileLoader\",(function(){return r.MTLFileLoader})),n.d(t,\"OBJFileLoader\",(function(){return r.OBJFileLoader}));var o=void 0!==e?e:\"undefined\"!=typeof window?window:void 0;if(void 0!==o)for(var a in r)o.BABYLON[a]=r[a]}.call(this,n(5))},function(e,t,n){\"use strict\";n.r(t),function(e){var r=n(11);n.d(t,\"STLFileLoader\",(function(){return r.STLFileLoader}));var o=void 0!==e?e:\"undefined\"!=typeof window?window:void 0;if(void 0!==o)for(var a in r)o.BABYLON[a]=r[a]}.call(this,n(5))},,,,function(e,t,n){\"use strict\";n.r(t),n.d(t,\"GLTFLoaderCoordinateSystemMode\",(function(){return r.c})),n.d(t,\"GLTFLoaderAnimationStartMode\",(function(){return r.b})),n.d(t,\"GLTFLoaderState\",(function(){return r.d})),n.d(t,\"GLTFFileLoader\",(function(){return r.a})),n.d(t,\"GLTFValidation\",(function(){return r.e})),n.d(t,\"GLTF1\",(function(){return o.a})),n.d(t,\"GLTF2\",(function(){return a.a})),n.d(t,\"MTLFileLoader\",(function(){return i.MTLFileLoader})),n.d(t,\"OBJFileLoader\",(function(){return i.OBJFileLoader})),n.d(t,\"STLFileLoader\",(function(){return s.STLFileLoader}));n(2),n(3),n(8),n(9),n(10),n(11);var r=n(12),o=n(13),a=n(14),i=n(15),s=n(16)}])}));","!function(e,t){\"object\"==typeof exports&&\"object\"==typeof module?module.exports=t(require(\"babylonjs\")):\"function\"==typeof define&&define.amd?define(\"babylonjs-materials\",[\"babylonjs\"],t):\"object\"==typeof exports?exports[\"babylonjs-materials\"]=t(require(\"babylonjs\")):e.MATERIALS=t(e.BABYLON)}(\"undefined\"!=typeof self?self:\"undefined\"!=typeof global?global:this,(function(e){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,\"a\",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p=\"\",i(i.s=19)}([function(t,i){t.exports=e},function(e,t,i){\"use strict\";i.d(t,\"b\",(function(){return r})),i.d(t,\"a\",(function(){return o}));\n/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nvar n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)};function r(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}function o(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if(\"object\"==typeof Reflect&&\"function\"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}Object.create;Object.create},function(e,t){var i;i=function(){return this}();try{i=i||new Function(\"return this\")()}catch(e){\"object\"==typeof window&&(i=window)}e.exports=i},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"CellMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include\\n\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform sampler2D diffuseSampler;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#include\\n\\n#include\\n\\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\\n{\\ndiffuseBase=info.diffuse*shadow;\\n#ifdef CELLBASIC\\nfloat level=1.0;\\nif (info.ndl<0.5)\\nlevel=0.5;\\ndiffuseBase.rgb*vec3(level,level,level);\\n#else\\nfloat ToonThresholds[4];\\nToonThresholds[0]=0.95;\\nToonThresholds[1]=0.5;\\nToonThresholds[2]=0.2;\\nToonThresholds[3]=0.03;\\nfloat ToonBrightnessLevels[5];\\nToonBrightnessLevels[0]=1.0;\\nToonBrightnessLevels[1]=0.8;\\nToonBrightnessLevels[2]=0.6;\\nToonBrightnessLevels[3]=0.35;\\nToonBrightnessLevels[4]=0.2;\\nif (info.ndl>ToonThresholds[0])\\n{\\ndiffuseBase.rgb*=ToonBrightnessLevels[0];\\n}\\nelse if (info.ndl>ToonThresholds[1])\\n{\\ndiffuseBase.rgb*=ToonBrightnessLevels[1];\\n}\\nelse if (info.ndl>ToonThresholds[2])\\n{\\ndiffuseBase.rgb*=ToonBrightnessLevels[2];\\n}\\nelse if (info.ndl>ToonThresholds[3])\\n{\\ndiffuseBase.rgb*=ToonBrightnessLevels[3];\\n}\\nelse\\n{\\ndiffuseBase.rgb*=ToonBrightnessLevels[4];\\n}\\n#endif\\nreturn max(diffuseBase,vec3(0.2));\\n}\\nvoid main(void)\\n{\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(1.,1.,1.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n\\nfloat alpha=vDiffuseColor.a;\\n#ifdef DIFFUSE\\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\n#include\\nbaseColor.rgb*=vDiffuseInfos.y;\\n#endif\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n\\nlightingInfo info;\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nfloat shadow=1.;\\nfloat glossiness=0.;\\n#ifdef SPECULARTERM\\nvec3 specularBase=vec3(0.,0.,0.);\\n#endif\\n#include[0..maxSimultaneousLights]\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\\n\\nvec4 color=vec4(finalDiffuse,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\";r.Effect.ShadersStore.cellPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform mat4 diffuseMatrix;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef DIFFUSE\\nif (vDiffuseInfos.x == 0.)\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n\\n#include\\n\\n#include\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.cellVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.NDOTL=!0,t.CUSTOMUSERLIGHTING=!0,t.CELLBASIC=!0,t.DEPTHPREPASS=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n._computeHighLevel=!1,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(n.CELLBASIC=!this.computeHighLevel,r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,\"FOG\"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vDiffuseInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"diffuseMatrix\"],d=[\"diffuseSampler\"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect(\"cell\",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture(\"diffuseSampler\",this._diffuseTexture),this._activeEffect.setFloat2(\"vDiffuseInfos\",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix(\"diffuseMatrix\",this._diffuseTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this._maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this._diffuseTexture===t},t.prototype.dispose=function(t){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.getClassName=function(){return\"CellMaterial\"},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.CellMaterial\",e},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture\")],t.prototype,\"_diffuseTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture\",void 0),Object(n.a)([Object(r.serializeAsColor3)(\"diffuse\")],t.prototype,\"diffuseColor\",void 0),Object(n.a)([Object(r.serialize)(\"computeHighLevel\")],t.prototype,\"_computeHighLevel\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"computeHighLevel\",void 0),Object(n.a)([Object(r.serialize)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(n.a)([Object(r.serialize)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.CellMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"FireMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\n\\nvarying vec3 vPositionW;\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform sampler2D diffuseSampler;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n\\nuniform sampler2D distortionSampler;\\nuniform sampler2D opacitySampler;\\n#ifdef DIFFUSE\\nvarying vec2 vDistortionCoords1;\\nvarying vec2 vDistortionCoords2;\\nvarying vec2 vDistortionCoords3;\\n#endif\\n#include\\n\\n#include\\nvec4 bx2(vec4 x)\\n{\\nreturn vec4(2.0)*x-vec4(1.0);\\n}\\nvoid main(void) {\\n\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(1.,1.,1.,1.);\\n\\nfloat alpha=1.0;\\n#ifdef DIFFUSE\\n\\nconst float distortionAmount0=0.092;\\nconst float distortionAmount1=0.092;\\nconst float distortionAmount2=0.092;\\nvec2 heightAttenuation=vec2(0.3,0.39);\\nvec4 noise0=texture2D(distortionSampler,vDistortionCoords1);\\nvec4 noise1=texture2D(distortionSampler,vDistortionCoords2);\\nvec4 noise2=texture2D(distortionSampler,vDistortionCoords3);\\nvec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;\\nvec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);\\nvec4 opacityColor=texture2D(opacitySampler,perturbedBaseCoords.xy);\\n#ifdef ALPHATEST\\nif (opacityColor.r<0.1)\\ndiscard;\\n#endif\\n#include\\nbaseColor=texture2D(diffuseSampler,perturbedBaseCoords.xy)*2.0;\\nbaseColor*=opacityColor;\\nbaseColor.rgb*=vDiffuseInfos.y;\\n#endif\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n\\nvec4 color=vec4(baseColor.rgb,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\";r.Effect.ShadersStore.firePixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n\\nuniform float time;\\nuniform float speed;\\n#ifdef DIFFUSE\\nvarying vec2 vDistortionCoords1;\\nvarying vec2 vDistortionCoords2;\\nvarying vec2 vDistortionCoords3;\\n#endif\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\n\\n#ifdef DIFFUSE\\nvDiffuseUV=uv;\\nvDiffuseUV.y-=0.2;\\n#endif\\n\\n#include\\n\\n#include\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n#ifdef DIFFUSE\\n\\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;\\nvDistortionCoords1.x=uv.x;\\nvDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;\\nvDistortionCoords2.x=uv.x;\\nvDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;\\nvDistortionCoords3.x=uv.x;\\nvDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\\n#endif\\n}\\n\";r.Effect.ShadersStore.fireVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.UV1=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.BonesPerMesh=0,t.NUM_BONE_INFLUENCERS=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n.speed=1,n._scaledDiffuse=new r.Color3,n._lastTime=0,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return!1},t.prototype.needAlphaTesting=function(){return!0},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(n.ALPHATEST=!!this._opacityTexture,n._areMiscDirty&&(n.POINTSIZE=this.pointsCloud||o.forcePointsCloud,n.FOG=o.fogEnabled&&e.applyFog&&o.fogMode!==r.Scene.FOGMODE_NONE&&this.fogEnabled),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,\"FOG\"),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.UV1&&l.push(r.VertexBuffer.UVKind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString();t.setEffect(o.getEngine().createEffect(\"fire\",{attributes:l,uniformsNames:[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vDiffuseInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"diffuseMatrix\",\"time\",\"speed\"],uniformBuffersNames:[],samplers:[\"diffuseSampler\",\"distortionSampler\",\"opacitySampler\"],defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:null,maxSimultaneousLights:4,transformFeedbackVaryings:null},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene();if(i._materialDefines){var o=i.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,o)&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture(\"diffuseSampler\",this._diffuseTexture),this._activeEffect.setFloat2(\"vDiffuseInfos\",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix(\"diffuseMatrix\",this._diffuseTexture.getTextureMatrix()),this._activeEffect.setTexture(\"distortionSampler\",this._distortionTexture),this._activeEffect.setTexture(\"opacitySampler\",this._opacityTexture)),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(o,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this._scaledDiffuse,this.alpha*t.visibility),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._lastTime+=n.getEngine().getDeltaTime(),this._activeEffect.setFloat(\"time\",this._lastTime),this._activeEffect.setFloat(\"speed\",this.speed),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._distortionTexture&&this._distortionTexture.animations&&this._distortionTexture.animations.length>0&&e.push(this._distortionTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._distortionTexture&&t.push(this._distortionTexture),this._opacityTexture&&t.push(this._opacityTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._distortionTexture===t||this._opacityTexture===t))},t.prototype.getClassName=function(){return\"FireMaterial\"},t.prototype.dispose=function(t){this._diffuseTexture&&this._diffuseTexture.dispose(),this._distortionTexture&&this._distortionTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.customType=\"BABYLON.FireMaterial\",t.diffuseColor=this.diffuseColor.asArray(),t.speed=this.speed,this._diffuseTexture&&(t._diffuseTexture=this._diffuseTexture.serialize()),this._distortionTexture&&(t._distortionTexture=this._distortionTexture.serialize()),this._opacityTexture&&(t._opacityTexture=this._opacityTexture.serialize()),t},t.Parse=function(e,i,n){var o=new t(e.name,i);return o.diffuseColor=r.Color3.FromArray(e.diffuseColor),o.speed=e.speed,o.alpha=e.alpha,o.id=e.id,r.Tags.AddTagsTo(o,e.tags),o.backFaceCulling=e.backFaceCulling,o.wireframe=e.wireframe,e._diffuseTexture&&(o._diffuseTexture=r.Texture.Parse(e._diffuseTexture,i,n)),e._distortionTexture&&(o._distortionTexture=r.Texture.Parse(e._distortionTexture,i,n)),e._opacityTexture&&(o._opacityTexture=r.Texture.Parse(e._opacityTexture,i,n)),o},Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture\")],t.prototype,\"_diffuseTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"distortionTexture\")],t.prototype,\"_distortionTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"distortionTexture\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"opacityTexture\")],t.prototype,\"_opacityTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"opacityTexture\",void 0),Object(n.a)([Object(r.serializeAsColor3)(\"diffuse\")],t.prototype,\"diffuseColor\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"speed\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.FireMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"FurMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n\\nuniform vec4 furColor;\\nuniform float furLength;\\nvarying vec3 vPositionW;\\nvarying float vfur_length;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform sampler2D diffuseSampler;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n\\n#ifdef HIGHLEVEL\\nuniform float furOffset;\\nuniform float furOcclusion;\\nuniform sampler2D furTexture;\\nvarying vec2 vFurUV;\\n#endif\\n#include\\n#include\\n#include\\n#include\\nfloat Rand(vec3 rv) {\\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\\nreturn fract(sin(x)*43758.5453);\\n}\\nvoid main(void) {\\n\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=furColor;\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n\\nfloat alpha=vDiffuseColor.a;\\n#ifdef DIFFUSE\\nbaseColor*=texture2D(diffuseSampler,vDiffuseUV);\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\n#include\\nbaseColor.rgb*=vDiffuseInfos.y;\\n#endif\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n#ifdef HIGHLEVEL\\n\\nvec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));\\nif (furTextureColor.a<=0.0 || furTextureColor.g[0..maxSimultaneousLights]\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\nvec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0);\\n\\n#ifdef HIGHLEVEL\\nvec4 color=vec4(finalDiffuse,alpha);\\n#else\\nfloat r=vfur_length/furLength*0.5;\\nvec4 color=vec4(finalDiffuse*(0.5+r),alpha);\\n#endif\\n#include\\ngl_FragColor=color;\\n#include\\n}\";r.Effect.ShadersStore.furPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\nattribute vec3 normal;\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\nuniform float furLength;\\nuniform float furAngle;\\n#ifdef HIGHLEVEL\\nuniform float furOffset;\\nuniform vec3 furGravity;\\nuniform float furTime;\\nuniform float furSpacing;\\nuniform float furDensity;\\n#endif\\n#ifdef HEIGHTMAP\\nuniform sampler2D heightTexture;\\n#endif\\n#ifdef HIGHLEVEL\\nvarying vec2 vFurUV;\\n#endif\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform mat4 diffuseMatrix;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\nvarying float vfur_length;\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nfloat Rand(vec3 rv) {\\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\\nreturn fract(sin(x)*43758.5453);\\n}\\nvoid main(void) {\\n#include\\n#include\\n\\nfloat r=Rand(position);\\n#ifdef HEIGHTMAP\\n#if __VERSION__>100\\nvfur_length=furLength*texture(heightTexture,uv).x;\\n#else\\nvfur_length=furLength*texture2D(heightTexture,uv).r;\\n#endif\\n#else\\nvfur_length=(furLength*r);\\n#endif\\nvec3 tangent1=vec3(normal.y,-normal.x,0);\\nvec3 tangent2=vec3(-normal.z,0,normal.x);\\nr=Rand(tangent1*r);\\nfloat J=(2.0+4.0*r);\\nr=Rand(tangent2*r);\\nfloat K=(2.0+2.0*r);\\ntangent1=tangent1*J+tangent2*K;\\ntangent1=normalize(tangent1);\\nvec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle);\\n#ifdef HIGHLEVEL\\n\\nvec3 forceDirection=vec3(0.0,0.0,0.0);\\nforceDirection.x=sin(furTime+position.x*0.05)*0.2;\\nforceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;\\nforceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;\\nvec3 displacement=vec3(0.0,0.0,0.0);\\ndisplacement=furGravity+forceDirection;\\nfloat displacementFactor=pow(furOffset,3.0);\\nvec3 aNormal=normal;\\naNormal.xyz+=displacement*displacementFactor;\\nnewPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing);\\n#endif\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\ngl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);\\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\\nvPositionW=vec3(worldPos);\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef DIFFUSE\\nif (vDiffuseInfos.x == 0.)\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n}\\n#ifdef HIGHLEVEL\\nvFurUV=vDiffuseUV*furDensity;\\n#endif\\n#else\\n#ifdef HIGHLEVEL\\nvFurUV=uv*furDensity;\\n#endif\\n#endif\\n\\n#include\\n\\n#include\\n\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.furVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.HEIGHTMAP=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.HIGHLEVEL=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n.furLength=1,n.furAngle=0,n.furColor=new r.Color3(.44,.21,.02),n.furOffset=0,n.furSpacing=12,n.furGravity=new r.Vector3(0,0,0),n.furSpeed=100,n.furDensity=20,n.furOcclusion=0,n._disableLighting=!1,n._maxSimultaneousLights=4,n.highLevelFur=!0,n._furTime=0,n}return Object(n.b)(t,e),Object.defineProperty(t.prototype,\"furTime\",{get:function(){return this._furTime},set:function(e){this._furTime=e},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.updateFur=function(){for(var e=1;e0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vDiffuseInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"diffuseMatrix\",\"furLength\",\"furAngle\",\"furColor\",\"furOffset\",\"furGravity\",\"furTime\",\"furSpacing\",\"furDensity\",\"furOcclusion\"],d=[\"diffuseSampler\",\"heightTexture\",\"furTexture\"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect(\"fur\",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),n.getCachedMaterial()!==this&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture(\"diffuseSampler\",this._diffuseTexture),this._activeEffect.setFloat2(\"vDiffuseInfos\",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix(\"diffuseMatrix\",this._diffuseTexture.getTextureMatrix())),this._heightTexture&&this._activeEffect.setTexture(\"heightTexture\",this._heightTexture),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._activeEffect.setFloat(\"furLength\",this.furLength),this._activeEffect.setFloat(\"furAngle\",this.furAngle),this._activeEffect.setColor4(\"furColor\",this.furColor,1),this.highLevelFur&&(this._activeEffect.setVector3(\"furGravity\",this.furGravity),this._activeEffect.setFloat(\"furOffset\",this.furOffset),this._activeEffect.setFloat(\"furSpacing\",this.furSpacing),this._activeEffect.setFloat(\"furDensity\",this.furDensity),this._activeEffect.setFloat(\"furOcclusion\",this.furOcclusion),this._furTime+=this.getScene().getEngine().getDeltaTime()/this.furSpeed,this._activeEffect.setFloat(\"furTime\",this._furTime),this._activeEffect.setTexture(\"furTexture\",this.furTexture)),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.heightTexture&&this.heightTexture.animations&&this.heightTexture.animations.length>0&&e.push(this.heightTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._heightTexture&&t.push(this._heightTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this.diffuseTexture===t||this._heightTexture===t)},t.prototype.dispose=function(t){if(this.diffuseTexture&&this.diffuseTexture.dispose(),this._meshes)for(var i=1;i\\n\\n#include<__decl__lightFragment>[0]\\n#include<__decl__lightFragment>[1]\\n#include<__decl__lightFragment>[2]\\n#include<__decl__lightFragment>[3]\\n#include\\n#include\\n#include\\n\\n#include\\nvoid main(void) {\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\nfloat h=vPosition.y*scale+offset;\\nfloat mysmoothness=clamp(smoothness,0.01,max(smoothness,10.));\\nvec4 baseColor=mix(bottomColor,topColor,max(pow(max(h,0.0),mysmoothness),0.0));\\n\\nvec3 diffuseColor=baseColor.rgb;\\n\\nfloat alpha=baseColor.a;\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\n#include\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n\\n#ifdef EMISSIVE\\nvec3 diffuseBase=baseColor.rgb;\\n#else\\nvec3 diffuseBase=vec3(0.,0.,0.);\\n#endif\\nlightingInfo info;\\nfloat shadow=1.;\\nfloat glossiness=0.;\\n#include[0..maxSimultaneousLights]\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\\n\\nvec4 color=vec4(finalDiffuse,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\\n\";r.Effect.ShadersStore.gradientPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\nvarying vec3 vPosition;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\nvPosition=position;\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n\\n#include\\n\\n#include\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.gradientVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.EMISSIVE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n._maxSimultaneousLights=4,n.topColor=new r.Color3(1,0,0),n.topColorAlpha=1,n.bottomColor=new r.Color3(0,0,1),n.bottomColorAlpha=1,n.offset=0,n.scale=1,n.smoothness=1,n._disableLighting=!1,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1||this.topColorAlpha<1||this.bottomColorAlpha<1},t.prototype.needAlphaTesting=function(){return!0},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),n.EMISSIVE=this._disableLighting,r.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,\"FOG\"),r.MaterialHelper.HandleFallbacksForShadows(n,f),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"topColor\",\"bottomColor\",\"offset\",\"smoothness\",\"scale\"],d=[],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:4}),t.setEffect(o.getEngine().createEffect(\"gradient\",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,a),this._mustRebind(n,a)&&(r.MaterialHelper.BindClipPlane(a,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._activeEffect.setColor4(\"topColor\",this.topColor,this.topColorAlpha),this._activeEffect.setColor4(\"bottomColor\",this.bottomColor,this.bottomColorAlpha),this._activeEffect.setFloat(\"offset\",this.offset),this._activeEffect.setFloat(\"scale\",this.scale),this._activeEffect.setFloat(\"smoothness\",this.smoothness),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){return[]},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.GradientMaterial\",e},t.prototype.getClassName=function(){return\"GradientMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serialize)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"topColor\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"topColorAlpha\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"bottomColor\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"bottomColorAlpha\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"offset\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"scale\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"smoothness\",void 0),Object(n.a)([Object(r.serialize)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.GradientMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"GridMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"#extension GL_OES_standard_derivatives : enable\\n#define SQRT2 1.41421356\\n#define PI 3.14159\\nprecision highp float;\\nuniform vec3 mainColor;\\nuniform vec3 lineColor;\\nuniform vec4 gridControl;\\nuniform vec3 gridOffset;\\n\\nvarying vec3 vPosition;\\nvarying vec3 vNormal;\\n#include\\n\\n#ifdef OPACITY\\nvarying vec2 vOpacityUV;\\nuniform sampler2D opacitySampler;\\nuniform vec2 vOpacityInfos;\\n#endif\\nfloat getVisibility(float position) {\\n\\nfloat majorGridFrequency=gridControl.y;\\nif (floor(position+0.5) == floor(position/majorGridFrequency+0.5)*majorGridFrequency)\\n{\\nreturn 1.0;\\n}\\nreturn gridControl.z;\\n}\\nfloat getAnisotropicAttenuation(float differentialLength) {\\nconst float maxNumberOfLines=10.0;\\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\\n}\\nfloat isPointOnLine(float position,float differentialLength) {\\nfloat fractionPartOfPosition=position-floor(position+0.5);\\nfractionPartOfPosition/=differentialLength;\\nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI);\\nreturn result;\\n}\\nfloat contributionOnAxis(float position) {\\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\\ndifferentialLength*=SQRT2;\\n\\nfloat result=isPointOnLine(position,differentialLength);\\n\\nfloat visibility=getVisibility(position);\\nresult*=visibility;\\n\\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\\nresult*=anisotropicAttenuation;\\nreturn result;\\n}\\nfloat normalImpactOnAxis(float x) {\\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\\nreturn normalImpact;\\n}\\nvoid main(void) {\\n\\nfloat gridRatio=gridControl.x;\\nvec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;\\n\\nfloat x=contributionOnAxis(gridPos.x);\\nfloat y=contributionOnAxis(gridPos.y);\\nfloat z=contributionOnAxis(gridPos.z);\\n\\nvec3 normal=normalize(vNormal);\\nx*=normalImpactOnAxis(normal.x);\\ny*=normalImpactOnAxis(normal.y);\\nz*=normalImpactOnAxis(normal.z);\\n\\nfloat grid=clamp(x+y+z,0.,1.);\\n\\nvec3 color=mix(mainColor,lineColor,grid);\\n#ifdef FOG\\n#include\\n#endif\\nfloat opacity=1.0;\\n#ifdef TRANSPARENT\\nopacity=clamp(grid,0.08,gridControl.w*grid);\\n#endif\\n#ifdef OPACITY\\nopacity*=texture2D(opacitySampler,vOpacityUV).a;\\n#endif\\n\\ngl_FragColor=vec4(color.rgb,opacity);\\n#ifdef TRANSPARENT\\n#ifdef PREMULTIPLYALPHA\\ngl_FragColor.rgb*=opacity;\\n#endif\\n#else\\n#endif\\n#include\\n}\";r.Effect.ShadersStore.gridPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\nattribute vec3 normal;\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#include\\n\\nuniform mat4 projection;\\nuniform mat4 view;\\n\\nvarying vec3 vPosition;\\nvarying vec3 vNormal;\\n#include\\n#ifdef OPACITY\\nvarying vec2 vOpacityUV;\\nuniform mat4 opacityMatrix;\\nuniform vec2 vOpacityInfos;\\n#endif\\nvoid main(void) {\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\n#include\\nvec4 cameraSpacePosition=view*worldPos;\\ngl_Position=projection*cameraSpacePosition;\\n#ifdef OPACITY\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\nif (vOpacityInfos.x == 0.)\\n{\\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\nvPosition=position;\\nvNormal=normal;\\n}\";r.Effect.ShadersStore.gridVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.OPACITY=!1,t.TRANSPARENT=!1,t.FOG=!1,t.PREMULTIPLYALPHA=!1,t.UV1=!1,t.UV2=!1,t.INSTANCES=!1,t.THIN_INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.mainColor=r.Color3.Black(),n.lineColor=r.Color3.Teal(),n.gridRatio=1,n.gridOffset=r.Vector3.Zero(),n.majorUnitFrequency=10,n.minorUnitVisibility=.33,n.opacity=1,n.preMultiplyAlpha=!1,n._gridControl=new r.Vector4(n.gridRatio,n.majorUnitFrequency,n.minorUnitVisibility,n.opacity),n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.opacity<1||this._opacityTexture&&this._opacityTexture.isReady()},t.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;if(n.TRANSPARENT!==this.opacity<1&&(n.TRANSPARENT=!n.TRANSPARENT,n.markAsUnprocessed()),n.PREMULTIPLYALPHA!=this.preMultiplyAlpha&&(n.PREMULTIPLYALPHA=!n.PREMULTIPLYALPHA,n.markAsUnprocessed()),n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._opacityTexture&&r.MaterialFlags.OpacityTextureEnabled)){if(!this._opacityTexture.isReady())return!1;n._needUVs=!0,n.OPACITY=!0}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,!1,this.fogEnabled,!1,n),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,o.getEngine(),n,!!i),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial(),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!1);var a=[r.VertexBuffer.PositionKind,r.VertexBuffer.NormalKind];n.UV1&&a.push(r.VertexBuffer.UVKind),n.UV2&&a.push(r.VertexBuffer.UV2Kind),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess,r.MaterialHelper.PrepareAttributesForInstances(a,n);var f=n.toString();t.setEffect(o.getEngine().createEffect(\"grid\",a,[\"projection\",\"mainColor\",\"lineColor\",\"gridControl\",\"gridOffset\",\"vFogInfos\",\"vFogColor\",\"world\",\"view\",\"opacityMatrix\",\"vOpacityInfos\"],[\"opacitySampler\"],f,void 0,this.onCompiled,this.onError),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,o.INSTANCES&&!o.THIN_INSTANCE||this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),this._activeEffect.setMatrix(\"projection\",n.getProjectionMatrix()),this._mustRebind(n,a)&&(this._activeEffect.setColor3(\"mainColor\",this.mainColor),this._activeEffect.setColor3(\"lineColor\",this.lineColor),this._activeEffect.setVector3(\"gridOffset\",this.gridOffset),this._gridControl.x=this.gridRatio,this._gridControl.y=Math.round(this.majorUnitFrequency),this._gridControl.z=this.minorUnitVisibility,this._gridControl.w=this.opacity,this._activeEffect.setVector4(\"gridControl\",this._gridControl),this._opacityTexture&&r.MaterialFlags.OpacityTextureEnabled&&(this._activeEffect.setTexture(\"opacitySampler\",this._opacityTexture),this._activeEffect.setFloat2(\"vOpacityInfos\",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._activeEffect.setMatrix(\"opacityMatrix\",this._opacityTexture.getTextureMatrix()))),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.GridMaterial\",e},t.prototype.getClassName=function(){return\"GridMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"mainColor\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"lineColor\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"gridRatio\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"gridOffset\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"majorUnitFrequency\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"minorUnitVisibility\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"opacity\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"preMultiplyAlpha\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"opacityTexture\")],t.prototype,\"_opacityTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"opacityTexture\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.GridMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"LavaMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n\\nvarying vec3 vPositionW;\\n\\nuniform float time;\\nuniform float speed;\\nuniform float movingSpeed;\\nuniform vec3 fogColor;\\nuniform sampler2D noiseTexture;\\nuniform float fogDensity;\\n\\nvarying float noise;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0]\\n#include<__decl__lightFragment>[1]\\n#include<__decl__lightFragment>[2]\\n#include<__decl__lightFragment>[3]\\n#include\\n#include\\n\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform sampler2D diffuseSampler;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#include\\n\\n#include\\nfloat random( vec3 scale,float seed ){\\nreturn fract( sin( dot( gl_FragCoord.xyz+seed,scale ) )*43758.5453+seed ) ;\\n}\\nvoid main(void) {\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(1.,1.,1.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n\\nfloat alpha=vDiffuseColor.a;\\n#ifdef DIFFUSE\\n\\nvec4 noiseTex=texture2D( noiseTexture,vDiffuseUV );\\nvec2 T1=vDiffuseUV+vec2( 1.5,-1.5 )*time*0.02;\\nvec2 T2=vDiffuseUV+vec2( -0.5,2.0 )*time*0.01*speed;\\nT1.x+=noiseTex.x*2.0;\\nT1.y+=noiseTex.y*2.0;\\nT2.x-=noiseTex.y*0.2+time*0.001*movingSpeed;\\nT2.y+=noiseTex.z*0.2+time*0.002*movingSpeed;\\nfloat p=texture2D( noiseTexture,T1*3.0 ).a;\\nvec4 lavaColor=texture2D( diffuseSampler,T2*4.0);\\nvec4 temp=lavaColor*( vec4( p,p,p,p )*2. )+( lavaColor*lavaColor-0.1 );\\nbaseColor=temp;\\nfloat depth=gl_FragCoord.z*4.0;\\nconst float LOG2=1.442695;\\nfloat fogFactor=exp2(-fogDensity*fogDensity*depth*depth*LOG2 );\\nfogFactor=1.0-clamp( fogFactor,0.0,1.0 );\\nbaseColor=mix( baseColor,vec4( fogColor,baseColor.w ),fogFactor );\\ndiffuseColor=baseColor.rgb;\\n\\n\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\n#include\\nbaseColor.rgb*=vDiffuseInfos.y;\\n#endif\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n#ifdef UNLIT\\nvec3 diffuseBase=vec3(1.,1.,1.);\\n#else\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\nfloat glossiness=0.;\\n#include[0]\\n#include[1]\\n#include[2]\\n#include[3]\\n#endif\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\\n\\nvec4 color=vec4(finalDiffuse,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\";r.Effect.ShadersStore.lavaPixelShader=o;var a=\"precision highp float;\\n\\nuniform float time;\\nuniform float lowFrequencySpeed;\\n\\nvarying float noise;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform mat4 diffuseMatrix;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n\\n\\n\\nvec3 mod289(vec3 x)\\n{\\nreturn x-floor(x*(1.0/289.0))*289.0;\\n}\\nvec4 mod289(vec4 x)\\n{\\nreturn x-floor(x*(1.0/289.0))*289.0;\\n}\\nvec4 permute(vec4 x)\\n{\\nreturn mod289(((x*34.0)+1.0)*x);\\n}\\nvec4 taylorInvSqrt(vec4 r)\\n{\\nreturn 1.79284291400159-0.85373472095314*r;\\n}\\nvec3 fade(vec3 t) {\\nreturn t*t*t*(t*(t*6.0-15.0)+10.0);\\n}\\n\\nfloat pnoise(vec3 P,vec3 rep)\\n{\\nvec3 Pi0=mod(floor(P),rep);\\nvec3 Pi1=mod(Pi0+vec3(1.0),rep);\\nPi0=mod289(Pi0);\\nPi1=mod289(Pi1);\\nvec3 Pf0=fract(P);\\nvec3 Pf1=Pf0-vec3(1.0);\\nvec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);\\nvec4 iy=vec4(Pi0.yy,Pi1.yy);\\nvec4 iz0=Pi0.zzzz;\\nvec4 iz1=Pi1.zzzz;\\nvec4 ixy=permute(permute(ix)+iy);\\nvec4 ixy0=permute(ixy+iz0);\\nvec4 ixy1=permute(ixy+iz1);\\nvec4 gx0=ixy0*(1.0/7.0);\\nvec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;\\ngx0=fract(gx0);\\nvec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);\\nvec4 sz0=step(gz0,vec4(0.0));\\ngx0-=sz0*(step(0.0,gx0)-0.5);\\ngy0-=sz0*(step(0.0,gy0)-0.5);\\nvec4 gx1=ixy1*(1.0/7.0);\\nvec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;\\ngx1=fract(gx1);\\nvec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);\\nvec4 sz1=step(gz1,vec4(0.0));\\ngx1-=sz1*(step(0.0,gx1)-0.5);\\ngy1-=sz1*(step(0.0,gy1)-0.5);\\nvec3 g000=vec3(gx0.x,gy0.x,gz0.x);\\nvec3 g100=vec3(gx0.y,gy0.y,gz0.y);\\nvec3 g010=vec3(gx0.z,gy0.z,gz0.z);\\nvec3 g110=vec3(gx0.w,gy0.w,gz0.w);\\nvec3 g001=vec3(gx1.x,gy1.x,gz1.x);\\nvec3 g101=vec3(gx1.y,gy1.y,gz1.y);\\nvec3 g011=vec3(gx1.z,gy1.z,gz1.z);\\nvec3 g111=vec3(gx1.w,gy1.w,gz1.w);\\nvec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));\\ng000*=norm0.x;\\ng010*=norm0.y;\\ng100*=norm0.z;\\ng110*=norm0.w;\\nvec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));\\ng001*=norm1.x;\\ng011*=norm1.y;\\ng101*=norm1.z;\\ng111*=norm1.w;\\nfloat n000=dot(g000,Pf0);\\nfloat n100=dot(g100,vec3(Pf1.x,Pf0.yz));\\nfloat n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));\\nfloat n110=dot(g110,vec3(Pf1.xy,Pf0.z));\\nfloat n001=dot(g001,vec3(Pf0.xy,Pf1.z));\\nfloat n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));\\nfloat n011=dot(g011,vec3(Pf0.x,Pf1.yz));\\nfloat n111=dot(g111,Pf1);\\nvec3 fade_xyz=fade(Pf0);\\nvec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);\\nvec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);\\nfloat n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);\\nreturn 2.2*n_xyz;\\n}\\n\\nfloat turbulence( vec3 p ) {\\nfloat w=100.0;\\nfloat t=-.5;\\nfor (float f=1.0 ; f<=10.0 ; f++ ){\\nfloat power=pow( 2.0,f );\\nt+=abs( pnoise( vec3( power*p ),vec3( 10.0,10.0,10.0 ) )/power );\\n}\\nreturn t;\\n}\\nvoid main(void) {\\n#include\\n#include\\n#ifdef NORMAL\\n\\nnoise=10.0*-.10*turbulence( .5*normal+time*1.15 );\\n\\nfloat b=lowFrequencySpeed*5.0*pnoise( 0.05*position +vec3(time*1.025),vec3( 100.0 ) );\\n\\nfloat displacement =-1.5*noise+b;\\n\\nvec3 newPosition=position+normal*displacement;\\ngl_Position=viewProjection*finalWorld*vec4( newPosition,1.0 );\\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\\nvPositionW=vec3(worldPos);\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef DIFFUSE\\nif (vDiffuseInfos.x == 0.)\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n\\n#include\\n\\n#include\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\";r.Effect.ShadersStore.lavaVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.LIGHT0=!1,t.LIGHT1=!1,t.LIGHT2=!1,t.LIGHT3=!1,t.SPOTLIGHT0=!1,t.SPOTLIGHT1=!1,t.SPOTLIGHT2=!1,t.SPOTLIGHT3=!1,t.HEMILIGHT0=!1,t.HEMILIGHT1=!1,t.HEMILIGHT2=!1,t.HEMILIGHT3=!1,t.DIRLIGHT0=!1,t.DIRLIGHT1=!1,t.DIRLIGHT2=!1,t.DIRLIGHT3=!1,t.POINTLIGHT0=!1,t.POINTLIGHT1=!1,t.POINTLIGHT2=!1,t.POINTLIGHT3=!1,t.SHADOW0=!1,t.SHADOW1=!1,t.SHADOW2=!1,t.SHADOW3=!1,t.SHADOWS=!1,t.SHADOWESM0=!1,t.SHADOWESM1=!1,t.SHADOWESM2=!1,t.SHADOWESM3=!1,t.SHADOWPOISSON0=!1,t.SHADOWPOISSON1=!1,t.SHADOWPOISSON2=!1,t.SHADOWPOISSON3=!1,t.SHADOWPCF0=!1,t.SHADOWPCF1=!1,t.SHADOWPCF2=!1,t.SHADOWPCF3=!1,t.SHADOWPCSS0=!1,t.SHADOWPCSS1=!1,t.SHADOWPCSS2=!1,t.SHADOWPCSS3=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.UNLIT=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.speed=1,n.movingSpeed=1,n.lowFrequencySpeed=1,n.fogDensity=.15,n._lastTime=0,n.diffuseColor=new r.Color3(1,1,1),n._disableLighting=!1,n._unlit=!1,n._maxSimultaneousLights=4,n._scaledDiffuse=new r.Color3,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=!0,r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,\"FOG\"),r.MaterialHelper.HandleFallbacksForShadows(n,f),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vDiffuseInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"diffuseMatrix\",\"time\",\"speed\",\"movingSpeed\",\"fogColor\",\"fogDensity\",\"lowFrequencySpeed\"],d=[\"diffuseSampler\",\"noiseTexture\"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect(\"lava\",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,o.UNLIT=this._unlit,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this.diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture(\"diffuseSampler\",this.diffuseTexture),this._activeEffect.setFloat2(\"vDiffuseInfos\",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix(\"diffuseMatrix\",this.diffuseTexture.getTextureMatrix())),this.noiseTexture&&this._activeEffect.setTexture(\"noiseTexture\",this.noiseTexture),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this._scaledDiffuse,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._lastTime+=n.getEngine().getDeltaTime(),this._activeEffect.setFloat(\"time\",this._lastTime*this.speed/1e3),this.fogColor||(this.fogColor=r.Color3.Black()),this._activeEffect.setColor3(\"fogColor\",this.fogColor),this._activeEffect.setFloat(\"fogDensity\",this.fogDensity),this._activeEffect.setFloat(\"lowFrequencySpeed\",this.lowFrequencySpeed),this._activeEffect.setFloat(\"movingSpeed\",this.movingSpeed),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.noiseTexture&&this.noiseTexture.animations&&this.noiseTexture.animations.length>0&&e.push(this.noiseTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this.diffuseTexture===t},t.prototype.dispose=function(t){this.diffuseTexture&&this.diffuseTexture.dispose(),this.noiseTexture&&this.noiseTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.LavaMaterial\",e},t.prototype.getClassName=function(){return\"LavaMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture\")],t.prototype,\"_diffuseTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture\",void 0),Object(n.a)([Object(r.serializeAsTexture)()],t.prototype,\"noiseTexture\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"fogColor\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"speed\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"movingSpeed\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"lowFrequencySpeed\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"fogDensity\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"diffuseColor\",void 0),Object(n.a)([Object(r.serialize)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(n.a)([Object(r.serialize)(\"unlit\")],t.prototype,\"_unlit\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"unlit\",void 0),Object(n.a)([Object(r.serialize)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.LavaMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"MixMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n#ifdef SPECULARTERM\\nuniform vec4 vSpecularColor;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n\\n#ifdef DIFFUSE\\nvarying vec2 vTextureUV;\\nuniform sampler2D mixMap1Sampler;\\nuniform vec2 vTextureInfos;\\n#ifdef MIXMAP2\\nuniform sampler2D mixMap2Sampler;\\n#endif\\nuniform sampler2D diffuse1Sampler;\\nuniform sampler2D diffuse2Sampler;\\nuniform sampler2D diffuse3Sampler;\\nuniform sampler2D diffuse4Sampler;\\nuniform vec2 diffuse1Infos;\\nuniform vec2 diffuse2Infos;\\nuniform vec2 diffuse3Infos;\\nuniform vec2 diffuse4Infos;\\n#ifdef MIXMAP2\\nuniform sampler2D diffuse5Sampler;\\nuniform sampler2D diffuse6Sampler;\\nuniform sampler2D diffuse7Sampler;\\nuniform sampler2D diffuse8Sampler;\\nuniform vec2 diffuse5Infos;\\nuniform vec2 diffuse6Infos;\\nuniform vec2 diffuse7Infos;\\nuniform vec2 diffuse8Infos;\\n#endif\\n#endif\\n\\n#include\\n#include\\n#include\\n\\n#include\\nvoid main(void) {\\n\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 finalMixColor=vec4(1.,1.,1.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n#ifdef MIXMAP2\\nvec4 mixColor2=vec4(1.,1.,1.,1.);\\n#endif\\n#ifdef SPECULARTERM\\nfloat glossiness=vSpecularColor.a;\\nvec3 specularColor=vSpecularColor.rgb;\\n#else\\nfloat glossiness=0.;\\n#endif\\n\\nfloat alpha=vDiffuseColor.a;\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n#ifdef DIFFUSE\\nvec4 mixColor=texture2D(mixMap1Sampler,vTextureUV);\\n#include\\nmixColor.rgb*=vTextureInfos.y;\\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\\nvec4 diffuse4Color=texture2D(diffuse4Sampler,vTextureUV*diffuse4Infos);\\ndiffuse1Color.rgb*=mixColor.r;\\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,mixColor.g);\\ndiffuse3Color.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,mixColor.b);\\nfinalMixColor.rgb=mix(diffuse3Color.rgb,diffuse4Color.rgb,1.0-mixColor.a);\\n#ifdef MIXMAP2\\nmixColor=texture2D(mixMap2Sampler,vTextureUV);\\nmixColor.rgb*=vTextureInfos.y;\\nvec4 diffuse5Color=texture2D(diffuse5Sampler,vTextureUV*diffuse5Infos);\\nvec4 diffuse6Color=texture2D(diffuse6Sampler,vTextureUV*diffuse6Infos);\\nvec4 diffuse7Color=texture2D(diffuse7Sampler,vTextureUV*diffuse7Infos);\\nvec4 diffuse8Color=texture2D(diffuse8Sampler,vTextureUV*diffuse8Infos);\\ndiffuse5Color.rgb=mix(finalMixColor.rgb,diffuse5Color.rgb,mixColor.r);\\ndiffuse6Color.rgb=mix(diffuse5Color.rgb,diffuse6Color.rgb,mixColor.g);\\ndiffuse7Color.rgb=mix(diffuse6Color.rgb,diffuse7Color.rgb,mixColor.b);\\nfinalMixColor.rgb=mix(diffuse7Color.rgb,diffuse8Color.rgb,1.0-mixColor.a);\\n#endif\\n#endif\\n#ifdef VERTEXCOLOR\\nfinalMixColor.rgb*=vColor.rgb;\\n#endif\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\n#ifdef SPECULARTERM\\nvec3 specularBase=vec3(0.,0.,0.);\\n#endif\\n#include[0..maxSimultaneousLights]\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n#ifdef SPECULARTERM\\nvec3 finalSpecular=specularBase*specularColor;\\n#else\\nvec3 finalSpecular=vec3(0.0);\\n#endif\\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*finalMixColor.rgb,0.0,1.0);\\n\\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\\n\";r.Effect.ShadersStore.mixPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSE\\nvarying vec2 vTextureUV;\\nuniform mat4 textureMatrix;\\nuniform vec2 vTextureInfos;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef DIFFUSE\\nif (vTextureInfos.x == 0.)\\n{\\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n\\n#include\\n\\n#include\\n\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.mixVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.MIXMAP2=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n.specularColor=new r.Color3(0,0,0),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(o.texturesEnabled){if(!this._mixTexture1||!this._mixTexture1.isReady())return!1;if(n._needUVs=!0,r.MaterialFlags.DiffuseTextureEnabled){if(!this._diffuseTexture1||!this._diffuseTexture1.isReady())return!1;if(n.DIFFUSE=!0,!this._diffuseTexture2||!this._diffuseTexture2.isReady())return!1;if(!this._diffuseTexture3||!this._diffuseTexture3.isReady())return!1;if(!this._diffuseTexture4||!this._diffuseTexture4.isReady())return!1;if(this._mixTexture2){if(!this._mixTexture2.isReady())return!1;if(n.MIXMAP2=!0,!this._diffuseTexture5||!this._diffuseTexture5.isReady())return!1;if(!this._diffuseTexture6||!this._diffuseTexture6.isReady())return!1;if(!this._diffuseTexture7||!this._diffuseTexture7.isReady())return!1;if(!this._diffuseTexture8||!this._diffuseTexture8.isReady())return!1}}}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,\"FOG\"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vSpecularColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vTextureInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"textureMatrix\",\"diffuse1Infos\",\"diffuse2Infos\",\"diffuse3Infos\",\"diffuse4Infos\",\"diffuse5Infos\",\"diffuse6Infos\",\"diffuse7Infos\",\"diffuse8Infos\"],d=[\"mixMap1Sampler\",\"mixMap2Sampler\",\"diffuse1Sampler\",\"diffuse2Sampler\",\"diffuse3Sampler\",\"diffuse4Sampler\",\"diffuse5Sampler\",\"diffuse6Sampler\",\"diffuse7Sampler\",\"diffuse8Sampler\"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect(\"mix\",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this._mixTexture1&&(this._activeEffect.setTexture(\"mixMap1Sampler\",this._mixTexture1),this._activeEffect.setFloat2(\"vTextureInfos\",this._mixTexture1.coordinatesIndex,this._mixTexture1.level),this._activeEffect.setMatrix(\"textureMatrix\",this._mixTexture1.getTextureMatrix()),r.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture1&&(this._activeEffect.setTexture(\"diffuse1Sampler\",this._diffuseTexture1),this._activeEffect.setFloat2(\"diffuse1Infos\",this._diffuseTexture1.uScale,this._diffuseTexture1.vScale)),this._diffuseTexture2&&(this._activeEffect.setTexture(\"diffuse2Sampler\",this._diffuseTexture2),this._activeEffect.setFloat2(\"diffuse2Infos\",this._diffuseTexture2.uScale,this._diffuseTexture2.vScale)),this._diffuseTexture3&&(this._activeEffect.setTexture(\"diffuse3Sampler\",this._diffuseTexture3),this._activeEffect.setFloat2(\"diffuse3Infos\",this._diffuseTexture3.uScale,this._diffuseTexture3.vScale)),this._diffuseTexture4&&(this._activeEffect.setTexture(\"diffuse4Sampler\",this._diffuseTexture4),this._activeEffect.setFloat2(\"diffuse4Infos\",this._diffuseTexture4.uScale,this._diffuseTexture4.vScale)))),this._mixTexture2&&(this._activeEffect.setTexture(\"mixMap2Sampler\",this._mixTexture2),r.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture5&&(this._activeEffect.setTexture(\"diffuse5Sampler\",this._diffuseTexture5),this._activeEffect.setFloat2(\"diffuse5Infos\",this._diffuseTexture5.uScale,this._diffuseTexture5.vScale)),this._diffuseTexture6&&(this._activeEffect.setTexture(\"diffuse6Sampler\",this._diffuseTexture6),this._activeEffect.setFloat2(\"diffuse6Infos\",this._diffuseTexture6.uScale,this._diffuseTexture6.vScale)),this._diffuseTexture7&&(this._activeEffect.setTexture(\"diffuse7Sampler\",this._diffuseTexture7),this._activeEffect.setFloat2(\"diffuse7Infos\",this._diffuseTexture7.uScale,this._diffuseTexture7.vScale)),this._diffuseTexture8&&(this._activeEffect.setTexture(\"diffuse8Sampler\",this._diffuseTexture8),this._activeEffect.setFloat2(\"diffuse8Infos\",this._diffuseTexture8.uScale,this._diffuseTexture8.vScale)))),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4(\"vSpecularColor\",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this._mixTexture1&&this._mixTexture1.animations&&this._mixTexture1.animations.length>0&&e.push(this._mixTexture1),this._mixTexture2&&this._mixTexture2.animations&&this._mixTexture2.animations.length>0&&e.push(this._mixTexture2),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._mixTexture1&&t.push(this._mixTexture1),this._diffuseTexture1&&t.push(this._diffuseTexture1),this._diffuseTexture2&&t.push(this._diffuseTexture2),this._diffuseTexture3&&t.push(this._diffuseTexture3),this._diffuseTexture4&&t.push(this._diffuseTexture4),this._mixTexture2&&t.push(this._mixTexture2),this._diffuseTexture5&&t.push(this._diffuseTexture5),this._diffuseTexture6&&t.push(this._diffuseTexture6),this._diffuseTexture7&&t.push(this._diffuseTexture7),this._diffuseTexture8&&t.push(this._diffuseTexture8),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._mixTexture1===t||(this._diffuseTexture1===t||(this._diffuseTexture2===t||(this._diffuseTexture3===t||(this._diffuseTexture4===t||(this._mixTexture2===t||(this._diffuseTexture5===t||(this._diffuseTexture6===t||(this._diffuseTexture7===t||this._diffuseTexture8===t)))))))))},t.prototype.dispose=function(t){this._mixTexture1&&this._mixTexture1.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.MixMaterial\",e},t.prototype.getClassName=function(){return\"MixMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)(\"mixTexture1\")],t.prototype,\"_mixTexture1\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"mixTexture1\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"mixTexture2\")],t.prototype,\"_mixTexture2\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"mixTexture2\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture1\")],t.prototype,\"_diffuseTexture1\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture1\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture2\")],t.prototype,\"_diffuseTexture2\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture2\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture3\")],t.prototype,\"_diffuseTexture3\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture3\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture4\")],t.prototype,\"_diffuseTexture4\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture4\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture1\")],t.prototype,\"_diffuseTexture5\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture5\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture2\")],t.prototype,\"_diffuseTexture6\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture6\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture3\")],t.prototype,\"_diffuseTexture7\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture7\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture4\")],t.prototype,\"_diffuseTexture8\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture8\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"diffuseColor\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"specularColor\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"specularPower\",void 0),Object(n.a)([Object(r.serialize)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(n.a)([Object(r.serialize)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.MixMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"NormalMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef LIGHTING\\n\\n#include\\n\\n#include<__decl__lightFragment>[0]\\n#include<__decl__lightFragment>[1]\\n#include<__decl__lightFragment>[2]\\n#include<__decl__lightFragment>[3]\\n#include\\n#include\\n#endif\\n\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform sampler2D diffuseSampler;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#include\\n\\n#include\\nvoid main(void) {\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(1.,1.,1.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n\\nfloat alpha=vDiffuseColor.a;\\n#ifdef DIFFUSE\\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\n#include\\nbaseColor.rgb*=vDiffuseInfos.y;\\n#endif\\n#ifdef NORMAL\\nbaseColor=mix(baseColor,vec4(vNormalW,1.0),0.5);\\n#endif\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n\\n#ifdef LIGHTING\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\nfloat glossiness=0.;\\n#include[0]\\n#include[1]\\n#include[2]\\n#include[3]\\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\\n#else\\nvec3 finalDiffuse=baseColor.rgb;\\n#endif\\n\\nvec4 color=vec4(finalDiffuse,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\";r.Effect.ShadersStore.normalPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform mat4 diffuseMatrix;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef DIFFUSE\\nif (vDiffuseInfos.x == 0.)\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n\\n#include\\n\\n#include\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.normalVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.LIGHT0=!1,t.LIGHT1=!1,t.LIGHT2=!1,t.LIGHT3=!1,t.SPOTLIGHT0=!1,t.SPOTLIGHT1=!1,t.SPOTLIGHT2=!1,t.SPOTLIGHT3=!1,t.HEMILIGHT0=!1,t.HEMILIGHT1=!1,t.HEMILIGHT2=!1,t.HEMILIGHT3=!1,t.DIRLIGHT0=!1,t.DIRLIGHT1=!1,t.DIRLIGHT2=!1,t.DIRLIGHT3=!1,t.POINTLIGHT0=!1,t.POINTLIGHT1=!1,t.POINTLIGHT2=!1,t.POINTLIGHT3=!1,t.SHADOW0=!1,t.SHADOW1=!1,t.SHADOW2=!1,t.SHADOW3=!1,t.SHADOWS=!1,t.SHADOWESM0=!1,t.SHADOWESM1=!1,t.SHADOWESM2=!1,t.SHADOWESM3=!1,t.SHADOWPOISSON0=!1,t.SHADOWPOISSON1=!1,t.SHADOWPOISSON2=!1,t.SHADOWPOISSON3=!1,t.SHADOWPCF0=!1,t.SHADOWPCF1=!1,t.SHADOWPCF2=!1,t.SHADOWPCF3=!1,t.SHADOWPCSS0=!1,t.SHADOWPCSS1=!1,t.SHADOWPCSS2=!1,t.SHADOWPCSS3=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.LIGHTING=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=!0,r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),n.LIGHTING=!this._disableLighting,r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,\"FOG\"),r.MaterialHelper.HandleFallbacksForShadows(n,f),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vDiffuseInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"diffuseMatrix\"],d=[\"diffuseSampler\"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:4}),t.setEffect(o.getEngine().createEffect(\"normal\",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this.diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture(\"diffuseSampler\",this.diffuseTexture),this._activeEffect.setFloat2(\"vDiffuseInfos\",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix(\"diffuseMatrix\",this.diffuseTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this.diffuseTexture===t},t.prototype.dispose=function(t){this.diffuseTexture&&this.diffuseTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.NormalMaterial\",e},t.prototype.getClassName=function(){return\"NormalMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture\")],t.prototype,\"_diffuseTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"diffuseColor\",void 0),Object(n.a)([Object(r.serialize)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(n.a)([Object(r.serialize)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.NormalMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"ShadowOnlyMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform float alpha;\\nuniform vec3 shadowColor;\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include\\n#include\\n\\n#include\\nvoid main(void) {\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\nfloat glossiness=0.;\\n#include[0..1]\\n\\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\";r.Effect.ShadersStore.shadowOnlyPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#include\\n\\n#include\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.shadowOnlyVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n._needAlphaBlending=!0,n.shadowColor=r.Color3.Black(),n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this._needAlphaBlending},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},Object.defineProperty(t.prototype,\"activeLight\",{get:function(){return this._activeLight},set:function(e){this._activeLight=e},enumerable:!1,configurable:!0}),t.prototype._getFirstShadowLightForMesh=function(e){for(var t=0,i=e.lightSources;t0&&v.addCPUSkinningFallback(0,e),o.IMAGEPROCESSINGPOSTPROCESS=a.imageProcessingConfiguration.applyByPostProcess;var m=[r.VertexBuffer.PositionKind];o.NORMAL&&m.push(r.VertexBuffer.NormalKind),r.MaterialHelper.PrepareAttributesForBones(m,e,o,v),r.MaterialHelper.PrepareAttributesForInstances(m,o);var g=o.toString(),x=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"alpha\",\"shadowColor\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\"],T=new Array,_=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:x,uniformBuffersNames:_,samplers:T,defines:o,maxSimultaneousLights:1}),t.setEffect(a.getEngine().createEffect(\"shadowOnly\",{attributes:m,uniformsNames:x,uniformBuffersNames:_,samplers:T,defines:g,fallbacks:v,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:1}},f),o)}return!(!t.effect||!t.effect.isReady())&&(o._renderId=a.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;if(a){if(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),this._activeEffect.setFloat(\"alpha\",this.alpha),this._activeEffect.setColor3(\"shadowColor\",this.shadowColor),r.MaterialHelper.BindEyePosition(a,n)),n.lightsEnabled){r.MaterialHelper.BindLights(n,t,this._activeEffect,o,1);var s=this._getFirstShadowLightForMesh(t);s&&(s._renderId=-1)}(n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE||o.SHADOWCSM0)&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect)}}},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.ShadowOnlyMaterial\",e},t.prototype.getClassName=function(){return\"ShadowOnlyMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.ShadowOnlyMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"SimpleMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include\\n\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform sampler2D diffuseSampler;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#include\\n\\n#include\\nvoid main(void) {\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(1.,1.,1.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n\\nfloat alpha=vDiffuseColor.a;\\n#ifdef DIFFUSE\\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\n#include\\nbaseColor.rgb*=vDiffuseInfos.y;\\n#endif\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\nfloat glossiness=0.;\\n#ifdef SPECULARTERM\\nvec3 specularBase=vec3(0.,0.,0.);\\n#endif\\n#include[0..maxSimultaneousLights]\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\\n\\nvec4 color=vec4(finalDiffuse,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\";r.Effect.ShadersStore.simplePixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSE\\nvarying vec2 vDiffuseUV;\\nuniform mat4 diffuseMatrix;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef DIFFUSE\\nif (vDiffuseInfos.x == 0.)\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n\\n#include\\n\\n#include\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.simpleVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,\"FOG\"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vDiffuseInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"diffuseMatrix\"],d=[\"diffuseSampler\"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect(\"simple\",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights-1}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture(\"diffuseSampler\",this._diffuseTexture),this._activeEffect.setFloat2(\"vDiffuseInfos\",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix(\"diffuseMatrix\",this._diffuseTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this.diffuseTexture===t},t.prototype.dispose=function(t){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.SimpleMaterial\",e},t.prototype.getClassName=function(){return\"SimpleMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture\")],t.prototype,\"_diffuseTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture\",void 0),Object(n.a)([Object(r.serializeAsColor3)(\"diffuse\")],t.prototype,\"diffuseColor\",void 0),Object(n.a)([Object(r.serialize)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(n.a)([Object(r.serialize)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.SimpleMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"SkyMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nvarying vec3 vPositionW;\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n\\nuniform vec3 cameraPosition;\\nuniform vec3 cameraOffset;\\nuniform float luminance;\\nuniform float turbidity;\\nuniform float rayleigh;\\nuniform float mieCoefficient;\\nuniform float mieDirectionalG;\\nuniform vec3 sunPosition;\\n\\n#include\\n\\nconst float e=2.71828182845904523536028747135266249775724709369995957;\\nconst float pi=3.141592653589793238462643383279502884197169;\\nconst float n=1.0003;\\nconst float N=2.545E25;\\nconst float pn=0.035;\\nconst vec3 lambda=vec3(680E-9,550E-9,450E-9);\\nconst vec3 K=vec3(0.686,0.678,0.666);\\nconst float v=4.0;\\nconst float rayleighZenithLength=8.4E3;\\nconst float mieZenithLength=1.25E3;\\nconst vec3 up=vec3(0.0,1.0,0.0);\\nconst float EE=1000.0;\\nconst float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;\\nconst float cutoffAngle=pi/1.95;\\nconst float steepness=1.5;\\nvec3 totalRayleigh(vec3 lambda)\\n{\\nreturn (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));\\n}\\nvec3 simplifiedRayleigh()\\n{\\nreturn 0.0005/vec3(94,40,18);\\n}\\nfloat rayleighPhase(float cosTheta)\\n{\\nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));\\n}\\nvec3 totalMie(vec3 lambda,vec3 K,float T)\\n{\\nfloat c=(0.2*T )*10E-18;\\nreturn 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;\\n}\\nfloat hgPhase(float cosTheta,float g)\\n{\\nreturn (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));\\n}\\nfloat sunIntensity(float zenithAngleCos)\\n{\\nreturn EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));\\n}\\nfloat A=0.15;\\nfloat B=0.50;\\nfloat C=0.10;\\nfloat D=0.20;\\nfloat EEE=0.02;\\nfloat F=0.30;\\nfloat W=1000.0;\\nvec3 Uncharted2Tonemap(vec3 x)\\n{\\nreturn ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;\\n}\\nvoid main(void) {\\n\\n#include\\n\\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);\\nfloat rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));\\nvec3 sunDirection=normalize(sunPosition);\\nfloat sunE=sunIntensity(dot(sunDirection,up));\\nvec3 betaR=simplifiedRayleigh()*rayleighCoefficient;\\nvec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;\\nfloat zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition+cameraOffset))));\\nfloat sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\\nfloat sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\\nvec3 Fex=exp(-(betaR*sR+betaM*sM));\\nfloat cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);\\nfloat rPhase=rayleighPhase(cosTheta*0.5+0.5);\\nvec3 betaRTheta=betaR*rPhase;\\nfloat mPhase=hgPhase(cosTheta,mieDirectionalG);\\nvec3 betaMTheta=betaM*mPhase;\\nvec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));\\nLin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));\\nvec3 direction=normalize(vPositionW-cameraPosition);\\nfloat theta=acos(direction.y);\\nfloat phi=atan(direction.z,direction.x);\\nvec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);\\nvec3 L0=vec3(0.1)*Fex;\\nfloat sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);\\nL0+=(sunE*19000.0*Fex)*sundisk;\\nvec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));\\nvec3 texColor=(Lin+L0);\\ntexColor*=0.04 ;\\ntexColor+=vec3(0.0,0.001,0.0025)*0.3;\\nfloat g_fMaxLuminance=1.0;\\nfloat fLumScaled=0.1/luminance;\\nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled);\\nfloat ExposureBias=fLumCompressed;\\nvec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);\\n\\n\\n\\nvec3 retColor=curr*whiteScale;\\n\\n\\nfloat alpha=1.0;\\n#ifdef VERTEXCOLOR\\nretColor.rgb*=vColor.rgb;\\n#endif\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n\\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\\n\\n#include\\ngl_FragColor=color;\\n#include\\n}\\n\";r.Effect.ShadersStore.skyPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n\\nuniform mat4 world;\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\nvoid main(void) {\\ngl_Position=viewProjection*world*vec4(position,1.0);\\nvec4 worldPos=world*vec4(position,1.0);\\nvPositionW=vec3(worldPos);\\n\\n#include\\n\\n#include\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.skyVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.POINTSIZE=!1,t.FOG=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.luminance=1,n.turbidity=10,n.rayleigh=2,n.mieCoefficient=.005,n.mieDirectionalG=.8,n.distance=500,n.inclination=.49,n.azimuth=.25,n.sunPosition=new r.Vector3(0,100,0),n.useSunPosition=!1,n.cameraOffset=r.Vector3.Zero(),n._cameraPosition=r.Vector3.Zero(),n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,!1,n),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!1),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var a=new r.EffectFallbacks;n.FOG&&a.addFallback(1,\"FOG\"),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var f=[r.VertexBuffer.PositionKind];n.VERTEXCOLOR&&f.push(r.VertexBuffer.ColorKind);var l=n.toString();t.setEffect(o.getEngine().createEffect(\"sky\",f,[\"world\",\"viewProjection\",\"view\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"luminance\",\"turbidity\",\"rayleigh\",\"mieCoefficient\",\"mieDirectionalG\",\"sunPosition\",\"cameraPosition\",\"cameraOffset\"],[],l,a,this.onCompiled,this.onError),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene();if(i._materialDefines){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),this._mustRebind(n,o)&&(r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize)),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect);var a=n.activeCamera;if(a){var s=a.getWorldMatrix();this._cameraPosition.x=s.m[12],this._cameraPosition.y=s.m[13],this._cameraPosition.z=s.m[14],this._activeEffect.setVector3(\"cameraPosition\",this._cameraPosition)}if(this._activeEffect.setVector3(\"cameraOffset\",this.cameraOffset),this.luminance>0&&this._activeEffect.setFloat(\"luminance\",this.luminance),this._activeEffect.setFloat(\"turbidity\",this.turbidity),this._activeEffect.setFloat(\"rayleigh\",this.rayleigh),this._activeEffect.setFloat(\"mieCoefficient\",this.mieCoefficient),this._activeEffect.setFloat(\"mieDirectionalG\",this.mieDirectionalG),!this.useSunPosition){var f=Math.PI*(this.inclination-.5),l=2*Math.PI*(this.azimuth-.5);this.sunPosition.x=this.distance*Math.cos(l),this.sunPosition.y=this.distance*Math.sin(l)*Math.sin(f),this.sunPosition.z=this.distance*Math.sin(l)*Math.cos(f)}this._activeEffect.setVector3(\"sunPosition\",this.sunPosition),this._afterBind(t,this._activeEffect)}}},t.prototype.getAnimatables=function(){return[]},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.SkyMaterial\",e},t.prototype.getClassName=function(){return\"SkyMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serialize)()],t.prototype,\"luminance\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"turbidity\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"rayleigh\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"mieCoefficient\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"mieDirectionalG\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"distance\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"inclination\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"azimuth\",void 0),Object(n.a)([Object(r.serializeAsVector3)()],t.prototype,\"sunPosition\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"useSunPosition\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"cameraOffset\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.SkyMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"TerrainMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n#ifdef SPECULARTERM\\nuniform vec4 vSpecularColor;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n\\n#ifdef DIFFUSE\\nvarying vec2 vTextureUV;\\nuniform sampler2D textureSampler;\\nuniform vec2 vTextureInfos;\\nuniform sampler2D diffuse1Sampler;\\nuniform sampler2D diffuse2Sampler;\\nuniform sampler2D diffuse3Sampler;\\nuniform vec2 diffuse1Infos;\\nuniform vec2 diffuse2Infos;\\nuniform vec2 diffuse3Infos;\\n#endif\\n#ifdef BUMP\\nuniform sampler2D bump1Sampler;\\nuniform sampler2D bump2Sampler;\\nuniform sampler2D bump3Sampler;\\n#endif\\n\\n#include\\n#include\\n#include\\n\\n#include\\n\\n#ifdef BUMP\\n#extension GL_OES_standard_derivatives : enable\\n\\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\\n{\\n\\nvec3 dp1=dFdx(p);\\nvec3 dp2=dFdy(p);\\nvec2 duv1=dFdx(uv);\\nvec2 duv2=dFdy(uv);\\n\\nvec3 dp2perp=cross(dp2,normal);\\nvec3 dp1perp=cross(normal,dp1);\\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\\nvec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\\n\\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\\nreturn mat3(tangent*invmax,binormal*invmax,normal);\\n}\\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\\n{\\nvec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;\\nvec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;\\nvec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;\\nbump1Color.rgb*=mixColor.r;\\nbump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);\\nvec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);\\nmap=map*255./127.-128./127.;\\nmat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);\\nreturn normalize(TBN*map);\\n}\\n#endif\\nvoid main(void) {\\n\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(1.,1.,1.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n#ifdef SPECULARTERM\\nfloat glossiness=vSpecularColor.a;\\nvec3 specularColor=vSpecularColor.rgb;\\n#else\\nfloat glossiness=0.;\\n#endif\\n\\nfloat alpha=vDiffuseColor.a;\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\n#ifdef DIFFUSE\\nbaseColor=texture2D(textureSampler,vTextureUV);\\n#if defined(BUMP) && defined(DIFFUSE)\\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\\n#endif\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\n#include\\nbaseColor.rgb*=vTextureInfos.y;\\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\\ndiffuse1Color.rgb*=baseColor.r;\\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);\\nbaseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\\n#endif\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\n#ifdef SPECULARTERM\\nvec3 specularBase=vec3(0.,0.,0.);\\n#endif\\n#include[0..maxSimultaneousLights]\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n#ifdef SPECULARTERM\\nvec3 finalSpecular=specularBase*specularColor;\\n#else\\nvec3 finalSpecular=vec3(0.0);\\n#endif\\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);\\n\\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\\n\";r.Effect.ShadersStore.terrainPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSE\\nvarying vec2 vTextureUV;\\nuniform mat4 textureMatrix;\\nuniform vec2 vTextureInfos;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef DIFFUSE\\nif (vTextureInfos.x == 0.)\\n{\\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n\\n#include\\n\\n#include\\n\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.terrainVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.BUMP=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n.specularColor=new r.Color3(0,0,0),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(o.texturesEnabled){if(!this.mixTexture||!this.mixTexture.isReady())return!1;if(n._needUVs=!0,r.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture1||!this.diffuseTexture1.isReady())return!1;if(!this.diffuseTexture2||!this.diffuseTexture2.isReady())return!1;if(!this.diffuseTexture3||!this.diffuseTexture3.isReady())return!1;n.DIFFUSE=!0}if(this.bumpTexture1&&this.bumpTexture2&&this.bumpTexture3&&r.MaterialFlags.BumpTextureEnabled){if(!this.bumpTexture1.isReady())return!1;if(!this.bumpTexture2.isReady())return!1;if(!this.bumpTexture3.isReady())return!1;n._needNormals=!0,n.BUMP=!0}}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,\"FOG\"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vSpecularColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vTextureInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"textureMatrix\",\"diffuse1Infos\",\"diffuse2Infos\",\"diffuse3Infos\"],d=[\"textureSampler\",\"diffuse1Sampler\",\"diffuse2Sampler\",\"diffuse3Sampler\",\"bump1Sampler\",\"bump2Sampler\",\"bump3Sampler\"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect(\"terrain\",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this.mixTexture&&(this._activeEffect.setTexture(\"textureSampler\",this._mixTexture),this._activeEffect.setFloat2(\"vTextureInfos\",this._mixTexture.coordinatesIndex,this._mixTexture.level),this._activeEffect.setMatrix(\"textureMatrix\",this._mixTexture.getTextureMatrix()),r.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture1&&(this._activeEffect.setTexture(\"diffuse1Sampler\",this._diffuseTexture1),this._activeEffect.setFloat2(\"diffuse1Infos\",this._diffuseTexture1.uScale,this._diffuseTexture1.vScale)),this._diffuseTexture2&&(this._activeEffect.setTexture(\"diffuse2Sampler\",this._diffuseTexture2),this._activeEffect.setFloat2(\"diffuse2Infos\",this._diffuseTexture2.uScale,this._diffuseTexture2.vScale)),this._diffuseTexture3&&(this._activeEffect.setTexture(\"diffuse3Sampler\",this._diffuseTexture3),this._activeEffect.setFloat2(\"diffuse3Infos\",this._diffuseTexture3.uScale,this._diffuseTexture3.vScale))),r.MaterialFlags.BumpTextureEnabled&&n.getEngine().getCaps().standardDerivatives&&(this._bumpTexture1&&this._activeEffect.setTexture(\"bump1Sampler\",this._bumpTexture1),this._bumpTexture2&&this._activeEffect.setTexture(\"bump2Sampler\",this._bumpTexture2),this._bumpTexture3&&this._activeEffect.setTexture(\"bump3Sampler\",this._bumpTexture3))),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4(\"vSpecularColor\",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._mixTexture&&t.push(this._mixTexture),this._diffuseTexture1&&t.push(this._diffuseTexture1),this._diffuseTexture2&&t.push(this._diffuseTexture2),this._diffuseTexture3&&t.push(this._diffuseTexture3),this._bumpTexture1&&t.push(this._bumpTexture1),this._bumpTexture2&&t.push(this._bumpTexture2),this._bumpTexture3&&t.push(this._bumpTexture3),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._mixTexture===t||(this._diffuseTexture1===t||(this._diffuseTexture2===t||(this._diffuseTexture3===t||(this._bumpTexture1===t||(this._bumpTexture2===t||this._bumpTexture3===t))))))},t.prototype.dispose=function(t){this.mixTexture&&this.mixTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.TerrainMaterial\",e},t.prototype.getClassName=function(){return\"TerrainMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)(\"mixTexture\")],t.prototype,\"_mixTexture\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"mixTexture\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture1\")],t.prototype,\"_diffuseTexture1\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture1\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture2\")],t.prototype,\"_diffuseTexture2\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture2\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexture3\")],t.prototype,\"_diffuseTexture3\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture3\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"bumpTexture1\")],t.prototype,\"_bumpTexture1\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"bumpTexture1\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"bumpTexture2\")],t.prototype,\"_bumpTexture2\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"bumpTexture2\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"bumpTexture3\")],t.prototype,\"_bumpTexture3\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"bumpTexture3\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"diffuseColor\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"specularColor\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"specularPower\",void 0),Object(n.a)([Object(r.serialize)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(n.a)([Object(r.serialize)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.TerrainMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"TriPlanarMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"precision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n#ifdef SPECULARTERM\\nuniform vec4 vSpecularColor;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n\\n#ifdef DIFFUSEX\\nvarying vec2 vTextureUVX;\\nuniform sampler2D diffuseSamplerX;\\n#ifdef BUMPX\\nuniform sampler2D normalSamplerX;\\n#endif\\n#endif\\n#ifdef DIFFUSEY\\nvarying vec2 vTextureUVY;\\nuniform sampler2D diffuseSamplerY;\\n#ifdef BUMPY\\nuniform sampler2D normalSamplerY;\\n#endif\\n#endif\\n#ifdef DIFFUSEZ\\nvarying vec2 vTextureUVZ;\\nuniform sampler2D diffuseSamplerZ;\\n#ifdef BUMPZ\\nuniform sampler2D normalSamplerZ;\\n#endif\\n#endif\\n#ifdef NORMAL\\nvarying mat3 tangentSpace;\\n#endif\\n#include\\n#include\\n#include\\n#include\\nvoid main(void) {\\n\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(0.,0.,0.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n\\nfloat alpha=vDiffuseColor.a;\\n\\n#ifdef NORMAL\\nvec3 normalW=tangentSpace[2];\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\n#endif\\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);\\nnormalW*=normalW;\\n#ifdef DIFFUSEX\\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\\n#ifdef BUMPX\\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\\n#endif\\n#endif\\n#ifdef DIFFUSEY\\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\\n#ifdef BUMPY\\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\\n#endif\\n#endif\\n#ifdef DIFFUSEZ\\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\\n#ifdef BUMPZ\\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\\n#endif\\n#endif\\n#ifdef NORMAL\\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\\n#endif\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\n#include\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\n#ifdef SPECULARTERM\\nfloat glossiness=vSpecularColor.a;\\nvec3 specularBase=vec3(0.,0.,0.);\\nvec3 specularColor=vSpecularColor.rgb;\\n#else\\nfloat glossiness=0.;\\n#endif\\n#include[0..maxSimultaneousLights]\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n#ifdef SPECULARTERM\\nvec3 finalSpecular=specularBase*specularColor;\\n#else\\nvec3 finalSpecular=vec3(0.0);\\n#endif\\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\\n\\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\\n#include\\ngl_FragColor=color;\\n#include\\n}\\n\";r.Effect.ShadersStore.triplanarPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef DIFFUSEX\\nvarying vec2 vTextureUVX;\\n#endif\\n#ifdef DIFFUSEY\\nvarying vec2 vTextureUVY;\\n#endif\\n#ifdef DIFFUSEZ\\nvarying vec2 vTextureUVZ;\\n#endif\\nuniform float tileSize;\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying mat3 tangentSpace;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\nvoid main(void)\\n{\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\ngl_Position=viewProjection*worldPos;\\nvPositionW=vec3(worldPos);\\n#ifdef DIFFUSEX\\nvTextureUVX=worldPos.zy/tileSize;\\n#endif\\n#ifdef DIFFUSEY\\nvTextureUVY=worldPos.xz/tileSize;\\n#endif\\n#ifdef DIFFUSEZ\\nvTextureUVZ=worldPos.xy/tileSize;\\n#endif\\n#ifdef NORMAL\\n\\nvec3 xtan=vec3(0,0,1);\\nvec3 xbin=vec3(0,1,0);\\nvec3 ytan=vec3(1,0,0);\\nvec3 ybin=vec3(0,0,1);\\nvec3 ztan=vec3(1,0,0);\\nvec3 zbin=vec3(0,1,0);\\nvec3 normalizedNormal=normalize(normal);\\nnormalizedNormal*=normalizedNormal;\\nvec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);\\nvec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);\\nworldTangent=(world*vec4(worldTangent,1.0)).xyz;\\nworldBinormal=(world*vec4(worldBinormal,1.0)).xyz;\\nvec3 worldNormal=(world*vec4(normalize(normal),1.0)).xyz;\\ntangentSpace[0]=worldTangent;\\ntangentSpace[1]=worldBinormal;\\ntangentSpace[2]=worldNormal;\\n#endif\\n\\n#include\\n\\n#include\\n\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";r.Effect.ShadersStore.triplanarVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSEX=!1,t.DIFFUSEY=!1,t.DIFFUSEZ=!1,t.BUMPX=!1,t.BUMPY=!1,t.BUMPZ=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.NORMAL=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.tileSize=1,n.diffuseColor=new r.Color3(1,1,1),n.specularColor=new r.Color3(.2,.2,.2),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&o.texturesEnabled){if(r.MaterialFlags.DiffuseTextureEnabled)for(var f=[this.diffuseTextureX,this.diffuseTextureY,this.diffuseTextureZ],l=[\"DIFFUSEX\",\"DIFFUSEY\",\"DIFFUSEZ\"],u=0;u0&&c.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var d=[r.VertexBuffer.PositionKind];n.NORMAL&&d.push(r.VertexBuffer.NormalKind),n.VERTEXCOLOR&&d.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(d,e,n,c),r.MaterialHelper.PrepareAttributesForInstances(d,n);var p=n.toString(),h=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vSpecularColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"tileSize\"],v=[\"diffuseSamplerX\",\"diffuseSamplerY\",\"diffuseSamplerZ\",\"normalSamplerX\",\"normalSamplerY\",\"normalSamplerZ\"],m=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:h,uniformBuffersNames:m,samplers:v,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect(\"triplanar\",{attributes:d,uniformsNames:h,uniformBuffersNames:m,samplers:v,defines:p,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._activeEffect.setFloat(\"tileSize\",this.tileSize),n.getCachedMaterial()!==this&&(this.diffuseTextureX&&this._activeEffect.setTexture(\"diffuseSamplerX\",this.diffuseTextureX),this.diffuseTextureY&&this._activeEffect.setTexture(\"diffuseSamplerY\",this.diffuseTextureY),this.diffuseTextureZ&&this._activeEffect.setTexture(\"diffuseSamplerZ\",this.diffuseTextureZ),this.normalTextureX&&this._activeEffect.setTexture(\"normalSamplerX\",this.normalTextureX),this.normalTextureY&&this._activeEffect.setTexture(\"normalSamplerY\",this.normalTextureY),this.normalTextureZ&&this._activeEffect.setTexture(\"normalSamplerZ\",this.normalTextureZ),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4(\"vSpecularColor\",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTextureX&&t.push(this._diffuseTextureX),this._diffuseTextureY&&t.push(this._diffuseTextureY),this._diffuseTextureZ&&t.push(this._diffuseTextureZ),this._normalTextureX&&t.push(this._normalTextureX),this._normalTextureY&&t.push(this._normalTextureY),this._normalTextureZ&&t.push(this._normalTextureZ),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTextureX===t||(this._diffuseTextureY===t||(this._diffuseTextureZ===t||(this._normalTextureX===t||(this._normalTextureY===t||this._normalTextureZ===t)))))},t.prototype.dispose=function(t){this.mixTexture&&this.mixTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType=\"BABYLON.TriPlanarMaterial\",e},t.prototype.getClassName=function(){return\"TriPlanarMaterial\"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)()],t.prototype,\"mixTexture\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTextureX\")],t.prototype,\"_diffuseTextureX\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTextureX\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTexturY\")],t.prototype,\"_diffuseTextureY\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTextureY\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"diffuseTextureZ\")],t.prototype,\"_diffuseTextureZ\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTextureZ\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"normalTextureX\")],t.prototype,\"_normalTextureX\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"normalTextureX\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"normalTextureY\")],t.prototype,\"_normalTextureY\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"normalTextureY\",void 0),Object(n.a)([Object(r.serializeAsTexture)(\"normalTextureZ\")],t.prototype,\"_normalTextureZ\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"normalTextureZ\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"tileSize\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"diffuseColor\",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,\"specularColor\",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,\"specularPower\",void 0),Object(n.a)([Object(r.serialize)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(n.a)([Object(r.serialize)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.a)([Object(r.expandToProperty)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.TriPlanarMaterial\"]=f},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"WaterMaterial\",(function(){return f}));var n=i(1),r=i(0),o=\"#ifdef LOGARITHMICDEPTH\\n#extension GL_EXT_frag_depth : enable\\n#endif\\nprecision highp float;\\n\\nuniform vec3 vEyePosition;\\nuniform vec4 vDiffuseColor;\\n#ifdef SPECULARTERM\\nuniform vec4 vSpecularColor;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n\\n#include\\n#include\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include\\n\\n#ifdef BUMP\\nvarying vec2 vNormalUV;\\nvarying vec2 vNormalUV2;\\nuniform sampler2D normalSampler;\\nuniform vec2 vNormalInfos;\\n#endif\\nuniform sampler2D refractionSampler;\\nuniform sampler2D reflectionSampler;\\n\\nconst float LOG2=1.442695;\\nuniform vec3 cameraPosition;\\nuniform vec4 waterColor;\\nuniform float colorBlendFactor;\\nuniform vec4 waterColor2;\\nuniform float colorBlendFactor2;\\nuniform float bumpHeight;\\nuniform float time;\\n\\nvarying vec3 vRefractionMapTexCoord;\\nvarying vec3 vReflectionMapTexCoord;\\nvarying vec3 vPosition;\\n#include\\n#include\\n\\n#include\\nvoid main(void) {\\n\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(1.,1.,1.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n\\nfloat alpha=vDiffuseColor.a;\\n#ifdef BUMP\\n#ifdef BUMPSUPERIMPOSE\\nbaseColor=0.6*texture2D(normalSampler,vNormalUV)+0.4*texture2D(normalSampler,vec2(vNormalUV2.x,vNormalUV2.y));\\n#else\\nbaseColor=texture2D(normalSampler,vNormalUV);\\n#endif\\nvec3 bumpColor=baseColor.rgb;\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\nbaseColor.rgb*=vNormalInfos.y;\\n#else\\nvec3 bumpColor=vec3(1.0);\\n#endif\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n\\n#ifdef NORMAL\\nvec2 perturbation=bumpHeight*(baseColor.rg-0.5);\\n#ifdef BUMPAFFECTSREFLECTION\\nvec3 normalW=normalize(vNormalW+vec3(perturbation.x*8.0,0.0,perturbation.y*8.0));\\nif (normalW.y<0.0) {\\nnormalW.y=-normalW.y;\\n}\\n#else\\nvec3 normalW=normalize(vNormalW);\\n#endif\\n#else\\nvec3 normalW=vec3(1.0,1.0,1.0);\\nvec2 perturbation=bumpHeight*(vec2(1.0,1.0)-0.5);\\n#endif\\n#ifdef FRESNELSEPARATE\\n#ifdef REFLECTION\\n\\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation*0.5,0.0,1.0);\\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\\n#ifdef IS_REFRACTION_LINEAR\\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\\n#endif\\nvec2 projectedReflectionTexCoords=clamp(vec2(\\nvReflectionMapTexCoord.x/vReflectionMapTexCoord.z+perturbation.x*0.3,\\nvReflectionMapTexCoord.y/vReflectionMapTexCoord.z+perturbation.y\\n),0.0,1.0);\\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\\n#ifdef IS_REFLECTION_LINEAR\\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\\n#endif\\nvec3 upVector=vec3(0.0,1.0,0.0);\\nfloat fresnelTerm=clamp(abs(pow(dot(viewDirectionW,upVector),3.0)),0.05,0.65);\\nfloat IfresnelTerm=1.0-fresnelTerm;\\nrefractiveColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*refractiveColor;\\nreflectiveColor=IfresnelTerm*colorBlendFactor2*waterColor+(1.0-colorBlendFactor2*IfresnelTerm)*reflectiveColor;\\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*IfresnelTerm;\\nbaseColor=combinedColor;\\n#endif\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\n#ifdef SPECULARTERM\\nfloat glossiness=vSpecularColor.a;\\nvec3 specularBase=vec3(0.,0.,0.);\\nvec3 specularColor=vSpecularColor.rgb;\\n#else\\nfloat glossiness=0.;\\n#endif\\n#include[0..maxSimultaneousLights]\\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n#ifdef SPECULARTERM\\nvec3 finalSpecular=specularBase*specularColor;\\n#else\\nvec3 finalSpecular=vec3(0.0);\\n#endif\\n#else\\n#ifdef REFLECTION\\n\\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation,0.0,1.0);\\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\\n#ifdef IS_REFRACTION_LINEAR\\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\\n#endif\\nvec2 projectedReflectionTexCoords=clamp(vReflectionMapTexCoord.xy/vReflectionMapTexCoord.z+perturbation,0.0,1.0);\\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\\n#ifdef IS_REFLECTION_LINEAR\\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\\n#endif\\nvec3 upVector=vec3(0.0,1.0,0.0);\\nfloat fresnelTerm=max(dot(viewDirectionW,upVector),0.0);\\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*(1.0-fresnelTerm);\\nbaseColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*combinedColor;\\n#endif\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\nfloat shadow=1.;\\n#ifdef SPECULARTERM\\nfloat glossiness=vSpecularColor.a;\\nvec3 specularBase=vec3(0.,0.,0.);\\nvec3 specularColor=vSpecularColor.rgb;\\n#else\\nfloat glossiness=0.;\\n#endif\\n#include[0..maxSimultaneousLights]\\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n#ifdef SPECULARTERM\\nvec3 finalSpecular=specularBase*specularColor;\\n#else\\nvec3 finalSpecular=vec3(0.0);\\n#endif\\n#endif\\n\\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\\n#include\\n#include\\n\\n\\n#ifdef IMAGEPROCESSINGPOSTPROCESS\\ncolor.rgb=toLinearSpace(color.rgb);\\n#elif defined(IMAGEPROCESSING)\\ncolor.rgb=toLinearSpace(color.rgb);\\ncolor=applyImageProcessing(color);\\n#endif\\ngl_FragColor=color;\\n}\\n\";r.Effect.ShadersStore.waterPixelShader=o;var a=\"precision highp float;\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n\\n#include\\nuniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef BUMP\\nvarying vec2 vNormalUV;\\n#ifdef BUMPSUPERIMPOSE\\nvarying vec2 vNormalUV2;\\n#endif\\nuniform mat4 normalMatrix;\\nuniform vec2 vNormalInfos;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n\\nuniform mat4 worldReflectionViewProjection;\\nuniform vec2 windDirection;\\nuniform float waveLength;\\nuniform float time;\\nuniform float windForce;\\nuniform float waveHeight;\\nuniform float waveSpeed;\\nuniform float waveCount;\\n\\nvarying vec3 vPosition;\\nvarying vec3 vRefractionMapTexCoord;\\nvarying vec3 vReflectionMapTexCoord;\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\nvPositionW=vec3(worldPos);\\n#ifdef NORMAL\\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef BUMP\\nif (vNormalInfos.x == 0.)\\n{\\nvNormalUV=vec2(normalMatrix*vec4((uv*1.0)/waveLength+time*windForce*windDirection,1.0,0.0));\\n#ifdef BUMPSUPERIMPOSE\\nvNormalUV2=vec2(normalMatrix*vec4((uv*0.721)/waveLength+time*1.2*windForce*windDirection,1.0,0.0));\\n#endif\\n}\\nelse\\n{\\nvNormalUV=vec2(normalMatrix*vec4((uv2*1.0)/waveLength+time*windForce*windDirection ,1.0,0.0));\\n#ifdef BUMPSUPERIMPOSE\\nvNormalUV2=vec2(normalMatrix*vec4((uv2*0.721)/waveLength+time*1.2*windForce*windDirection ,1.0,0.0));\\n#endif\\n}\\n#endif\\n\\n#include\\n\\n#include\\n\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\nfloat finalWaveCount=1.0/(waveCount*0.5);\\nvec3 p=position;\\nfloat newY=(sin(((p.x/finalWaveCount)+time*waveSpeed))*waveHeight*windDirection.x*5.0)\\n+(cos(((p.z/finalWaveCount)+time*waveSpeed))*waveHeight*windDirection.y*5.0);\\np.y+=abs(newY);\\ngl_Position=viewProjection*finalWorld*vec4(p,1.0);\\n#ifdef REFLECTION\\nworldPos=viewProjection*finalWorld*vec4(p,1.0);\\n\\nvPosition=position;\\nvRefractionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\\nvRefractionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\\nvRefractionMapTexCoord.z=worldPos.w;\\nworldPos=worldReflectionViewProjection*vec4(position,1.0);\\nvReflectionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\\nvReflectionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\\nvReflectionMapTexCoord.z=worldPos.w;\\n#endif\\n#include\\n}\\n\";r.Effect.ShadersStore.waterVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.BUMP=!1,t.REFLECTION=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.SPECULARTERM=!1,t.LOGARITHMICDEPTH=!1,t.FRESNELSEPARATE=!1,t.BUMPSUPERIMPOSE=!1,t.BUMPAFFECTSREFLECTION=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.EXPOSURE=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i,n){void 0===n&&(n=new r.Vector2(512,512));var o=e.call(this,t,i)||this;return o.renderTargetSize=n,o.diffuseColor=new r.Color3(1,1,1),o.specularColor=new r.Color3(0,0,0),o.specularPower=64,o._disableLighting=!1,o._maxSimultaneousLights=4,o.windForce=6,o.windDirection=new r.Vector2(0,1),o.waveHeight=.4,o.bumpHeight=.4,o._bumpSuperimpose=!1,o._fresnelSeparate=!1,o._bumpAffectsReflection=!1,o.waterColor=new r.Color3(.1,.1,.6),o.colorBlendFactor=.2,o.waterColor2=new r.Color3(.1,.1,.6),o.colorBlendFactor2=.2,o.waveLength=.1,o.waveSpeed=1,o.waveCount=20,o.disableClipPlane=!1,o._renderTargets=new r.SmartArray(16),o._mesh=null,o._reflectionTransform=r.Matrix.Zero(),o._lastTime=0,o._lastDeltaTime=0,o._createRenderTargets(i,n),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._renderTargets.push(o._reflectionRTT),o._renderTargets.push(o._refractionRTT),o._renderTargets},o._imageProcessingConfiguration=o.getScene().imageProcessingConfiguration,o._imageProcessingConfiguration&&(o._imageProcessingObserver=o._imageProcessingConfiguration.onUpdateParameters.add((function(){o._markAllSubMeshesAsImageProcessingDirty()}))),o}return Object(n.b)(t,e),Object.defineProperty(t.prototype,\"hasRenderTargetTextures\",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"useLogarithmicDepth\",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"refractionTexture\",{get:function(){return this._refractionRTT},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"reflectionTexture\",{get:function(){return this._reflectionRTT},enumerable:!1,configurable:!0}),t.prototype.addToRenderList=function(e){this._refractionRTT&&this._refractionRTT.renderList&&this._refractionRTT.renderList.push(e),this._reflectionRTT&&this._reflectionRTT.renderList&&this._reflectionRTT.renderList.push(e)},t.prototype.enableRenderTargets=function(e){var t=e?1:0;this._refractionRTT&&(this._refractionRTT.refreshRate=t),this._reflectionRTT&&(this._reflectionRTT.refreshRate=t)},t.prototype.getRenderList=function(){return this._refractionRTT?this._refractionRTT.renderList:[]},Object.defineProperty(t.prototype,\"renderTargetsEnabled\",{get:function(){return!(this._refractionRTT&&0===this._refractionRTT.refreshRate)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled)){if(this.bumpTexture&&r.MaterialFlags.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;n._needUVs=!0,n.BUMP=!0}r.MaterialFlags.ReflectionTextureEnabled&&(n.REFLECTION=!0)}if(r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForMisc(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._areMiscDirty&&(this._fresnelSeparate&&(n.FRESNELSEPARATE=!0),this._bumpSuperimpose&&(n.BUMPSUPERIMPOSE=!0),this._bumpAffectsReflection&&(n.BUMPAFFECTSREFLECTION=!0)),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(n),n.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,n.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),this._mesh=e,this._waitingRenderList){for(var f=0;f0&&l.addCPUSkinningFallback(0,e);var u=[r.VertexBuffer.PositionKind];n.NORMAL&&u.push(r.VertexBuffer.NormalKind),n.UV1&&u.push(r.VertexBuffer.UVKind),n.UV2&&u.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&u.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(u,e,n,l),r.MaterialHelper.PrepareAttributesForInstances(u,n);var c=n.toString(),d=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vDiffuseColor\",\"vSpecularColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vNormalInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"normalMatrix\",\"logarithmicDepthConstant\",\"worldReflectionViewProjection\",\"windDirection\",\"waveLength\",\"time\",\"windForce\",\"cameraPosition\",\"bumpHeight\",\"waveHeight\",\"waterColor\",\"waterColor2\",\"colorBlendFactor\",\"colorBlendFactor2\",\"waveSpeed\",\"waveCount\"],p=[\"normalSampler\",\"refractionSampler\",\"reflectionSampler\"],h=new Array;r.ImageProcessingConfiguration&&(r.ImageProcessingConfiguration.PrepareUniforms(d,n),r.ImageProcessingConfiguration.PrepareSamplers(p,n)),r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:h,samplers:p,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect(\"water\",{attributes:u,uniformsNames:d,uniformBuffersNames:h,samplers:p,defines:c,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;if(a&&this._mesh){this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix(\"viewProjection\",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this.bumpTexture&&r.MaterialFlags.BumpTextureEnabled&&(this._activeEffect.setTexture(\"normalSampler\",this.bumpTexture),this._activeEffect.setFloat2(\"vNormalInfos\",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix(\"normalMatrix\",this.bumpTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat(\"pointSize\",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4(\"vSpecularColor\",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix(\"view\",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),r.MaterialHelper.BindLogDepth(o,this._activeEffect,n),r.MaterialFlags.ReflectionTextureEnabled&&(this._activeEffect.setTexture(\"refractionSampler\",this._refractionRTT),this._activeEffect.setTexture(\"reflectionSampler\",this._reflectionRTT));var s=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(n.getProjectionMatrix()),f=n.getEngine().getDeltaTime();f!==this._lastDeltaTime&&(this._lastDeltaTime=f,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix(\"worldReflectionViewProjection\",s),this._activeEffect.setVector2(\"windDirection\",this.windDirection),this._activeEffect.setFloat(\"waveLength\",this.waveLength),this._activeEffect.setFloat(\"time\",this._lastTime/1e5),this._activeEffect.setFloat(\"windForce\",this.windForce),this._activeEffect.setFloat(\"waveHeight\",this.waveHeight),this._activeEffect.setFloat(\"bumpHeight\",this.bumpHeight),this._activeEffect.setColor4(\"waterColor\",this.waterColor,1),this._activeEffect.setFloat(\"colorBlendFactor\",this.colorBlendFactor),this._activeEffect.setColor4(\"waterColor2\",this.waterColor2,1),this._activeEffect.setFloat(\"colorBlendFactor2\",this.colorBlendFactor2),this._activeEffect.setFloat(\"waveSpeed\",this.waveSpeed),this._activeEffect.setFloat(\"waveCount\",this.waveCount),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect),this._afterBind(t,this._activeEffect)}}},t.prototype._createRenderTargets=function(e,t){var i,n=this;this._refractionRTT=new r.RenderTargetTexture(name+\"_refraction\",{width:t.x,height:t.y},e,!1,!0),this._refractionRTT.wrapU=r.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=r.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.ignoreCameraViewport=!0,this._reflectionRTT=new r.RenderTargetTexture(name+\"_reflection\",{width:t.x,height:t.y},e,!1,!0),this._reflectionRTT.wrapU=r.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=r.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.ignoreCameraViewport=!0;var o,a=null,s=r.Matrix.Zero();this._refractionRTT.onBeforeRender=function(){if(n._mesh&&(i=n._mesh.isVisible,n._mesh.isVisible=!1),!n.disableClipPlane){a=e.clipPlane;var t=n._mesh?n._mesh.position.y:0;e.clipPlane=r.Plane.FromPositionAndNormal(new r.Vector3(0,t+.05,0),new r.Vector3(0,1,0))}},this._refractionRTT.onAfterRender=function(){n._mesh&&(n._mesh.isVisible=i),n.disableClipPlane||(e.clipPlane=a)},this._reflectionRTT.onBeforeRender=function(){if(n._mesh&&(i=n._mesh.isVisible,n._mesh.isVisible=!1),!n.disableClipPlane){a=e.clipPlane;var t=n._mesh?n._mesh.position.y:0;e.clipPlane=r.Plane.FromPositionAndNormal(new r.Vector3(0,t-.05,0),new r.Vector3(0,-1,0)),r.Matrix.ReflectionToRef(e.clipPlane,s)}o=e.getViewMatrix(),s.multiplyToRef(o,n._reflectionTransform),e.setTransformMatrix(n._reflectionTransform,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!1,e._mirroredCameraPosition=r.Vector3.TransformCoordinates(e.activeCamera.position,s)},this._reflectionRTT.onAfterRender=function(){n._mesh&&(n._mesh.isVisible=i),e.clipPlane=a,e.setTransformMatrix(o,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!0,e._mirroredCameraPosition=null}},t.prototype.getAnimatables=function(){var e=[];return this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this._reflectionRTT&&this._reflectionRTT.animations&&this._reflectionRTT.animations.length>0&&e.push(this._reflectionRTT),this._refractionRTT&&this._refractionRTT.animations&&this._refractionRTT.animations.length>0&&e.push(this._refractionRTT),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._bumpTexture&&t.push(this._bumpTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this._bumpTexture===t},t.prototype.dispose=function(t){this.bumpTexture&&this.bumpTexture.dispose();var i=this.getScene().customRenderTargets.indexOf(this._refractionRTT);-1!=i&&this.getScene().customRenderTargets.splice(i,1),i=-1,-1!=(i=this.getScene().customRenderTargets.indexOf(this._reflectionRTT))&&this.getScene().customRenderTargets.splice(i,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);if(e.customType=\"BABYLON.WaterMaterial\",e.renderList=[],this._refractionRTT&&this._refractionRTT.renderList)for(var t=0;t0&&s.push.apply(s,this._customAttributes),this.ReviewUniform(\"uniform\",i),this.ReviewUniform(\"sampler\",o),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,t.ShaderIndexer++;var l=\"custom_\"+t.ShaderIndexer,u=this._afterBind.bind(this);return this._afterBind=function(e,t){if(t){f.AttachAfterBind(e,t);try{u(e,t)}catch(t){}}},r.Effect.ShadersStore[l+\"VertexShader\"]=this.VertexShader.replace(\"#define CUSTOM_VERTEX_BEGIN\",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:\"\").replace(\"#define CUSTOM_VERTEX_DEFINITIONS\",(this._customUniform?this._customUniform.join(\"\\n\"):\"\")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:\"\")).replace(\"#define CUSTOM_VERTEX_MAIN_BEGIN\",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:\"\").replace(\"#define CUSTOM_VERTEX_UPDATE_POSITION\",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:\"\").replace(\"#define CUSTOM_VERTEX_UPDATE_NORMAL\",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:\"\").replace(\"#define CUSTOM_VERTEX_MAIN_END\",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:\"\"),this.CustomParts.Vertex_After_WorldPosComputed&&(r.Effect.ShadersStore[l+\"VertexShader\"]=r.Effect.ShadersStore[l+\"VertexShader\"].replace(\"#define CUSTOM_VERTEX_UPDATE_WORLDPOS\",this.CustomParts.Vertex_After_WorldPosComputed)),r.Effect.ShadersStore[l+\"PixelShader\"]=this.FragmentShader.replace(\"#define CUSTOM_FRAGMENT_BEGIN\",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:\"\").replace(\"#define CUSTOM_FRAGMENT_MAIN_BEGIN\",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:\"\").replace(\"#define CUSTOM_FRAGMENT_DEFINITIONS\",(this._customUniform?this._customUniform.join(\"\\n\"):\"\")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:\"\")).replace(\"#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\",this.CustomParts.Fragment_Custom_Diffuse?this.CustomParts.Fragment_Custom_Diffuse:\"\").replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALPHA\",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:\"\").replace(\"#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:\"\").replace(\"#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:\"\"),this.CustomParts.Fragment_Before_Fog&&(r.Effect.ShadersStore[l+\"PixelShader\"]=r.Effect.ShadersStore[l+\"PixelShader\"].replace(\"#define CUSTOM_FRAGMENT_BEFORE_FOG\",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=l,l},t.prototype.AddUniform=function(e,t,i){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),i&&(-1!=t.indexOf(\"sampler\")?this._newSamplerInstances[t+\"-\"+e]=i:this._newUniformInstances[t+\"-\"+e]=i),this._customUniform.push(\"uniform \"+t+\" \"+e+\";\"),this._newUniforms.push(e),this},t.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},t.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},t.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},t.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},t.prototype.Fragment_Custom_Diffuse=function(e){return this.CustomParts.Fragment_Custom_Diffuse=e.replace(\"result\",\"diffuseColor\"),this},t.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace(\"result\",\"alpha\"),this},t.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},t.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},t.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace(\"result\",\"color\"),this},t.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},t.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},t.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},t.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace(\"result\",\"positionUpdated\"),this},t.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace(\"result\",\"normalUpdated\"),this},t.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},t.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},t.ShaderIndexer=1,t}(r.StandardMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.CustomMaterial\"]=s;var f=function(){},l=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.CustomParts=new f,n.customShaderNameResolve=n.Builder,n.FragmentShader=r.Effect.ShadersStore.pbrPixelShader,n.VertexShader=r.Effect.ShadersStore.pbrVertexShader,n.FragmentShader=n.FragmentShader.replace(/#include/g,r.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),n.FragmentShader=n.FragmentShader.replace(/#include/g,r.Effect.IncludesShadersStore.pbrBlockReflectivity),n.FragmentShader=n.FragmentShader.replace(/#include/g,r.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),n}return Object(n.b)(t,e),t.prototype.AttachAfterBind=function(e,t){if(this._newUniformInstances)for(var i in this._newUniformInstances){\"vec2\"==(n=i.toString().split(\"-\"))[0]?t.setVector2(n[1],this._newUniformInstances[i]):\"vec3\"==n[0]?t.setVector3(n[1],this._newUniformInstances[i]):\"vec4\"==n[0]?t.setVector4(n[1],this._newUniformInstances[i]):\"mat4\"==n[0]?t.setMatrix(n[1],this._newUniformInstances[i]):\"float\"==n[0]&&t.setFloat(n[1],this._newUniformInstances[i])}if(this._newSamplerInstances)for(var i in this._newSamplerInstances){var n;\"sampler2D\"==(n=i.toString().split(\"-\"))[0]&&this._newSamplerInstances[i].isReady&&this._newSamplerInstances[i].isReady()&&t.setTexture(n[1],this._newSamplerInstances[i])}},t.prototype.ReviewUniform=function(e,t){if(\"uniform\"==e&&this._newUniforms)for(var i=0;i0&&s.push.apply(s,this._customAttributes),this.ReviewUniform(\"uniform\",i),this.ReviewUniform(\"sampler\",o),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,t.ShaderIndexer++;var l=\"custom_\"+t.ShaderIndexer,u=this._afterBind.bind(this);return this._afterBind=function(e,t){if(t){f.AttachAfterBind(e,t);try{u(e,t)}catch(t){}}},r.Effect.ShadersStore[l+\"VertexShader\"]=this.VertexShader.replace(\"#define CUSTOM_VERTEX_BEGIN\",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:\"\").replace(\"#define CUSTOM_VERTEX_DEFINITIONS\",(this._customUniform?this._customUniform.join(\"\\n\"):\"\")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:\"\")).replace(\"#define CUSTOM_VERTEX_MAIN_BEGIN\",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:\"\").replace(\"#define CUSTOM_VERTEX_UPDATE_POSITION\",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:\"\").replace(\"#define CUSTOM_VERTEX_UPDATE_NORMAL\",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:\"\").replace(\"#define CUSTOM_VERTEX_MAIN_END\",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:\"\"),this.CustomParts.Vertex_After_WorldPosComputed&&(r.Effect.ShadersStore[l+\"VertexShader\"]=r.Effect.ShadersStore[l+\"VertexShader\"].replace(\"#define CUSTOM_VERTEX_UPDATE_WORLDPOS\",this.CustomParts.Vertex_After_WorldPosComputed)),r.Effect.ShadersStore[l+\"PixelShader\"]=this.FragmentShader.replace(\"#define CUSTOM_FRAGMENT_BEGIN\",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:\"\").replace(\"#define CUSTOM_FRAGMENT_MAIN_BEGIN\",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:\"\").replace(\"#define CUSTOM_FRAGMENT_DEFINITIONS\",(this._customUniform?this._customUniform.join(\"\\n\"):\"\")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:\"\")).replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\",this.CustomParts.Fragment_Custom_Albedo?this.CustomParts.Fragment_Custom_Albedo:\"\").replace(\"#define CUSTOM_FRAGMENT_UPDATE_ALPHA\",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:\"\").replace(\"#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:\"\").replace(\"#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\",this.CustomParts.Fragment_Custom_MetallicRoughness?this.CustomParts.Fragment_Custom_MetallicRoughness:\"\").replace(\"#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\",this.CustomParts.Fragment_Custom_MicroSurface?this.CustomParts.Fragment_Custom_MicroSurface:\"\").replace(\"#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:\"\"),this.CustomParts.Fragment_Before_Fog&&(r.Effect.ShadersStore[l+\"PixelShader\"]=r.Effect.ShadersStore[l+\"PixelShader\"].replace(\"#define CUSTOM_FRAGMENT_BEFORE_FOG\",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=l,l},t.prototype.AddUniform=function(e,t,i){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),i&&(-1!=t.indexOf(\"sampler\")?this._newSamplerInstances[t+\"-\"+e]=i:this._newUniformInstances[t+\"-\"+e]=i),this._customUniform.push(\"uniform \"+t+\" \"+e+\";\"),this._newUniforms.push(e),this},t.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},t.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},t.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},t.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},t.prototype.Fragment_Custom_Albedo=function(e){return this.CustomParts.Fragment_Custom_Albedo=e.replace(\"result\",\"surfaceAlbedo\"),this},t.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace(\"result\",\"alpha\"),this},t.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},t.prototype.Fragment_Custom_MetallicRoughness=function(e){return this.CustomParts.Fragment_Custom_MetallicRoughness=e,this},t.prototype.Fragment_Custom_MicroSurface=function(e){return this.CustomParts.Fragment_Custom_MicroSurface=e,this},t.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},t.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace(\"result\",\"color\"),this},t.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},t.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},t.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},t.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace(\"result\",\"positionUpdated\"),this},t.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace(\"result\",\"normalUpdated\"),this},t.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},t.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},t.ShaderIndexer=1,t}(r.PBRMaterial);r._TypeStore.RegisteredTypes[\"BABYLON.PBRCustomMaterial\"]=l},function(e,t,i){\"use strict\";i.r(t);var n=i(3);i.d(t,\"CellMaterial\",(function(){return n.CellMaterial}));var r=i(17);i.d(t,\"CustomShaderStructure\",(function(){return r.CustomShaderStructure})),i.d(t,\"ShaderSpecialParts\",(function(){return r.ShaderSpecialParts})),i.d(t,\"CustomMaterial\",(function(){return r.CustomMaterial})),i.d(t,\"ShaderAlebdoParts\",(function(){return r.ShaderAlebdoParts})),i.d(t,\"PBRCustomMaterial\",(function(){return r.PBRCustomMaterial}));var o=i(4);i.d(t,\"FireMaterial\",(function(){return o.FireMaterial}));var a=i(5);i.d(t,\"FurMaterial\",(function(){return a.FurMaterial}));var s=i(6);i.d(t,\"GradientMaterial\",(function(){return s.GradientMaterial}));var f=i(7);i.d(t,\"GridMaterial\",(function(){return f.GridMaterial}));var l=i(8);i.d(t,\"LavaMaterial\",(function(){return l.LavaMaterial}));var u=i(9);i.d(t,\"MixMaterial\",(function(){return u.MixMaterial}));var c=i(10);i.d(t,\"NormalMaterial\",(function(){return c.NormalMaterial}));var d=i(11);i.d(t,\"ShadowOnlyMaterial\",(function(){return d.ShadowOnlyMaterial}));var p=i(12);i.d(t,\"SimpleMaterial\",(function(){return p.SimpleMaterial}));var h=i(13);i.d(t,\"SkyMaterial\",(function(){return h.SkyMaterial}));var v=i(14);i.d(t,\"TerrainMaterial\",(function(){return v.TerrainMaterial}));var m=i(15);i.d(t,\"TriPlanarMaterial\",(function(){return m.TriPlanarMaterial}));var g=i(16);i.d(t,\"WaterMaterial\",(function(){return g.WaterMaterial}))},function(e,t,i){\"use strict\";i.r(t),function(e){var n=i(18);i.d(t,\"CellMaterial\",(function(){return n.CellMaterial})),i.d(t,\"CustomShaderStructure\",(function(){return n.CustomShaderStructure})),i.d(t,\"ShaderSpecialParts\",(function(){return n.ShaderSpecialParts})),i.d(t,\"CustomMaterial\",(function(){return n.CustomMaterial})),i.d(t,\"ShaderAlebdoParts\",(function(){return n.ShaderAlebdoParts})),i.d(t,\"PBRCustomMaterial\",(function(){return n.PBRCustomMaterial})),i.d(t,\"FireMaterial\",(function(){return n.FireMaterial})),i.d(t,\"FurMaterial\",(function(){return n.FurMaterial})),i.d(t,\"GradientMaterial\",(function(){return n.GradientMaterial})),i.d(t,\"GridMaterial\",(function(){return n.GridMaterial})),i.d(t,\"LavaMaterial\",(function(){return n.LavaMaterial})),i.d(t,\"MixMaterial\",(function(){return n.MixMaterial})),i.d(t,\"NormalMaterial\",(function(){return n.NormalMaterial})),i.d(t,\"ShadowOnlyMaterial\",(function(){return n.ShadowOnlyMaterial})),i.d(t,\"SimpleMaterial\",(function(){return n.SimpleMaterial})),i.d(t,\"SkyMaterial\",(function(){return n.SkyMaterial})),i.d(t,\"TerrainMaterial\",(function(){return n.TerrainMaterial})),i.d(t,\"TriPlanarMaterial\",(function(){return n.TriPlanarMaterial})),i.d(t,\"WaterMaterial\",(function(){return n.WaterMaterial}));var r=void 0!==e?e:\"undefined\"!=typeof window?window:void 0;if(void 0!==r)for(var o in r.BABYLON=r.BABYLON||{},n)r.BABYLON[o]=n[o]}.call(this,i(2))}])}));","!function(e,t){\"object\"==typeof exports&&\"object\"==typeof module?module.exports=t():\"function\"==typeof define&&define.amd?define(\"babylonjs\",[],t):\"object\"==typeof exports?exports.babylonjs=t():e.BABYLON=t()}(\"undefined\"!=typeof self?self:\"undefined\"!=typeof global?global:this,(function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,\"a\",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p=\"\",i(i.s=169)}([function(e,t,i){\"use strict\";i.d(t,\"d\",(function(){return c})),i.d(t,\"e\",(function(){return l})),i.d(t,\"f\",(function(){return u})),i.d(t,\"b\",(function(){return h})),i.d(t,\"a\",(function(){return d})),i.d(t,\"c\",(function(){return p}));var n=i(14),r=i(28),o=i(44),a=i(11),s=i(74),c=function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.x=e,this.y=t}return e.prototype.toString=function(){return\"{X: \"+this.x+\" Y: \"+this.y+\"}\"},e.prototype.getClassName=function(){return\"Vector2\"},e.prototype.getHashCode=function(){var e=0|this.x;return e=397*e^(0|this.y)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},e.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},e.prototype.addVector3=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y)},e.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},e.prototype.multiply=function(t){return new e(this.x*t.x,this.y*t.y)},e.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},e.prototype.multiplyByFloats=function(t,i){return new e(this.x*t,this.y*i)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y)},e.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.negate=function(){return new e(-this.x,-this.y)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*this.y)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},e.prototype.scale=function(t){var i=new e(0,0);return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,this},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=r.a),e&&n.a.WithinEpsilon(this.x,e.x,t)&&n.a.WithinEpsilon(this.y,e.y,t)},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.normalize=function(){var e=this.length();return 0===e||(this.x/=e,this.y/=e),this},e.prototype.clone=function(){return new e(this.x,this.y)},e.Zero=function(){return new e(0,0)},e.One=function(){return new e(1,1)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},e.CatmullRom=function(t,i,n,r,o){var a=o*o,s=o*a;return new e(.5*(2*i.x+(-t.x+n.x)*o+(2*t.x-5*i.x+4*n.x-r.x)*a+(-t.x+3*i.x-3*n.x+r.x)*s),.5*(2*i.y+(-t.y+n.y)*o+(2*t.y-5*i.y+4*n.y-r.y)*a+(-t.y+3*i.y-3*n.y+r.y)*s))},e.Clamp=function(t,i,n){var r=t.x;r=(r=r>n.x?n.x:r)n.y?n.y:o)i.x?t.x:i.x,t.y>i.y?t.y:i.y)},e.Transform=function(t,i){var n=e.Zero();return e.TransformToRef(t,i,n),n},e.TransformToRef=function(e,t,i){var n=t.m,r=e.x*n[0]+e.y*n[4]+n[12],o=e.x*n[1]+e.y*n[5]+n[13];i.x=r,i.y=o},e.PointInTriangle=function(e,t,i,n){var r=.5*(-i.y*n.x+t.y*(-i.x+n.x)+t.x*(i.y-n.y)+i.x*n.y),o=r<0?-1:1,a=(t.y*n.x-t.x*n.y+(n.y-t.y)*e.x+(t.x-n.x)*e.y)*o,s=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return a>0&&s>0&&a+s<2*r*o},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.DistanceOfPointFromSegment=function(t,i,n){var r=e.DistanceSquared(i,n);if(0===r)return e.Distance(t,i);var o=n.subtract(i),a=Math.max(0,Math.min(1,e.Dot(t.subtract(i),o)/r)),s=i.add(o.multiplyByFloats(a,a));return e.Distance(t,s)},e}(),l=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this._isDirty=!0,this._x=e,this._y=t,this._z=i}return Object.defineProperty(e.prototype,\"x\",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"y\",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"z\",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return\"{X: \"+this._x+\" Y:\"+this._y+\" Z:\"+this._z+\"}\"},e.prototype.getClassName=function(){return\"Vector3\"},e.prototype.getHashCode=function(){var e=0|this._x;return e=397*(e=397*e^(0|this._y))^(0|this._z)},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toQuaternion=function(){return h.RotationYawPitchRoll(this._y,this._x,this._z)},e.prototype.addInPlace=function(e){return this.addInPlaceFromFloats(e._x,e._y,e._z)},e.prototype.addInPlaceFromFloats=function(e,t,i){return this.x+=e,this.y+=t,this.z+=i,this},e.prototype.add=function(t){return new e(this._x+t._x,this._y+t._y,this._z+t._z)},e.prototype.addToRef=function(e,t){return t.copyFromFloats(this._x+e._x,this._y+e._y,this._z+e._z)},e.prototype.subtractInPlace=function(e){return this.x-=e._x,this.y-=e._y,this.z-=e._z,this},e.prototype.subtract=function(t){return new e(this._x-t._x,this._y-t._y,this._z-t._z)},e.prototype.subtractToRef=function(e,t){return this.subtractFromFloatsToRef(e._x,e._y,e._z,t)},e.prototype.subtractFromFloats=function(t,i,n){return new e(this._x-t,this._y-i,this._z-n)},e.prototype.subtractFromFloatsToRef=function(e,t,i,n){return n.copyFromFloats(this._x-e,this._y-t,this._z-i)},e.prototype.negate=function(){return new e(-this._x,-this._y,-this._z)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this._x,-1*this._y,-1*this._z)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},e.prototype.scale=function(t){return new e(this._x*t,this._y*t,this._z*t)},e.prototype.scaleToRef=function(e,t){return t.copyFromFloats(this._x*e,this._y*e,this._z*e)},e.prototype.scaleAndAddToRef=function(e,t){return t.addInPlaceFromFloats(this._x*e,this._y*e,this._z*e)},e.prototype.projectOnPlane=function(t,i){var n=e.Zero();return this.projectOnPlaneToRef(t,i,n),n},e.prototype.projectOnPlaneToRef=function(t,i,n){var r=t.normal,o=t.d,a=f.Vector3[0];this.subtractToRef(i,a),a.normalize();var s=e.Dot(a,r),c=-(e.Dot(i,r)+o)/s,l=a.scaleInPlace(c);i.addToRef(l,n)},e.prototype.equals=function(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=r.a),e&&n.a.WithinEpsilon(this._x,e._x,t)&&n.a.WithinEpsilon(this._y,e._y,t)&&n.a.WithinEpsilon(this._z,e._z,t)},e.prototype.equalsToFloats=function(e,t,i){return this._x===e&&this._y===t&&this._z===i},e.prototype.multiplyInPlace=function(e){return this.x*=e._x,this.y*=e._y,this.z*=e._z,this},e.prototype.multiply=function(e){return this.multiplyByFloats(e._x,e._y,e._z)},e.prototype.multiplyToRef=function(e,t){return t.copyFromFloats(this._x*e._x,this._y*e._y,this._z*e._z)},e.prototype.multiplyByFloats=function(t,i,n){return new e(this._x*t,this._y*i,this._z*n)},e.prototype.divide=function(t){return new e(this._x/t._x,this._y/t._y,this._z/t._z)},e.prototype.divideToRef=function(e,t){return t.copyFromFloats(this._x/e._x,this._y/e._y,this._z/e._z)},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.minimizeInPlace=function(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)},e.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)},e.prototype.minimizeInPlaceFromFloats=function(e,t,i){return ethis._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this},e.prototype.isNonUniformWithinEpsilon=function(e){var t=Math.abs(this._x),i=Math.abs(this._y);if(!n.a.WithinEpsilon(t,i,e))return!0;var r=Math.abs(this._z);return!n.a.WithinEpsilon(t,r,e)||!n.a.WithinEpsilon(i,r,e)},Object.defineProperty(e.prototype,\"isNonUniform\",{get:function(){var e=Math.abs(this._x);return e!==Math.abs(this._y)||e!==Math.abs(this._z)},enumerable:!1,configurable:!0}),e.prototype.floor=function(){return new e(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))},e.prototype.fract=function(){return new e(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))},e.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)},e.prototype.lengthSquared=function(){return this._x*this._x+this._y*this._y+this._z*this._z},e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.reorderInPlace=function(e){var t=this;return\"xyz\"===(e=e.toLowerCase())||(f.Vector3[0].copyFrom(this),[\"x\",\"y\",\"z\"].forEach((function(i,n){t[i]=f.Vector3[0][e[n]]}))),this},e.prototype.rotateByQuaternionToRef=function(t,i){return t.toRotationMatrix(f.Matrix[0]),e.TransformCoordinatesToRef(this,f.Matrix[0],i),i},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,i){return this.subtractToRef(t,f.Vector3[0]),f.Vector3[0].rotateByQuaternionToRef(e,f.Vector3[0]),t.addToRef(f.Vector3[0],i),i},e.prototype.cross=function(t){return e.Cross(this,t)},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){var t=new e(0,0,0);return this.normalizeToRef(t),t},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?e.copyFromFloats(this._x,this._y,this._z):this.scaleToRef(1/t,e)},e.prototype.clone=function(){return new e(this._x,this._y,this._z)},e.prototype.copyFrom=function(e){return this.copyFromFloats(e._x,e._y,e._z)},e.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.setAll=function(e){return this.x=this.y=this.z=e,this},e.GetClipFactor=function(t,i,n,r){var o=e.Dot(t,n)-r;return o/(o-(e.Dot(i,n)-r))},e.GetAngleBetweenVectors=function(t,i,n){var r=t.normalizeToRef(f.Vector3[1]),o=i.normalizeToRef(f.Vector3[2]),a=e.Dot(r,o),s=f.Vector3[3];return e.CrossToRef(r,o,s),e.Dot(s,n)>0?Math.acos(a):-Math.acos(a)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromFloatArray=function(t,i){return e.FromArray(t,i)},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},e.FromFloatArrayToRef=function(t,i,n){return e.FromArrayToRef(t,i,n)},e.FromFloatsToRef=function(e,t,i,n){n.copyFromFloats(e,t,i)},e.Zero=function(){return new e(0,0,0)},e.One=function(){return new e(1,1,1)},e.Up=function(){return new e(0,1,0)},Object.defineProperty(e,\"UpReadOnly\",{get:function(){return e._UpReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"ZeroReadOnly\",{get:function(){return e._ZeroReadOnly},enumerable:!1,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(t){return void 0===t&&(t=!1),new e(0,0,t?-1:1)},e.Backward=function(t){return void 0===t&&(t=!1),new e(0,0,t?1:-1)},e.Right=function(){return new e(1,0,0)},e.Left=function(){return new e(-1,0,0)},e.TransformCoordinates=function(t,i){var n=e.Zero();return e.TransformCoordinatesToRef(t,i,n),n},e.TransformCoordinatesToRef=function(t,i,n){e.TransformCoordinatesFromFloatsToRef(t._x,t._y,t._z,i,n)},e.TransformCoordinatesFromFloatsToRef=function(e,t,i,n,r){var o=n.m,a=e*o[0]+t*o[4]+i*o[8]+o[12],s=e*o[1]+t*o[5]+i*o[9]+o[13],c=e*o[2]+t*o[6]+i*o[10]+o[14],l=1/(e*o[3]+t*o[7]+i*o[11]+o[15]);r.x=a*l,r.y=s*l,r.z=c*l},e.TransformNormal=function(t,i){var n=e.Zero();return e.TransformNormalToRef(t,i,n),n},e.TransformNormalToRef=function(e,t,i){this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i)},e.TransformNormalFromFloatsToRef=function(e,t,i,n,r){var o=n.m;r.x=e*o[0]+t*o[4]+i*o[8],r.y=e*o[1]+t*o[5]+i*o[9],r.z=e*o[2]+t*o[6]+i*o[10]},e.CatmullRom=function(t,i,n,r,o){var a=o*o,s=o*a;return new e(.5*(2*i._x+(-t._x+n._x)*o+(2*t._x-5*i._x+4*n._x-r._x)*a+(-t._x+3*i._x-3*n._x+r._x)*s),.5*(2*i._y+(-t._y+n._y)*o+(2*t._y-5*i._y+4*n._y-r._y)*a+(-t._y+3*i._y-3*n._y+r._y)*s),.5*(2*i._z+(-t._z+n._z)*o+(2*t._z-5*i._z+4*n._z-r._z)*a+(-t._z+3*i._z-3*n._z+r._z)*s))},e.Clamp=function(t,i,n){var r=new e;return e.ClampToRef(t,i,n,r),r},e.ClampToRef=function(e,t,i,n){var r=e._x;r=(r=r>i._x?i._x:r)i._y?i._y:o)i._z?i._z:a)this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.prototype.normalize=function(){var e=this.length();return 0===e?this:this.scaleInPlace(1/e)},e.prototype.toVector3=function(){return new l(this.x,this.y,this.z)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},e.prototype.setAll=function(e){return this.x=this.y=this.z=this.w=e,this},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},e.FromFloatArrayToRef=function(t,i,n){e.FromArrayToRef(t,i,n)},e.FromFloatsToRef=function(e,t,i,n,r){r.x=e,r.y=t,r.z=i,r.w=n},e.Zero=function(){return new e(0,0,0,0)},e.One=function(){return new e(1,1,1,1)},e.Normalize=function(t){var i=e.Zero();return e.NormalizeToRef(t,i),i},e.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},e.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},e.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z,o=e.w-t.w;return i*i+n*n+r*r+o*o},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.TransformNormal=function(t,i){var n=e.Zero();return e.TransformNormalToRef(t,i,n),n},e.TransformNormalToRef=function(e,t,i){var n=t.m,r=e.x*n[0]+e.y*n[4]+e.z*n[8],o=e.x*n[1]+e.y*n[5]+e.z*n[9],a=e.x*n[2]+e.y*n[6]+e.z*n[10];i.x=r,i.y=o,i.z=a,i.w=e.w},e.TransformNormalFromFloatsToRef=function(e,t,i,n,r,o){var a=r.m;o.x=e*a[0]+t*a[4]+i*a[8],o.y=e*a[1]+t*a[5]+i*a[9],o.z=e*a[2]+t*a[6]+i*a[10],o.w=n},e.FromVector3=function(t,i){return void 0===i&&(i=0),new e(t._x,t._y,t._z,i)},e}(),h=function(){function e(e,t,i,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=n}return Object.defineProperty(e.prototype,\"x\",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"y\",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"z\",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"w\",{get:function(){return this._w},set:function(e){this._w=e,this._isDirty=!0},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return\"{X: \"+this._x+\" Y:\"+this._y+\" Z:\"+this._z+\" W:\"+this._w+\"}\"},e.prototype.getClassName=function(){return\"Quaternion\"},e.prototype.getHashCode=function(){var e=0|this._x;return e=397*(e=397*(e=397*e^(0|this._y))^(0|this._z))^(0|this._w)},e.prototype.asArray=function(){return[this._x,this._y,this._z,this._w]},e.prototype.equals=function(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=r.a),e&&n.a.WithinEpsilon(this._x,e._x,t)&&n.a.WithinEpsilon(this._y,e._y,t)&&n.a.WithinEpsilon(this._z,e._z,t)&&n.a.WithinEpsilon(this._w,e._w,t)},e.prototype.clone=function(){return new e(this._x,this._y,this._z,this._w)},e.prototype.copyFrom=function(e){return this.x=e._x,this.y=e._y,this.z=e._z,this.w=e._w,this},e.prototype.copyFromFloats=function(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},e.prototype.add=function(t){return new e(this._x+t._x,this._y+t._y,this._z+t._z,this._w+t._w)},e.prototype.addInPlace=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this},e.prototype.subtract=function(t){return new e(this._x-t._x,this._y-t._y,this._z-t._z,this._w-t._w)},e.prototype.scale=function(t){return new e(this._x*t,this._y*t,this._z*t,this._w*t)},e.prototype.scaleToRef=function(e,t){return t.x=this._x*e,t.y=this._y*e,t.z=this._z*e,t.w=this._w*e,this},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this._x*e,t.y+=this._y*e,t.z+=this._z*e,t.w+=this._w*e,this},e.prototype.multiply=function(t){var i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,n=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,r=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,o=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,n,r,o),this},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),this},e.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.conjugate=function(){return new e(-this._x,-this._y,-this._z,this._w)},e.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.prototype.toEulerAngles=function(e){void 0===e&&(e=\"YZX\");var t=l.Zero();return this.toEulerAnglesToRef(t),t},e.prototype.toEulerAnglesToRef=function(e){var t=this._z,i=this._x,n=this._y,r=this._w,o=r*r,a=t*t,s=i*i,c=n*n,l=n*t-i*r;return l<-.4999999?(e.y=2*Math.atan2(n,r),e.x=Math.PI/2,e.z=0):l>.4999999?(e.y=2*Math.atan2(n,r),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(i*n+t*r),-a-s+c+o),e.x=Math.asin(-2*(t*n-i*r)),e.y=Math.atan2(2*(t*i+n*r),a-s-c+o)),this},e.prototype.toRotationMatrix=function(e){return d.FromQuaternionToRef(this,e),this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,n=e.m,r=n[0],o=n[4],a=n[8],s=n[1],c=n[5],l=n[9],u=n[2],h=n[6],d=n[10],f=r+c+d;f>0?(i=.5/Math.sqrt(f+1),t.w=.25/i,t.x=(h-l)*i,t.y=(a-u)*i,t.z=(s-o)*i):r>c&&r>d?(i=2*Math.sqrt(1+r-c-d),t.w=(h-l)/i,t.x=.25*i,t.y=(o+s)/i,t.z=(a+u)/i):c>d?(i=2*Math.sqrt(1+c-r-d),t.w=(a-u)/i,t.x=(o+s)/i,t.y=.25*i,t.z=(l+h)/i):(i=2*Math.sqrt(1+d-r-c),t.w=(s-o)/i,t.x=(a+u)/i,t.y=(l+h)/i,t.z=.25*i)},e.Dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.AreClose=function(t,i){return e.Dot(t,i)>=0},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(t){return new e(-t._x,-t._y,-t._z,t._w)},e.InverseToRef=function(e,t){return t.set(-e._x,-e._y,-e._z,e._w),t},e.Identity=function(){return new e(0,0,0,1)},e.IsIdentity=function(e){return e&&0===e._x&&0===e._y&&0===e._z&&1===e._w},e.RotationAxis=function(t,i){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var n=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e._x*n,i.y=e._y*n,i.z=e._z*n,i},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},e.FromEulerAngles=function(t,i,n){var r=new e;return e.RotationYawPitchRollToRef(i,t,n,r),r},e.FromEulerAnglesToRef=function(t,i,n,r){return e.RotationYawPitchRollToRef(i,t,n,r),r},e.FromEulerVector=function(t){var i=new e;return e.RotationYawPitchRollToRef(t._y,t._x,t._z,i),i},e.FromEulerVectorToRef=function(t,i){return e.RotationYawPitchRollToRef(t._y,t._x,t._z,i),i},e.RotationYawPitchRoll=function(t,i,n){var r=new e;return e.RotationYawPitchRollToRef(t,i,n,r),r},e.RotationYawPitchRollToRef=function(e,t,i,n){var r=.5*i,o=.5*t,a=.5*e,s=Math.sin(r),c=Math.cos(r),l=Math.sin(o),u=Math.cos(o),h=Math.sin(a),d=Math.cos(a);n.x=d*l*c+h*u*s,n.y=h*u*c-d*l*s,n.z=d*u*s-h*l*c,n.w=d*u*c+h*l*s},e.RotationAlphaBetaGamma=function(t,i,n){var r=new e;return e.RotationAlphaBetaGammaToRef(t,i,n,r),r},e.RotationAlphaBetaGammaToRef=function(e,t,i,n){var r=.5*(i+e),o=.5*(i-e),a=.5*t;n.x=Math.cos(o)*Math.sin(a),n.y=Math.sin(o)*Math.sin(a),n.z=Math.sin(r)*Math.cos(a),n.w=Math.cos(r)*Math.cos(a)},e.RotationQuaternionFromAxis=function(t,i,n){var r=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,i,n,r),r},e.RotationQuaternionFromAxisToRef=function(t,i,n,r){var o=f.Matrix[0];d.FromXYZAxesToRef(t.normalize(),i.normalize(),n.normalize(),o),e.FromRotationMatrixToRef(o,r)},e.Slerp=function(t,i,n){var r=e.Identity();return e.SlerpToRef(t,i,n,r),r},e.SlerpToRef=function(e,t,i,n){var r,o,a=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,s=!1;if(a<0&&(s=!0,a=-a),a>.999999)o=1-i,r=s?-i:i;else{var c=Math.acos(a),l=1/Math.sin(c);o=Math.sin((1-i)*c)*l,r=s?-Math.sin(i*c)*l:Math.sin(i*c)*l}n.x=o*e._x+r*t._x,n.y=o*e._y+r*t._y,n.z=o*e._z+r*t._z,n.w=o*e._w+r*t._w},e.Hermite=function(t,i,n,r,o){var a=o*o,s=o*a,c=2*s-3*a+1,l=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t._x*c+n._x*l+i._x*u+r._x*h,t._y*c+n._y*l+i._y*u+r._y*h,t._z*c+n._z*l+i._z*u+r._z*h,t._w*c+n._w*l+i._w*u+r._w*h)},e}(),d=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,s.a.MatrixTrackPrecisionChange&&s.a.MatrixTrackedMatrices.push(this),this._m=new s.a.MatrixCurrentType(16),this._updateIdentityStatus(!1)}return Object.defineProperty(e,\"Use64Bits\",{get:function(){return s.a.MatrixUse64Bits},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"m\",{get:function(){return this._m},enumerable:!1,configurable:!0}),e.prototype._markAsUpdated=function(){this.updateFlag=e._updateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},e.prototype._updateIdentityStatus=function(t,i,n,r){void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===r&&(r=!0),this.updateFlag=e._updateFlagSeed++,this._isIdentity=t,this._isIdentity3x2=t||n,this._isIdentityDirty=!this._isIdentity&&i,this._isIdentity3x2Dirty=!this._isIdentity3x2&&r},e.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity},e.prototype.isIdentityAs3x2=function(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]||0!==this._m[1]||0!==this._m[2]||0!==this._m[3]||0!==this._m[4]||0!==this._m[6]||0!==this._m[7]||0!==this._m[8]||0!==this._m[9]||0!==this._m[10]||0!==this._m[11]||0!==this._m[12]||0!==this._m[13]||0!==this._m[14]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2},e.prototype.determinant=function(){if(!0===this._isIdentity)return 1;var e=this._m,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],s=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],p=e[13],_=e[14],m=e[15],g=h*m-_*d,v=u*m-p*d,b=u*_-p*h,y=l*m-f*d,T=l*_-h*f,E=l*p-f*u;return t*+(a*g-s*v+c*b)+i*-(o*g-s*y+c*T)+n*+(o*v-a*y+c*E)+r*-(o*b-a*T+s*E)},e.prototype.toArray=function(){return this._m},e.prototype.asArray=function(){return this._m},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){return e.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this},e.prototype.add=function(t){var i=new e;return this.addToRef(t,i),i},e.prototype.addToRef=function(e,t){for(var i=this._m,n=t._m,r=e.m,o=0;o<16;o++)n[o]=i[o]+r[o];return t._markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=this._m,i=e.m,n=0;n<16;n++)t[n]+=i[n];return this._markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),this;var i=this._m,n=i[0],r=i[1],o=i[2],a=i[3],s=i[4],c=i[5],l=i[6],u=i[7],h=i[8],d=i[9],f=i[10],p=i[11],_=i[12],m=i[13],g=i[14],v=i[15],b=f*v-g*p,y=d*v-m*p,T=d*g-m*f,E=h*v-_*p,S=h*g-f*_,A=h*m-_*d,P=+(c*b-l*y+u*T),C=-(s*b-l*E+u*S),R=+(s*y-c*E+u*A),x=-(s*T-c*S+l*A),O=n*P+r*C+o*R+a*x;if(0===O)return t.copyFrom(this),this;var M=1/O,I=l*v-g*u,D=c*v-m*u,N=c*g-m*l,L=s*v-_*u,w=s*g-_*l,F=s*m-_*c,B=l*p-f*u,U=c*p-d*u,V=c*f-d*l,k=s*p-h*u,z=s*f-h*l,G=s*d-h*c,j=-(r*b-o*y+a*T),W=+(n*b-o*E+a*S),H=-(n*y-r*E+a*A),X=+(n*T-r*S+o*A),Y=+(r*I-o*D+a*N),K=-(n*I-o*L+a*w),Q=+(n*D-r*L+a*F),q=-(n*N-r*w+o*F),Z=-(r*B-o*U+a*V),J=+(n*B-o*k+a*z),$=-(n*U-r*k+a*G),ee=+(n*V-r*z+o*G);return e.FromValuesToRef(P*M,j*M,Y*M,Z*M,C*M,W*M,K*M,J*M,R*M,H*M,Q*M,$*M,x*M,X*M,q*M,ee*M,t),this},e.prototype.addAtIndex=function(e,t){return this._m[e]+=t,this._markAsUpdated(),this},e.prototype.multiplyAtIndex=function(e,t){return this._m[e]*=t,this._markAsUpdated(),this},e.prototype.setTranslationFromFloats=function(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this._markAsUpdated(),this},e.prototype.addTranslationFromFloats=function(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this._markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.setTranslationFromFloats(e._x,e._y,e._z)},e.prototype.getTranslation=function(){return new l(this._m[12],this._m[13],this._m[14])},e.prototype.getTranslationToRef=function(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],this},e.prototype.removeRotationAndScaling=function(){var t=this.m;return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t[12],t[13],t[14],t[15],this),this._updateIdentityStatus(0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]),this},e.prototype.multiply=function(t){var i=new e;return this.multiplyToRef(t,i),i},e.prototype.copyFrom=function(e){e.copyToArray(this._m);var t=e;return this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);var i=this._m;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],this},e.prototype.multiplyToRef=function(e,t){return this._isIdentity?(t.copyFrom(e),this):e._isIdentity?(t.copyFrom(this),this):(this.multiplyToArray(e,t._m,0),t._markAsUpdated(),this)},e.prototype.multiplyToArray=function(e,t,i){var n=this._m,r=e.m,o=n[0],a=n[1],s=n[2],c=n[3],l=n[4],u=n[5],h=n[6],d=n[7],f=n[8],p=n[9],_=n[10],m=n[11],g=n[12],v=n[13],b=n[14],y=n[15],T=r[0],E=r[1],S=r[2],A=r[3],P=r[4],C=r[5],R=r[6],x=r[7],O=r[8],M=r[9],I=r[10],D=r[11],N=r[12],L=r[13],w=r[14],F=r[15];return t[i]=o*T+a*P+s*O+c*N,t[i+1]=o*E+a*C+s*M+c*L,t[i+2]=o*S+a*R+s*I+c*w,t[i+3]=o*A+a*x+s*D+c*F,t[i+4]=l*T+u*P+h*O+d*N,t[i+5]=l*E+u*C+h*M+d*L,t[i+6]=l*S+u*R+h*I+d*w,t[i+7]=l*A+u*x+h*D+d*F,t[i+8]=f*T+p*P+_*O+m*N,t[i+9]=f*E+p*C+_*M+m*L,t[i+10]=f*S+p*R+_*I+m*w,t[i+11]=f*A+p*x+_*D+m*F,t[i+12]=g*T+v*P+b*O+y*N,t[i+13]=g*E+v*C+b*M+y*L,t[i+14]=g*S+v*R+b*I+y*w,t[i+15]=g*A+v*x+b*D+y*F,this},e.prototype.equals=function(e){var t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;var i=this.m,n=t.m;return i[0]===n[0]&&i[1]===n[1]&&i[2]===n[2]&&i[3]===n[3]&&i[4]===n[4]&&i[5]===n[5]&&i[6]===n[6]&&i[7]===n[7]&&i[8]===n[8]&&i[9]===n[9]&&i[10]===n[10]&&i[11]===n[11]&&i[12]===n[12]&&i[13]===n[13]&&i[14]===n[14]&&i[15]===n[15]},e.prototype.clone=function(){var t=new e;return t.copyFrom(this),t},e.prototype.getClassName=function(){return\"Matrix\"},e.prototype.getHashCode=function(){for(var e=0|this._m[0],t=1;t<16;t++)e=397*e^(0|this._m[t]);return e},e.prototype.decompose=function(t,i,n){if(this._isIdentity)return n&&n.setAll(0),t&&t.setAll(1),i&&i.copyFromFloats(0,0,0,1),!0;var r=this._m;if(n&&n.copyFromFloats(r[12],r[13],r[14]),(t=t||f.Vector3[0]).x=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),t.y=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),t.z=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]),this.determinant()<=0&&(t.y*=-1),0===t._x||0===t._y||0===t._z)return i&&i.copyFromFloats(0,0,0,1),!1;if(i){var o=1/t._x,a=1/t._y,s=1/t._z;e.FromValuesToRef(r[0]*o,r[1]*o,r[2]*o,0,r[4]*a,r[5]*a,r[6]*a,0,r[8]*s,r[9]*s,r[10]*s,0,0,0,0,1,f.Matrix[0]),h.FromRotationMatrixToRef(f.Matrix[0],i)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new u(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])},e.prototype.setRow=function(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)},e.prototype.transpose=function(){return e.Transpose(this)},e.prototype.transposeToRef=function(t){return e.TransposeToRef(this,t),this},e.prototype.setRowFromFloats=function(e,t,i,n,r){if(e<0||e>3)return this;var o=4*e;return this._m[o+0]=t,this._m[o+1]=i,this._m[o+2]=n,this._m[o+3]=r,this._markAsUpdated(),this},e.prototype.scale=function(t){var i=new e;return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]=this._m[i]*e;return t._markAsUpdated(),this},e.prototype.scaleAndAddToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]+=this._m[i]*e;return t._markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){var i=f.Matrix[0];this.invertToRef(i),i.transposeToRef(t);var n=t._m;e.FromValuesToRef(n[0],n[1],n[2],0,n[4],n[5],n[6],0,n[8],n[9],n[10],0,0,0,0,1,t)},e.prototype.getRotationMatrix=function(){var t=new e;return this.getRotationMatrixToRef(t),t},e.prototype.getRotationMatrixToRef=function(t){var i=f.Vector3[0];if(!this.decompose(i))return e.IdentityToRef(t),this;var n=this._m,r=1/i._x,o=1/i._y,a=1/i._z;return e.FromValuesToRef(n[0]*r,n[1]*r,n[2]*r,0,n[4]*o,n[5]*o,n[6]*o,0,n[8]*a,n[9]*a,n[10]*a,0,0,0,0,1,t),this},e.prototype.toggleModelMatrixHandInPlace=function(){var e=this._m;e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this._markAsUpdated()},e.prototype.toggleProjectionMatrixHandInPlace=function(){var e=this._m;e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this._markAsUpdated()},e.FromArray=function(t,i){void 0===i&&(i=0);var n=new e;return e.FromArrayToRef(t,i,n),n},e.FromArrayToRef=function(e,t,i){for(var n=0;n<16;n++)i._m[n]=e[n+t];i._markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,i,n){for(var r=0;r<16;r++)n._m[r]=e[r+t]*i;n._markAsUpdated()},Object.defineProperty(e,\"IdentityReadOnly\",{get:function(){return e._identityReadOnly},enumerable:!1,configurable:!0}),e.FromValuesToRef=function(e,t,i,n,r,o,a,s,c,l,u,h,d,f,p,_,m){var g=m._m;g[0]=e,g[1]=t,g[2]=i,g[3]=n,g[4]=r,g[5]=o,g[6]=a,g[7]=s,g[8]=c,g[9]=l,g[10]=u,g[11]=h,g[12]=d,g[13]=f,g[14]=p,g[15]=_,m._markAsUpdated()},e.FromValues=function(t,i,n,r,o,a,s,c,l,u,h,d,f,p,_,m){var g=new e,v=g._m;return v[0]=t,v[1]=i,v[2]=n,v[3]=r,v[4]=o,v[5]=a,v[6]=s,v[7]=c,v[8]=l,v[9]=u,v[10]=h,v[11]=d,v[12]=f,v[13]=p,v[14]=_,v[15]=m,g._markAsUpdated(),g},e.Compose=function(t,i,n){var r=new e;return e.ComposeToRef(t,i,n,r),r},e.ComposeToRef=function(e,t,i,n){var r=n._m,o=t._x,a=t._y,s=t._z,c=t._w,l=o+o,u=a+a,h=s+s,d=o*l,f=o*u,p=o*h,_=a*u,m=a*h,g=s*h,v=c*l,b=c*u,y=c*h,T=e._x,E=e._y,S=e._z;r[0]=(1-(_+g))*T,r[1]=(f+y)*T,r[2]=(p-b)*T,r[3]=0,r[4]=(f-y)*E,r[5]=(1-(d+g))*E,r[6]=(m+v)*E,r[7]=0,r[8]=(p+b)*S,r[9]=(m-v)*S,r[10]=(1-(d+_))*S,r[11]=0,r[12]=i._x,r[13]=i._y,r[14]=i._z,r[15]=1,n._markAsUpdated()},e.Identity=function(){var t=e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return t._updateIdentityStatus(!0),t},e.IdentityToRef=function(t){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(!0)},e.Zero=function(){var t=e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return t._updateIdentityStatus(!1),t},e.RotationX=function(t){var i=new e;return e.RotationXToRef(t,i),i},e.Invert=function(t){var i=new e;return t.invertToRef(i),i},e.RotationXToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(1,0,0,0,0,r,n,0,0,-n,r,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.RotationYToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(r,0,-n,0,0,1,0,0,n,0,r,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.RotationZToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(r,n,0,0,-n,r,0,0,0,0,1,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationAxis=function(t,i){var n=new e;return e.RotationAxisToRef(t,i,n),n},e.RotationAxisToRef=function(e,t,i){var n=Math.sin(-t),r=Math.cos(-t),o=1-r;e.normalize();var a=i._m;a[0]=e._x*e._x*o+r,a[1]=e._x*e._y*o-e._z*n,a[2]=e._x*e._z*o+e._y*n,a[3]=0,a[4]=e._y*e._x*o+e._z*n,a[5]=e._y*e._y*o+r,a[6]=e._y*e._z*o-e._x*n,a[7]=0,a[8]=e._z*e._x*o-e._y*n,a[9]=e._z*e._y*o+e._x*n,a[10]=e._z*e._z*o+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,i._markAsUpdated()},e.RotationAlignToRef=function(e,t,i){var n=l.Cross(t,e),r=l.Dot(t,e),o=1/(1+r),a=i._m;a[0]=n._x*n._x*o+r,a[1]=n._y*n._x*o-n._z,a[2]=n._z*n._x*o+n._y,a[3]=0,a[4]=n._x*n._y*o+n._z,a[5]=n._y*n._y*o+r,a[6]=n._z*n._y*o-n._x,a[7]=0,a[8]=n._x*n._z*o-n._y,a[9]=n._y*n._z*o+n._x,a[10]=n._z*n._z*o+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,i._markAsUpdated()},e.RotationYawPitchRoll=function(t,i,n){var r=new e;return e.RotationYawPitchRollToRef(t,i,n,r),r},e.RotationYawPitchRollToRef=function(e,t,i,n){h.RotationYawPitchRollToRef(e,t,i,f.Quaternion[0]),f.Quaternion[0].toRotationMatrix(n)},e.Scaling=function(t,i,n){var r=new e;return e.ScalingToRef(t,i,n,r),r},e.ScalingToRef=function(t,i,n,r){e.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,n,0,0,0,0,1,r),r._updateIdentityStatus(1===t&&1===i&&1===n)},e.Translation=function(t,i,n){var r=new e;return e.TranslationToRef(t,i,n,r),r},e.TranslationToRef=function(t,i,n,r){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,n,1,r),r._updateIdentityStatus(0===t&&0===i&&0===n)},e.Lerp=function(t,i,n){var r=new e;return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){for(var r=n._m,o=e.m,a=t.m,s=0;s<16;s++)r[s]=o[s]*(1-i)+a[s]*i;n._markAsUpdated()},e.DecomposeLerp=function(t,i,n){var r=new e;return e.DecomposeLerpToRef(t,i,n,r),r},e.DecomposeLerpToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Quaternion[0],s=f.Vector3[1];t.decompose(o,a,s);var c=f.Vector3[2],u=f.Quaternion[1],d=f.Vector3[3];i.decompose(c,u,d);var p=f.Vector3[4];l.LerpToRef(o,c,n,p);var _=f.Quaternion[2];h.SlerpToRef(a,u,n,_);var m=f.Vector3[5];l.LerpToRef(s,d,n,m),e.ComposeToRef(p,_,m,r)},e.LookAtLH=function(t,i,n){var r=new e;return e.LookAtLHToRef(t,i,n,r),r},e.LookAtLHToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Vector3[1],s=f.Vector3[2];i.subtractToRef(t,s),s.normalize(),l.CrossToRef(n,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),l.CrossToRef(s,o,a),a.normalize();var u=-l.Dot(o,t),h=-l.Dot(a,t),d=-l.Dot(s,t);e.FromValuesToRef(o._x,a._x,s._x,0,o._y,a._y,s._y,0,o._z,a._z,s._z,0,u,h,d,1,r)},e.LookAtRH=function(t,i,n){var r=new e;return e.LookAtRHToRef(t,i,n,r),r},e.LookAtRHToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Vector3[1],s=f.Vector3[2];t.subtractToRef(i,s),s.normalize(),l.CrossToRef(n,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),l.CrossToRef(s,o,a),a.normalize();var u=-l.Dot(o,t),h=-l.Dot(a,t),d=-l.Dot(s,t);e.FromValuesToRef(o._x,a._x,s._x,0,o._y,a._y,s._y,0,o._z,a._z,s._z,0,u,h,d,1,r)},e.OrthoLH=function(t,i,n,r){var o=new e;return e.OrthoLHToRef(t,i,n,r,o),o},e.OrthoLHToRef=function(t,i,n,r,o){var a=2/t,s=2/i,c=2/(r-n),l=-(r+n)/(r-n);e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,c,0,0,0,l,1,o),o._updateIdentityStatus(1===a&&1===s&&1===c&&0===l)},e.OrthoOffCenterLH=function(t,i,n,r,o,a){var s=new e;return e.OrthoOffCenterLHToRef(t,i,n,r,o,a,s),s},e.OrthoOffCenterLHToRef=function(t,i,n,r,o,a,s){var c=2/(i-t),l=2/(r-n),u=2/(a-o),h=-(a+o)/(a-o),d=(t+i)/(t-i),f=(r+n)/(n-r);e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,0,d,f,h,1,s),s._markAsUpdated()},e.OrthoOffCenterRH=function(t,i,n,r,o,a){var s=new e;return e.OrthoOffCenterRHToRef(t,i,n,r,o,a,s),s},e.OrthoOffCenterRHToRef=function(t,i,n,r,o,a,s){e.OrthoOffCenterLHToRef(t,i,n,r,o,a,s),s._m[10]*=-1},e.PerspectiveLH=function(t,i,n,r){var o=new e,a=2*n/t,s=2*n/i,c=(r+n)/(r-n),l=-2*r*n/(r-n);return e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,c,1,0,0,l,0,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovLH=function(t,i,n,r){var o=new e;return e.PerspectiveFovLHToRef(t,i,n,r,o),o},e.PerspectiveFovLHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=n,c=r,l=1/Math.tan(.5*t),u=a?l/i:l,h=a?l:l*i,d=(c+s)/(c-s),f=-2*c*s/(c-s);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseLHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),c=a?s/i:s,l=a?s:s*i;e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,-n,1,0,0,1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,i,n,r){var o=new e;return e.PerspectiveFovRHToRef(t,i,n,r,o),o},e.PerspectiveFovRHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=n,c=r,l=1/Math.tan(.5*t),u=a?l/i:l,h=a?l:l*i,d=-(c+s)/(c-s),f=-2*c*s/(c-s);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,-1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseRHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),c=a?s/i:s,l=a?s:s*i;e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,-n,-1,0,0,-1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,i,n,r){void 0===r&&(r=!1);var o=r?-1:1,a=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),c=Math.tan(e.leftDegrees*Math.PI/180),l=Math.tan(e.rightDegrees*Math.PI/180),u=2/(c+l),h=2/(a+s),d=n._m;d[0]=u,d[1]=d[2]=d[3]=d[4]=0,d[5]=h,d[6]=d[7]=0,d[8]=(c-l)*u*.5,d[9]=-(a-s)*h*.5,d[10]=-i/(t-i),d[11]=1*o,d[12]=d[13]=d[15]=0,d[14]=-2*i*t/(i-t),n._markAsUpdated()},e.GetFinalMatrix=function(t,i,n,r,o,a){var s=t.width,c=t.height,l=t.x,u=t.y,h=e.FromValues(s/2,0,0,0,0,-c/2,0,0,0,0,a-o,0,l+s/2,c/2+u,o,1),d=f.Matrix[0];return i.multiplyToRef(n,d),d.multiplyToRef(r,d),d.multiply(h)},e.GetAsMatrix2x2=function(e){var t=e.m,i=[t[0],t[1],t[4],t[5]];return s.a.MatrixUse64Bits?i:new Float32Array(i)},e.GetAsMatrix3x3=function(e){var t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return s.a.MatrixUse64Bits?i:new Float32Array(i)},e.Transpose=function(t){var i=new e;return e.TransposeToRef(t,i),i},e.TransposeToRef=function(e,t){var i=t._m,n=e.m;i[0]=n[0],i[1]=n[4],i[2]=n[8],i[3]=n[12],i[4]=n[1],i[5]=n[5],i[6]=n[9],i[7]=n[13],i[8]=n[2],i[9]=n[6],i[10]=n[10],i[11]=n[14],i[12]=n[3],i[13]=n[7],i[14]=n[11],i[15]=n[15],t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty)},e.Reflection=function(t){var i=new e;return e.ReflectionToRef(t,i),i},e.ReflectionToRef=function(t,i){t.normalize();var n=t.normal.x,r=t.normal.y,o=t.normal.z,a=-2*n,s=-2*r,c=-2*o;e.FromValuesToRef(a*n+1,s*n,c*n,0,a*r,s*r+1,c*r,0,a*o,s*o,c*o+1,0,a*t.d,s*t.d,c*t.d,1,i)},e.FromXYZAxesToRef=function(t,i,n,r){e.FromValuesToRef(t._x,t._y,t._z,0,i._x,i._y,i._z,0,n._x,n._y,n._z,0,0,0,0,1,r)},e.FromQuaternionToRef=function(e,t){var i=e._x*e._x,n=e._y*e._y,r=e._z*e._z,o=e._x*e._y,a=e._z*e._w,s=e._z*e._x,c=e._y*e._w,l=e._y*e._z,u=e._x*e._w;t._m[0]=1-2*(n+r),t._m[1]=2*(o+a),t._m[2]=2*(s-c),t._m[3]=0,t._m[4]=2*(o-a),t._m[5]=1-2*(r+i),t._m[6]=2*(l+u),t._m[7]=0,t._m[8]=2*(s+c),t._m[9]=2*(l-u),t._m[10]=1-2*(n+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t._markAsUpdated()},e._updateFlagSeed=0,e._identityReadOnly=e.Identity(),e}(),f=function(){function e(){}return e.Vector3=o.a.BuildArray(6,l.Zero),e.Matrix=o.a.BuildArray(2,d.Identity),e.Quaternion=o.a.BuildArray(3,h.Zero),e}(),p=function(){function e(){}return e.Vector2=o.a.BuildArray(3,c.Zero),e.Vector3=o.a.BuildArray(13,l.Zero),e.Vector4=o.a.BuildArray(3,u.Zero),e.Quaternion=o.a.BuildArray(2,h.Zero),e.Matrix=o.a.BuildArray(8,d.Identity),e}();a.a.RegisteredTypes[\"BABYLON.Vector2\"]=c,a.a.RegisteredTypes[\"BABYLON.Vector3\"]=l,a.a.RegisteredTypes[\"BABYLON.Vector4\"]=u,a.a.RegisteredTypes[\"BABYLON.Matrix\"]=d},function(e,t,i){\"use strict\";i.d(t,\"d\",(function(){return r})),i.d(t,\"a\",(function(){return o})),i.d(t,\"c\",(function(){return a})),i.d(t,\"b\",(function(){return s})),i.d(t,\"e\",(function(){return c})),i.d(t,\"f\",(function(){return l}));\n/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nvar n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)};function r(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var o=function(){return(o=Object.assign||function(e){for(var t,i=1,n=arguments.length;i=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}function s(e,t,i,n){return new(i||(i=Promise))((function(r,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},\"function\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError(\"Generator is already executing.\");for(;a;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=2?\"WEBGL2\":\"WEBGL1\"};this._loadShader(m,\"Vertex\",\"\",(function(e){_._rawVertexSourceCode=e,_._loadShader(g,\"Fragment\",\"Pixel\",(function(i){_._rawFragmentSourceCode=i,s.a.Process(e,E,(function(e){v&&(e=v(\"vertex\",e)),E.isFragment=!0,s.a.Process(i,E,(function(i){v&&(i=v(\"fragment\",i)),_._useFinalCode(e,i,t)}),_._engine)}),_._engine)}))}))}return Object.defineProperty(e.prototype,\"onBindObservable\",{get:function(){return this._onBindObservable||(this._onBindObservable=new n.c),this._onBindObservable},enumerable:!1,configurable:!0}),e.prototype._useFinalCode=function(e,t,i){if(i){var n=i.vertexElement||i.vertex||i.spectorName||i,r=i.fragmentElement||i.fragment||i.spectorName||i;this._vertexSourceCode=\"#define SHADER_NAME vertex:\"+n+\"\\n\"+e,this._fragmentSourceCode=\"#define SHADER_NAME fragment:\"+r+\"\\n\"+t}else this._vertexSourceCode=e,this._fragmentSourceCode=t;this._prepareEffect()},Object.defineProperty(e.prototype,\"key\",{get:function(){return this._key},enumerable:!1,configurable:!0}),e.prototype.isReady=function(){try{return this._isReadyInternal()}catch(e){return!1}},e.prototype._isReadyInternal=function(){return!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady},e.prototype.getEngine=function(){return this._engine},e.prototype.getPipelineContext=function(){return this._pipelineContext},e.prototype.getAttributesNames=function(){return this._attributesNames},e.prototype.getAttributeLocation=function(e){return this._attributes[e]},e.prototype.getAttributeLocationByName=function(e){return this._attributeLocationByName[e]},e.prototype.getAttributesCount=function(){return this._attributes.length},e.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},e.prototype.getUniform=function(e){return this._uniforms[e]},e.prototype.getSamplers=function(){return this._samplerList},e.prototype.getUniformNames=function(){return this._uniformsNames},e.prototype.getUniformBuffersNames=function(){return this._uniformBuffersNamesList},e.prototype.getIndexParameters=function(){return this._indexParameters},e.prototype.getCompilationError=function(){return this._compilationError},e.prototype.allFallbacksProcessed=function(){return this._allFallbacksProcessed},e.prototype.executeWhenCompiled=function(e){var t=this;this.isReady()?e(this):(this.onCompileObservable.add((function(t){e(t)})),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout((function(){t._checkIsReady(null)}),16))},e.prototype._checkIsReady=function(e){var t=this;try{if(this._isReadyInternal())return}catch(t){return void this._processCompilationErrors(t,e)}setTimeout((function(){t._checkIsReady(e)}),16)},e.prototype._loadShader=function(t,i,n,r){var a;if(\"undefined\"!=typeof HTMLElement&&t instanceof HTMLElement)return void r(o.a.GetDOMTextContent(t));\"source:\"!==t.substr(0,7)?\"base64:\"!==t.substr(0,7)?e.ShadersStore[t+i+\"Shader\"]?r(e.ShadersStore[t+i+\"Shader\"]):n&&e.ShadersStore[t+n+\"Shader\"]?r(e.ShadersStore[t+n+\"Shader\"]):(a=\".\"===t[0]||\"/\"===t[0]||t.indexOf(\"http\")>-1?t:e.ShadersRepository+t,this._engine._loadFile(a+\".\"+i.toLowerCase()+\".fx\",r)):r(window.atob(t.substr(7))):r(t.substr(7))},Object.defineProperty(e.prototype,\"vertexSourceCode\",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._vertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"fragmentSourceCode\",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._fragmentSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"rawVertexSourceCode\",{get:function(){return this._rawVertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"rawFragmentSourceCode\",{get:function(){return this._rawFragmentSourceCode},enumerable:!1,configurable:!0}),e.prototype._rebuildProgram=function(e,t,i,n){var o=this;this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=function(e,t){n&&n(t)},this.onCompiled=function(){var e=o.getEngine().scenes;if(e)for(var t=0;t=a&&(r=\"Offending line [\"+a+\"] in \"+(i?\"fragment\":\"vertex\")+\" code: \"+s[a-1])}}return[e,r]},e.prototype._processCompilationErrors=function(t,i){var n,r,o,s,c;void 0===i&&(i=null),this._compilationError=t.message;var l=this._attributesNames,u=this._fallbacks;if(a.a.Error(\"Unable to compile effect:\"),a.a.Error(\"Uniforms: \"+this._uniformsNames.map((function(e){return\" \"+e}))),a.a.Error(\"Attributes: \"+l.map((function(e){return\" \"+e}))),a.a.Error(\"Defines:\\r\\n\"+this.defines),e.LogShaderCodeOnCompilationError){var h=null,d=null,f=null;(null===(o=this._pipelineContext)||void 0===o?void 0:o._getVertexShaderCode())&&(f=(n=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],h=n[1],f&&(a.a.Error(\"Vertex code:\"),a.a.Error(f))),(null===(s=this._pipelineContext)||void 0===s?void 0:s._getFragmentShaderCode())&&(f=(r=this._getShaderCodeAndErrorLine(null===(c=this._pipelineContext)||void 0===c?void 0:c._getFragmentShaderCode(),this._compilationError,!0))[0],d=r[1],f&&(a.a.Error(\"Fragment code:\"),a.a.Error(f))),h&&a.a.Error(h),d&&a.a.Error(d)}a.a.Error(\"Error: \"+this._compilationError),i&&(this._pipelineContext=i,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),u?(this._pipelineContext=null,u.hasMoreFallbacks?(this._allFallbacksProcessed=!1,a.a.Error(\"Trying next fallback.\"),this.defines=u.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):this._allFallbacksProcessed=!0},Object.defineProperty(e.prototype,\"isSupported\",{get:function(){return\"\"===this._compilationError},enumerable:!1,configurable:!0}),e.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers[e],t)},e.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t)},e.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers[e],this._uniforms[e],t)},e.prototype.setTextureArray=function(e,t){var i=e+\"Ex\";if(-1===this._samplerList.indexOf(i+\"0\")){for(var n=this._samplerList.indexOf(e),r=1;r0},e.prototype.clear=function(){this._observers=new Array,this._onObserverAdded=null},e.prototype.clone=function(){var t=new e;return t._observers=this._observers.slice(0),t},e.prototype.hasSpecificMask=function(e){void 0===e&&(e=-1);for(var t=0,i=this._observers;t0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"hasThinInstances\",{get:function(){var e;return(null!==(e=this._thinInstanceDataStorage.instancesCount)&&void 0!==e?e:0)>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"morphTargetManager\",{get:function(){return this._internalMeshDataInfo._morphTargetManager},set:function(e){this._internalMeshDataInfo._morphTargetManager!==e&&(this._internalMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"source\",{get:function(){return this._internalMeshDataInfo._source},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cloneMeshMap\",{get:function(){return this._internalMeshDataInfo.meshMap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"isUnIndexed\",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"worldMatrixInstancedBuffer\",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"manualUpdateOfWorldMatrixInstancedBuffer\",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(e){this._instanceDataStorage.manualUpdate=e},enumerable:!1,configurable:!0}),t.prototype.instantiateHierarchy=function(e,t,i){void 0===e&&(e=null);var n=!(this.getTotalVertices()>0)||t&&t.doNotInstantiate?this.clone(\"Clone of \"+(this.name||this.id),e||this.parent,!0):this.createInstance(\"instance of \"+(this.name||this.id));n&&(n.parent=e||this.parent,n.position=this.position.clone(),n.scaling=this.scaling.clone(),this.rotationQuaternion?n.rotationQuaternion=this.rotationQuaternion.clone():n.rotation=this.rotation.clone(),i&&i(this,n));for(var r=0,o=this.getChildTransformNodes(!0);r0},enumerable:!1,configurable:!0}),t.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},t.prototype._sortLODLevels=function(){this._internalMeshDataInfo._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},t.prototype.addLODLevel=function(e,t){if(t&&t._masterMesh)return E.a.Warn(\"You cannot use a mesh as LOD level twice\"),this;var i=new C.a(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this},t.prototype.getLODLevelAtDistance=function(e){for(var t=this._internalMeshDataInfo,i=0;ir)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this;for(var o=0;o0||this.hasThinInstances);this.computeWorldMatrix();var d=this.material||u.defaultMaterial;if(d)if(d._storeEffectOnSubMeshes)for(var f=0,p=this.subMeshes;f0){var i=this.getIndices();if(!i)return null;var n=i.length,r=!1;if(e)r=!0;else for(var o=0,a=this.subMeshes;on){r=!0;break}if(s.verticesStart+s.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new _.a(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),i=t/e|0,n=0;i%3!=0;)i++;this.releaseSubMeshes();for(var r=0;r=t);r++)_.a.CreateFromIndices(0,n,r===e-1?t-n:i,this),n+=i;this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,i,n){if(void 0===i&&(i=!1),this._geometry)this._geometry.setVerticesData(e,t,i,n);else{var r=new d.a;r.set(t,e);var o=this.getScene();new f.a(f.a.RandomId(),o,r,i,this)}return this},t.prototype.removeVerticesData=function(e){this._geometry&&this._geometry.removeVerticesData(e)},t.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},t.prototype.setVerticesBuffer=function(e){return this._geometry||(this._geometry=f.a.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),this},t.prototype.updateVerticesData=function(e,t,i,n){return this._geometry?(n?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this},t.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var i=this.getVerticesData(h.b.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(h.b.PositionKind,i,!1,!1),t){var n=this.getIndices(),r=this.getVerticesData(h.b.NormalKind);if(!r)return this;d.a.ComputeNormals(i,n,r),this.updateVerticesData(h.b.NormalKind,r,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;var e=this._geometry,t=this._geometry.copy(f.a.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},t.prototype.setIndices=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),this._geometry)this._geometry.setIndices(e,t,i);else{var n=new d.a;n.indices=e;var r=this.getScene();new f.a(f.a.RandomId(),r,n,i,this)}return this},t.prototype.updateIndices=function(e,t,i){return void 0===i&&(i=!1),this._geometry?(this._geometry.updateIndices(e,t,i),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,t,i){if(!this._geometry)return this;var n,r=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(i){case g.a.PointFillMode:n=null;break;case g.a.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case g.a.TriangleFillMode:n=this._geometry.getIndexBuffer()}return this._geometry._bind(t,n),this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();return this._unIndexed||t==g.a.PointFillMode?n.drawArraysType(t,e.verticesStart,e.verticesCount,i):t==g.a.WireFrameFillMode?n.drawElementsType(t,0,e._linesIndexCount,i):n.drawElementsType(t,e.indexStart,e.indexCount,i),this},t.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},t.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},t.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},t.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},t.prototype._getInstancesRenderList=function(e,t){if(void 0===t&&(t=!1),this._instanceDataStorage.isFrozen&&this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch;var i=this.getScene(),n=i._isInIntermediateRendering(),r=n?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=this._instanceDataStorage.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!r&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){var a=this._instanceDataStorage.visibleInstances,s=i.getRenderId(),c=n?a.intermediateDefaultRenderId:a.defaultRenderId;o.visibleInstances[e]=a[s],!o.visibleInstances[e]&&c&&(o.visibleInstances[e]=a[c])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==o.visibleInstances[e]&&void 0!==o.visibleInstances[e],this._instanceDataStorage.previousBatch=o,o},t.prototype._renderWithInstances=function(e,t,i,n,r){var o=i.visibleInstances[e._id];if(!o)return this;for(var a=this._instanceDataStorage,s=a.instancesBufferSize,c=a.instancesBuffer,l=16*(o.length+1)*4;a.instancesBufferSizeu&&n++,0!==_&&f++,d+=_,u=_}if(c[f]++,f>o&&(o=f),0===d)r++;else{var m=1/d,g=0;for(p=0;p.001&&a++}}var v=this.skeleton.bones.length,b=this.getVerticesData(h.b.MatricesIndicesKind),y=this.getVerticesData(h.b.MatricesIndicesExtraKind),T=0;for(l=0;l=v||E<0)&&T++}return{skinned:!0,valid:0===r&&0===a&&0===T,report:\"Number of Weights = \"+i/4+\"\\nMaximum influences = \"+o+\"\\nMissing Weights = \"+r+\"\\nNot Sorted = \"+n+\"\\nNot Normalized = \"+a+\"\\nWeightCounts = [\"+c+\"]\\nNumber of bones = \"+v+\"\\nBad Bone Indices = \"+T}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===y.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=y.a.DELAYLOADSTATE_LOADING,this._queueLoad(e)),this},t.prototype._queueLoad=function(e){var t=this;e._addPendingData(this);var i=-1!==this.delayLoadingFile.indexOf(\".babylonbinarymeshdata\");return o.b.LoadFile(this.delayLoadingFile,(function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),e._syncSubMeshes()})),t.delayLoadState=y.a.DELAYLOADSTATE_LOADED,e._removePendingData(t)}),(function(){}),e.offlineProvider,i),this},t.prototype.isInFrustum=function(t){return this.delayLoadState!==y.a.DELAYLOADSTATE_LOADING&&(!!e.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},t.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;var n=this.getScene().multiMaterials;for(t=n.length-1;t>-1;t--)if(n[t].id===e)return this.material=n[t],this;return this},t.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},t.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(h.b.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,n=this.getVerticesData(h.b.PositionKind),r=new Array;for(i=0;i1)for(var n=0,r=i.meshes.slice(0);n-1&&(r.morphTargetManager=i.getMorphTargetManagerById(e.morphTargetManagerId)),void 0!==e.skeletonId&&null!==e.skeletonId&&(r.skeleton=i.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o4,d=u?this.getVerticesData(h.b.MatricesIndicesExtraKind):null,f=u?this.getVerticesData(h.b.MatricesWeightsExtraKind):null,p=e.getTransformMatrices(this),_=c.e.Zero(),m=new c.a,g=new c.a,v=0,b=0;b0&&(c.a.FromFloat32ArrayToRefScaled(p,Math.floor(16*a[v+l]),y,g),m.addToSelf(g));if(u)for(l=0;l<4;l++)(y=f[v+l])>0&&(c.a.FromFloat32ArrayToRefScaled(p,Math.floor(16*d[v+l]),y,g),m.addToSelf(g));c.e.TransformCoordinatesFromFloatsToRef(i._sourcePositions[b],i._sourcePositions[b+1],i._sourcePositions[b+2],m,_),_.toArray(r,b),t&&(c.e.TransformNormalFromFloatsToRef(i._sourceNormals[b],i._sourceNormals[b+1],i._sourceNormals[b+2],m,_),_.toArray(o,b)),m.reset()}return this.updateVerticesData(h.b.PositionKind,r),t&&this.updateVerticesData(h.b.NormalKind,o),this},t.MinMax=function(e){var t=null,i=null;return e.forEach((function(e){var n=e.getBoundingInfo().boundingBox;t&&i?(t.minimizeInPlace(n.minimumWorld),i.maximizeInPlace(n.maximumWorld)):(t=n.minimumWorld,i=n.maximumWorld)})),t&&i?{min:t,max:i}:{min:c.e.Zero(),max:c.e.Zero()}},t.Center=function(e){var i=e instanceof Array?t.MinMax(e):e;return c.e.Center(i.min,i.max)},t.MergeMeshes=function(e,i,n,r,o,a){var s;if(void 0===i&&(i=!0),!n){var c=0;for(s=0;s=65536)return E.a.Warn(\"Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices\"),null}if(a){var l,u,h=null;o=!1}var f,p=new Array,m=new Array,g=null,b=new Array,y=null;for(s=0;s\"+i+\"
\";e._AddLogEntry(n)},e._WarnDisabled=function(e){},e._WarnEnabled=function(t){var i=e._FormatMessage(t);console.warn(\"BJS - \"+i);var n=\"
\"+i+\"

\";e._AddLogEntry(n)},e._ErrorDisabled=function(e){},e._ErrorEnabled=function(t){e.errorsCount++;var i=e._FormatMessage(t);console.error(\"BJS - \"+i);var n=\"
\"+i+\"

\";e._AddLogEntry(n)},Object.defineProperty(e,\"LogCache\",{get:function(){return e._LogCache},enumerable:!1,configurable:!0}),e.ClearLogCache=function(){e._LogCache=\"\",e.errorsCount=0},Object.defineProperty(e,\"LogLevels\",{set:function(t){(t&e.MessageLogLevel)===e.MessageLogLevel?e.Log=e._LogEnabled:e.Log=e._LogDisabled,(t&e.WarningLogLevel)===e.WarningLogLevel?e.Warn=e._WarnEnabled:e.Warn=e._WarnDisabled,(t&e.ErrorLogLevel)===e.ErrorLogLevel?e.Error=e._ErrorEnabled:e.Error=e._ErrorDisabled},enumerable:!1,configurable:!0}),e.NoneLogLevel=0,e.MessageLogLevel=1,e.WarningLogLevel=2,e.ErrorLogLevel=4,e.AllLogLevel=7,e._LogCache=\"\",e.errorsCount=0,e.Log=e._LogEnabled,e.Warn=e._WarnEnabled,e.Error=e._ErrorEnabled,e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return s})),i.d(t,\"b\",(function(){return c})),i.d(t,\"c\",(function(){return l}));var n=i(14),r=i(28),o=i(44),a=i(11),s=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return e.prototype.toString=function(){return\"{R: \"+this.r+\" G:\"+this.g+\" B:\"+this.b+\"}\"},e.prototype.getClassName=function(){return\"Color3\"},e.prototype.getHashCode=function(){var e=255*this.r|0;return e=397*(e=397*e^(255*this.g|0))^(255*this.b|0)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new c(this.r,this.g,this.b,e)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},e.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=n.a.Clamp(this.r,e,t),i.g=n.a.Clamp(this.g,e,t),i.b=n.a.Clamp(this.b,e,t),this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b)},e.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},e.prototype.clone=function(){return new e(this.r,this.g,this.b)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,i=255*this.b|0;return\"#\"+n.a.ToHex(e)+n.a.ToHex(t)+n.a.ToHex(i)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toHSV=function(){var t=new e;return this.toHSVToRef(t),t},e.prototype.toHSVToRef=function(e){var t=this.r,i=this.g,n=this.b,r=Math.max(t,i,n),o=Math.min(t,i,n),a=0,s=0,c=r,l=r-o;0!==r&&(s=l/r),r!=o&&(r==t?(a=(i-n)/l,i=0&&o<=1?(s=r,c=a):o>=1&&o<=2?(s=a,c=r):o>=2&&o<=3?(c=r,l=a):o>=3&&o<=4?(c=a,l=r):o>=4&&o<=5?(s=a,l=r):o>=5&&o<=6&&(s=r,l=a);var u=i-r;n.set(s+u,c+u,l+u)},e.FromHexString=function(t){if(\"#\"!==t.substring(0,1)||7!==t.length)return new e(0,0,0);var i=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16);return e.FromInts(i,n,r)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2]},e.FromInts=function(t,i,n){return new e(t/255,i/255,n/255)},e.Lerp=function(t,i,n){var r=new e(0,0,0);return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){n.r=e.r+(t.r-e.r)*i,n.g=e.g+(t.g-e.g)*i,n.b=e.b+(t.b-e.b)*i},e.Red=function(){return new e(1,0,0)},e.Green=function(){return new e(0,1,0)},e.Blue=function(){return new e(0,0,1)},e.Black=function(){return new e(0,0,0)},Object.defineProperty(e,\"BlackReadOnly\",{get:function(){return e._BlackReadOnly},enumerable:!1,configurable:!0}),e.White=function(){return new e(1,1,1)},e.Purple=function(){return new e(.5,0,.5)},e.Magenta=function(){return new e(1,0,1)},e.Yellow=function(){return new e(1,1,0)},e.Gray=function(){return new e(.5,.5,.5)},e.Teal=function(){return new e(0,1,1)},e.Random=function(){return new e(Math.random(),Math.random(),Math.random())},e._BlackReadOnly=e.Black(),e}(),c=function(){function e(e,t,i,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),this.r=e,this.g=t,this.b=i,this.a=n}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,this},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=n.a.Clamp(this.r,e,t),i.g=n.a.Clamp(this.g,e,t),i.b=n.a.Clamp(this.b,e,t),i.a=n.a.Clamp(this.a,e,t),this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return\"{R: \"+this.r+\" G:\"+this.g+\" B:\"+this.b+\" A:\"+this.a+\"}\"},e.prototype.getClassName=function(){return\"Color4\"},e.prototype.getHashCode=function(){var e=255*this.r|0;return e=397*(e=397*(e=397*e^(255*this.g|0))^(255*this.b|0))^(255*this.a|0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.copyFromFloats=function(e,t,i,n){return this.r=e,this.g=t,this.b=i,this.a=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},e.prototype.toHexString=function(e){void 0===e&&(e=!1);var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0;if(e)return\"#\"+n.a.ToHex(t)+n.a.ToHex(i)+n.a.ToHex(r);var o=255*this.a|0;return\"#\"+n.a.ToHex(t)+n.a.ToHex(i)+n.a.ToHex(r)+n.a.ToHex(o)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,r.c),e.g=Math.pow(this.g,r.c),e.b=Math.pow(this.b,r.c),e.a=this.a,this},e.prototype.toGammaSpace=function(){var t=new e;return this.toGammaSpaceToRef(t),t},e.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,r.b),e.g=Math.pow(this.g,r.b),e.b=Math.pow(this.b,r.b),e.a=this.a,this},e.FromHexString=function(t){if(\"#\"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var i=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(i,n,r,o)},e.Lerp=function(t,i,n){var r=new e(0,0,0,0);return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){n.r=e.r+(t.r-e.r)*i,n.g=e.g+(t.g-e.g)*i,n.b=e.b+(t.b-e.b)*i,n.a=e.a+(t.a-e.a)*i},e.FromColor3=function(t,i){return void 0===i&&(i=1),new e(t.r,t.g,t.b,i)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2],i.a=e[t+3]},e.FromInts=function(t,i,n,r){return new e(t/255,i/255,n/255,r/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],n=0;n0?e.name:n+e.name,(p.a.StartsWith(e.url,\"data:\")||t.UseSerializedUrlIfAny&&e.url)&&(h=e.url),r=new t(h,i,!o,e.invertY,void 0,a)}return r}),e,i);return s},t.CreateFromBase64String=function(e,i,n,r,o,a,s,l,u){return void 0===a&&(a=t.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===l&&(l=null),void 0===u&&(u=c.a.TEXTUREFORMAT_RGBA),new t(\"data:\"+i,n,r,o,a,s,l,e,!1,u)},t.LoadFromDataString=function(e,i,n,r,o,a,s,l,u,h){return void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=!0),void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=c.a.TEXTUREFORMAT_RGBA),\"data:\"!==e.substr(0,5)&&(e=\"data:\"+e),new t(e,n,o,a,s,l,u,i,r,h)},t.SerializeBuffers=!0,t.ForceSerializeBuffers=!1,t._CubeTextureParser=function(e,t,i){throw u.a.WarnImport(\"CubeTexture\")},t._CreateMirror=function(e,t,i,n){throw u.a.WarnImport(\"MirrorTexture\")},t._CreateRenderTargetTexture=function(e,t,i,n){throw u.a.WarnImport(\"RenderTargetTexture\")},t.NEAREST_SAMPLINGMODE=c.a.TEXTURE_NEAREST_SAMPLINGMODE,t.NEAREST_NEAREST_MIPLINEAR=c.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.BILINEAR_SAMPLINGMODE=c.a.TEXTURE_BILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPNEAREST=c.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TRILINEAR_SAMPLINGMODE=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPLINEAR=c.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.NEAREST_NEAREST_MIPNEAREST=c.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.NEAREST_LINEAR_MIPNEAREST=c.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.NEAREST_LINEAR_MIPLINEAR=c.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.NEAREST_LINEAR=c.a.TEXTURE_NEAREST_LINEAR,t.NEAREST_NEAREST=c.a.TEXTURE_NEAREST_NEAREST,t.LINEAR_NEAREST_MIPNEAREST=c.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.LINEAR_NEAREST_MIPLINEAR=c.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.LINEAR_LINEAR=c.a.TEXTURE_LINEAR_LINEAR,t.LINEAR_NEAREST=c.a.TEXTURE_LINEAR_NEAREST,t.EXPLICIT_MODE=c.a.TEXTURE_EXPLICIT_MODE,t.SPHERICAL_MODE=c.a.TEXTURE_SPHERICAL_MODE,t.PLANAR_MODE=c.a.TEXTURE_PLANAR_MODE,t.CUBIC_MODE=c.a.TEXTURE_CUBIC_MODE,t.PROJECTION_MODE=c.a.TEXTURE_PROJECTION_MODE,t.SKYBOX_MODE=c.a.TEXTURE_SKYBOX_MODE,t.INVCUBIC_MODE=c.a.TEXTURE_INVCUBIC_MODE,t.EQUIRECTANGULAR_MODE=c.a.TEXTURE_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MODE=c.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=c.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.CLAMP_ADDRESSMODE=c.a.TEXTURE_CLAMP_ADDRESSMODE,t.WRAP_ADDRESSMODE=c.a.TEXTURE_WRAP_ADDRESSMODE,t.MIRROR_ADDRESSMODE=c.a.TEXTURE_MIRROR_ADDRESSMODE,t.UseSerializedUrlIfAny=!1,Object(n.c)([Object(r.c)()],t.prototype,\"url\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"uOffset\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"vOffset\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"uScale\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"vScale\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"uAng\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"vAng\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"wAng\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"uRotationCenter\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"vRotationCenter\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"wRotationCenter\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"homogeneousRotationInUVTransform\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"isBlocking\",null),t}(s.a);l.a.RegisteredTypes[\"BABYLON.Texture\"]=m,r.a._TextureParser=m.Parse},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){}return e.GetClass=function(e){return this.RegisteredTypes&&this.RegisteredTypes[e]?this.RegisteredTypes[e]:null},e.RegisteredTypes={},e}()},function(e,t,i){\"use strict\";i.d(t,\"b\",(function(){return m})),i.d(t,\"c\",(function(){return g})),i.d(t,\"a\",(function(){return v}));var n=i(6),r=i(38),o=i(8),a=i(41),s=i(57),c=i(21),l=i(49),u=i(22),h=i(56),d=i(145),f=i(104),p=i(122),_=i(120),m=function(){function e(){}return Object.defineProperty(e,\"BaseUrl\",{get:function(){return h.a.BaseUrl},set:function(e){h.a.BaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"DefaultRetryStrategy\",{get:function(){return h.a.DefaultRetryStrategy},set:function(e){h.a.DefaultRetryStrategy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"CorsBehavior\",{get:function(){return h.a.CorsBehavior},set:function(e){h.a.CorsBehavior=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"UseFallbackTexture\",{get:function(){return u.a.UseFallbackTexture},set:function(e){u.a.UseFallbackTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"RegisteredExternalClasses\",{get:function(){return p.a.RegisteredExternalClasses},set:function(e){p.a.RegisteredExternalClasses=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"fallbackTexture\",{get:function(){return u.a.FallbackTexture},set:function(e){u.a.FallbackTexture=e},enumerable:!1,configurable:!0}),e.FetchToRef=function(e,t,i,n,r,o){var a=4*((Math.abs(e)*i%i|0)+(Math.abs(t)*n%n|0)*i);o.r=r[a]/255,o.g=r[a+1]/255,o.b=r[a+2]/255,o.a=r[a+3]/255},e.Mix=function(e,t,i){return e*(1-i)+t*i},e.Instantiate=function(e){return p.a.Instantiate(e)},e.Slice=function(e,t,i){return e.slice?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SliceToArray=function(e,t,i){return Array.isArray(e)?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SetImmediate=function(e){f.a.SetImmediate(e)},e.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t=t)break;if(n(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),r)},e}();u.a.FallbackTexture=\"data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z\",d.a.Apply()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return p}));var n=i(1),r=i(6),o=i(38),a=i(22),s=i(21),c=i(26),l=i(2),u=i(146),h=i(55),d=i(88),f=i(8),p=(i(123),i(129),i(124),function(e){function t(i,n,a,s){void 0===s&&(s=!1);var c=e.call(this,i,n,a,s)||this;if(c.enableOfflineSupport=!1,c.disableManifestCheck=!1,c.scenes=new Array,c.onNewSceneAddedObservable=new r.c,c.postProcesses=new Array,c.isPointerLock=!1,c.onResizeObservable=new r.c,c.onCanvasBlurObservable=new r.c,c.onCanvasFocusObservable=new r.c,c.onCanvasPointerOutObservable=new r.c,c.onBeginFrameObservable=new r.c,c.customAnimationFrameRequester=null,c.onEndFrameObservable=new r.c,c.onBeforeShaderCompilationObservable=new r.c,c.onAfterShaderCompilationObservable=new r.c,c._deterministicLockstep=!1,c._lockstepMaxSteps=4,c._timeStep=1/60,c._fps=60,c._deltaTime=0,c._drawCalls=new h.a,c.canvasTabIndex=1,c.disablePerformanceMonitorInBackground=!1,c._performanceMonitor=new u.a,t.Instances.push(c),!i)return c;if(a=c._creationOptions,i.getContext){var l=i;if(c._onCanvasFocus=function(){c.onCanvasFocusObservable.notifyObservers(c)},c._onCanvasBlur=function(){c.onCanvasBlurObservable.notifyObservers(c)},l.addEventListener(\"focus\",c._onCanvasFocus),l.addEventListener(\"blur\",c._onCanvasBlur),c._onBlur=function(){c.disablePerformanceMonitorInBackground&&c._performanceMonitor.disable(),c._windowIsBackground=!0},c._onFocus=function(){c.disablePerformanceMonitorInBackground&&c._performanceMonitor.enable(),c._windowIsBackground=!1},c._onCanvasPointerOut=function(e){c.onCanvasPointerOutObservable.notifyObservers(e)},l.addEventListener(\"pointerout\",c._onCanvasPointerOut),o.a.IsWindowObjectExist()){var d=c.getHostWindow();d.addEventListener(\"blur\",c._onBlur),d.addEventListener(\"focus\",c._onFocus);var f=document;c._onFullscreenChange=function(){void 0!==f.fullscreen?c.isFullscreen=f.fullscreen:void 0!==f.mozFullScreen?c.isFullscreen=f.mozFullScreen:void 0!==f.webkitIsFullScreen?c.isFullscreen=f.webkitIsFullScreen:void 0!==f.msIsFullScreen&&(c.isFullscreen=f.msIsFullScreen),c.isFullscreen&&c._pointerLockRequested&&l&&t._RequestPointerlock(l)},document.addEventListener(\"fullscreenchange\",c._onFullscreenChange,!1),document.addEventListener(\"mozfullscreenchange\",c._onFullscreenChange,!1),document.addEventListener(\"webkitfullscreenchange\",c._onFullscreenChange,!1),document.addEventListener(\"msfullscreenchange\",c._onFullscreenChange,!1),c._onPointerLockChange=function(){c.isPointerLock=f.mozPointerLockElement===l||f.webkitPointerLockElement===l||f.msPointerLockElement===l||f.pointerLockElement===l},document.addEventListener(\"pointerlockchange\",c._onPointerLockChange,!1),document.addEventListener(\"mspointerlockchange\",c._onPointerLockChange,!1),document.addEventListener(\"mozpointerlockchange\",c._onPointerLockChange,!1),document.addEventListener(\"webkitpointerlockchange\",c._onPointerLockChange,!1),!t.audioEngine&&a.audioEngine&&t.AudioEngineFactory&&(t.audioEngine=t.AudioEngineFactory(c.getRenderingCanvas()))}c._connectVREvents(),c.enableOfflineSupport=void 0!==t.OfflineProviderFactory,a.doNotHandleTouchAction||c._disableTouchAction(),c._deterministicLockstep=!!a.deterministicLockstep,c._lockstepMaxSteps=a.lockstepMaxSteps||0,c._timeStep=a.timeStep||1/60}return c._prepareVRComponent(),a.autoEnableWebVR&&c.initWebVR(),c}return Object(n.d)(t,e),Object.defineProperty(t,\"NpmPackage\",{get:function(){return c.a.NpmPackage},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"Version\",{get:function(){return c.a.Version},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"Instances\",{get:function(){return a.a.Instances},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"LastCreatedEngine\",{get:function(){return a.a.LastCreatedEngine},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"LastCreatedScene\",{get:function(){return a.a.LastCreatedScene},enumerable:!1,configurable:!0}),t.MarkAllMaterialsAsDirty=function(e,i){for(var n=0;n0?this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this.isVRPresenting()?this._requestVRFrame():this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},t.prototype._renderViews=function(){return!1},t.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},t.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&t._RequestFullscreen(this._renderingCanvas))},t.prototype.exitFullscreen=function(){this.isFullscreen&&t._ExitFullscreen()},t.prototype.enterPointerlock=function(){this._renderingCanvas&&t._RequestPointerlock(this._renderingCanvas)},t.prototype.exitPointerlock=function(){t._ExitPointerlock()},t.prototype.beginFrame=function(){this._measureFps(),this.onBeginFrameObservable.notifyObservers(this),e.prototype.beginFrame.call(this)},t.prototype.endFrame=function(){e.prototype.endFrame.call(this),this._submitVRFrame(),this.onEndFrameObservable.notifyObservers(this)},t.prototype.resize=function(){this.isVRPresenting()||e.prototype.resize.call(this)},t.prototype.setSize=function(t,i){if(!this._renderingCanvas)return!1;if(!e.prototype.setSize.call(this,t,i))return!1;if(this.scenes){for(var n=0;n1&&r){var a=this.createTransformFeedback();this.bindTransformFeedback(a),this.setTranformFeedbackVaryings(o,r),e.transformFeedback=a}return n.linkProgram(o),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),e.context=n,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},t.prototype._releaseTexture=function(t){e.prototype._releaseTexture.call(this,t),this.scenes.forEach((function(e){e.postProcesses.forEach((function(e){e._outputTexture==t&&(e._outputTexture=null)})),e.cameras.forEach((function(e){e._postProcesses.forEach((function(e){e&&e._outputTexture==t&&(e._outputTexture=null)}))}))}))},t.prototype._rescaleTexture=function(e,i,n,r,o){var a=this;this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);var s=this.createRenderTargetTexture({width:i.width,height:i.height},{generateMipMaps:!1,type:l.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:l.a.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});!this._rescalePostProcess&&t._RescalePostProcessFactory&&(this._rescalePostProcess=t._RescalePostProcessFactory(this)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){a._rescalePostProcess.onApply=function(t){t._bindTexture(\"textureSampler\",e)};var t=n;t||(t=a.scenes[a.scenes.length-1]),t.postProcessManager.directRender([a._rescalePostProcess],s,!0),a._bindTextureDirectly(a._gl.TEXTURE_2D,i,!0),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,r,0,0,i.width,i.height,0),a.unBindFramebuffer(s),a._releaseTexture(s),o&&o()}))},t.prototype.getFps=function(){return this._fps},t.prototype.getDeltaTime=function(){return this._deltaTime},t.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},t.prototype._uploadImageToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0);var r=this._gl,o=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),s=this._getRGBABufferInternalSizedFormat(e.type,a),c=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(c,e,!0),this._unpackFlipY(e.invertY);var l=r.TEXTURE_2D;e.isCube&&(l=r.TEXTURE_CUBE_MAP_POSITIVE_X+i),r.texImage2D(l,n,s,a,o,t),this._bindTextureDirectly(c,null,!0)},t.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;var i=this._gl;if(t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(i.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(i.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null),t>1&&i.renderbufferStorageMultisample){var n=i.createFramebuffer();if(!n)throw new Error(\"Unable to create multi sampled framebuffer\");e._MSAAFramebuffer=n,this._bindUnboundFramebuffer(e._MSAAFramebuffer);var r=i.createRenderbuffer();if(!r)throw new Error(\"Unable to create multi sampled framebuffer\");i.bindRenderbuffer(i.RENDERBUFFER,r),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(e.type),e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r),e._MSAARenderBuffer=r}else this._bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t),this._bindUnboundFramebuffer(null),t},t.prototype.updateTextureComparisonFunction=function(e,t){if(1!==this.webGLVersion){var i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,l.a.LEQUAL),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,l.a.LEQUAL),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}else f.a.Error(\"WebGL 1 does not support texture comparison.\")},t.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error(\"Unable to create instance buffer\");var i=new d.a(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i},t.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},t.prototype._clientWaitAsync=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=10);var n=this._gl;return new Promise((function(r,o){var a=function(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?r():setTimeout(a,i):o()};a()}))},t.prototype._readPixelsAsync=function(e,t,i,n,r,o,a){if(this._webGLVersion<2)throw new Error(\"_readPixelsAsync only work on WebGL2+\");var s=this._gl,c=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,c),s.bufferData(s.PIXEL_PACK_BUFFER,a.byteLength,s.STREAM_READ),s.readPixels(e,t,i,n,r,o,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null);var l=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);return l?(s.flush(),this._clientWaitAsync(l,0,10).then((function(){return s.deleteSync(l),s.bindBuffer(s.PIXEL_PACK_BUFFER,c),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,a),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),s.deleteBuffer(c),a}))):null},t.prototype.dispose=function(){for(this.hideLoadingUI(),this.onNewSceneAddedObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();1===t.Instances.length&&t.audioEngine&&t.audioEngine.dispose(),this.disableVR(),o.a.IsWindowObjectExist()&&(window.removeEventListener(\"blur\",this._onBlur),window.removeEventListener(\"focus\",this._onFocus),this._renderingCanvas&&(this._renderingCanvas.removeEventListener(\"focus\",this._onCanvasFocus),this._renderingCanvas.removeEventListener(\"blur\",this._onCanvasBlur),this._renderingCanvas.removeEventListener(\"pointerout\",this._onCanvasPointerOut)),o.a.IsDocumentAvailable()&&(document.removeEventListener(\"fullscreenchange\",this._onFullscreenChange),document.removeEventListener(\"mozfullscreenchange\",this._onFullscreenChange),document.removeEventListener(\"webkitfullscreenchange\",this._onFullscreenChange),document.removeEventListener(\"msfullscreenchange\",this._onFullscreenChange),document.removeEventListener(\"pointerlockchange\",this._onPointerLockChange),document.removeEventListener(\"mspointerlockchange\",this._onPointerLockChange),document.removeEventListener(\"mozpointerlockchange\",this._onPointerLockChange),document.removeEventListener(\"webkitpointerlockchange\",this._onPointerLockChange))),e.prototype.dispose.call(this);var i=t.Instances.indexOf(this);i>=0&&t.Instances.splice(i,1),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()},t.prototype._disableTouchAction=function(){this._renderingCanvas&&this._renderingCanvas.setAttribute&&(this._renderingCanvas.setAttribute(\"touch-action\",\"none\"),this._renderingCanvas.style.touchAction=\"none\",this._renderingCanvas.style.msTouchAction=\"none\")},t.prototype.displayLoadingUI=function(){if(o.a.IsWindowObjectExist()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},t.prototype.hideLoadingUI=function(){if(o.a.IsWindowObjectExist()){var e=this._loadingScreen;e&&e.hideLoadingUI()}},Object.defineProperty(t.prototype,\"loadingScreen\",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=t.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"loadingUIText\",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"loadingUIBackgroundColor\",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!1,configurable:!0}),t._RequestPointerlock=function(e){e.requestPointerLock=e.requestPointerLock||e.msRequestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock,e.requestPointerLock&&e.requestPointerLock()},t._ExitPointerlock=function(){var e=document;document.exitPointerLock=document.exitPointerLock||e.msExitPointerLock||e.mozExitPointerLock||e.webkitExitPointerLock,document.exitPointerLock&&document.exitPointerLock()},t._RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t._ExitFullscreen=function(){var e=document;document.exitFullscreen?document.exitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.webkitCancelFullScreen?e.webkitCancelFullScreen():e.msCancelFullScreen&&e.msCancelFullScreen()},t.ALPHA_DISABLE=l.a.ALPHA_DISABLE,t.ALPHA_ADD=l.a.ALPHA_ADD,t.ALPHA_COMBINE=l.a.ALPHA_COMBINE,t.ALPHA_SUBTRACT=l.a.ALPHA_SUBTRACT,t.ALPHA_MULTIPLY=l.a.ALPHA_MULTIPLY,t.ALPHA_MAXIMIZED=l.a.ALPHA_MAXIMIZED,t.ALPHA_ONEONE=l.a.ALPHA_ONEONE,t.ALPHA_PREMULTIPLIED=l.a.ALPHA_PREMULTIPLIED,t.ALPHA_PREMULTIPLIED_PORTERDUFF=l.a.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHA_INTERPOLATE=l.a.ALPHA_INTERPOLATE,t.ALPHA_SCREENMODE=l.a.ALPHA_SCREENMODE,t.DELAYLOADSTATE_NONE=l.a.DELAYLOADSTATE_NONE,t.DELAYLOADSTATE_LOADED=l.a.DELAYLOADSTATE_LOADED,t.DELAYLOADSTATE_LOADING=l.a.DELAYLOADSTATE_LOADING,t.DELAYLOADSTATE_NOTLOADED=l.a.DELAYLOADSTATE_NOTLOADED,t.NEVER=l.a.NEVER,t.ALWAYS=l.a.ALWAYS,t.LESS=l.a.LESS,t.EQUAL=l.a.EQUAL,t.LEQUAL=l.a.LEQUAL,t.GREATER=l.a.GREATER,t.GEQUAL=l.a.GEQUAL,t.NOTEQUAL=l.a.NOTEQUAL,t.KEEP=l.a.KEEP,t.REPLACE=l.a.REPLACE,t.INCR=l.a.INCR,t.DECR=l.a.DECR,t.INVERT=l.a.INVERT,t.INCR_WRAP=l.a.INCR_WRAP,t.DECR_WRAP=l.a.DECR_WRAP,t.TEXTURE_CLAMP_ADDRESSMODE=l.a.TEXTURE_CLAMP_ADDRESSMODE,t.TEXTURE_WRAP_ADDRESSMODE=l.a.TEXTURE_WRAP_ADDRESSMODE,t.TEXTURE_MIRROR_ADDRESSMODE=l.a.TEXTURE_MIRROR_ADDRESSMODE,t.TEXTUREFORMAT_ALPHA=l.a.TEXTUREFORMAT_ALPHA,t.TEXTUREFORMAT_LUMINANCE=l.a.TEXTUREFORMAT_LUMINANCE,t.TEXTUREFORMAT_LUMINANCE_ALPHA=l.a.TEXTUREFORMAT_LUMINANCE_ALPHA,t.TEXTUREFORMAT_RGB=l.a.TEXTUREFORMAT_RGB,t.TEXTUREFORMAT_RGBA=l.a.TEXTUREFORMAT_RGBA,t.TEXTUREFORMAT_RED=l.a.TEXTUREFORMAT_RED,t.TEXTUREFORMAT_R=l.a.TEXTUREFORMAT_R,t.TEXTUREFORMAT_RG=l.a.TEXTUREFORMAT_RG,t.TEXTUREFORMAT_RED_INTEGER=l.a.TEXTUREFORMAT_RED_INTEGER,t.TEXTUREFORMAT_R_INTEGER=l.a.TEXTUREFORMAT_R_INTEGER,t.TEXTUREFORMAT_RG_INTEGER=l.a.TEXTUREFORMAT_RG_INTEGER,t.TEXTUREFORMAT_RGB_INTEGER=l.a.TEXTUREFORMAT_RGB_INTEGER,t.TEXTUREFORMAT_RGBA_INTEGER=l.a.TEXTUREFORMAT_RGBA_INTEGER,t.TEXTURETYPE_UNSIGNED_BYTE=l.a.TEXTURETYPE_UNSIGNED_BYTE,t.TEXTURETYPE_UNSIGNED_INT=l.a.TEXTURETYPE_UNSIGNED_INT,t.TEXTURETYPE_FLOAT=l.a.TEXTURETYPE_FLOAT,t.TEXTURETYPE_HALF_FLOAT=l.a.TEXTURETYPE_HALF_FLOAT,t.TEXTURETYPE_BYTE=l.a.TEXTURETYPE_BYTE,t.TEXTURETYPE_SHORT=l.a.TEXTURETYPE_SHORT,t.TEXTURETYPE_UNSIGNED_SHORT=l.a.TEXTURETYPE_UNSIGNED_SHORT,t.TEXTURETYPE_INT=l.a.TEXTURETYPE_INT,t.TEXTURETYPE_UNSIGNED_INTEGER=l.a.TEXTURETYPE_UNSIGNED_INTEGER,t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=l.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=l.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=l.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=l.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,t.TEXTURETYPE_UNSIGNED_INT_24_8=l.a.TEXTURETYPE_UNSIGNED_INT_24_8,t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=l.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=l.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=l.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,t.TEXTURE_NEAREST_SAMPLINGMODE=l.a.TEXTURE_NEAREST_SAMPLINGMODE,t.TEXTURE_BILINEAR_SAMPLINGMODE=l.a.TEXTURE_BILINEAR_SAMPLINGMODE,t.TEXTURE_TRILINEAR_SAMPLINGMODE=l.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.TEXTURE_NEAREST_NEAREST_MIPLINEAR=l.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR_MIPNEAREST=l.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TEXTURE_LINEAR_LINEAR_MIPLINEAR=l.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_NEAREST_MIPNEAREST=l.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPNEAREST=l.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPLINEAR=l.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_LINEAR=l.a.TEXTURE_NEAREST_LINEAR,t.TEXTURE_NEAREST_NEAREST=l.a.TEXTURE_NEAREST_NEAREST,t.TEXTURE_LINEAR_NEAREST_MIPNEAREST=l.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.TEXTURE_LINEAR_NEAREST_MIPLINEAR=l.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR=l.a.TEXTURE_LINEAR_LINEAR,t.TEXTURE_LINEAR_NEAREST=l.a.TEXTURE_LINEAR_NEAREST,t.TEXTURE_EXPLICIT_MODE=l.a.TEXTURE_EXPLICIT_MODE,t.TEXTURE_SPHERICAL_MODE=l.a.TEXTURE_SPHERICAL_MODE,t.TEXTURE_PLANAR_MODE=l.a.TEXTURE_PLANAR_MODE,t.TEXTURE_CUBIC_MODE=l.a.TEXTURE_CUBIC_MODE,t.TEXTURE_PROJECTION_MODE=l.a.TEXTURE_PROJECTION_MODE,t.TEXTURE_SKYBOX_MODE=l.a.TEXTURE_SKYBOX_MODE,t.TEXTURE_INVCUBIC_MODE=l.a.TEXTURE_INVCUBIC_MODE,t.TEXTURE_EQUIRECTANGULAR_MODE=l.a.TEXTURE_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=l.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=l.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.SCALEMODE_FLOOR=l.a.SCALEMODE_FLOOR,t.SCALEMODE_NEAREST=l.a.SCALEMODE_NEAREST,t.SCALEMODE_CEILING=l.a.SCALEMODE_CEILING,t._RescalePostProcessFactory=null,t}(c.a))},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){}return e.WithinEpsilon=function(e,t,i){void 0===i&&(i=1401298e-51);var n=e-t;return-i<=n&&n<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?(\"0\"+t).toUpperCase():t.toUpperCase()},e.Sign=function(e){return 0===(e=+e)||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,i){return(e-t)/(i-t)},e.Denormalize=function(e,t,i){return e*(i-t)+t},e.DeltaAngle=function(t,i){var n=e.Repeat(i-t,360);return n>180&&(n-=360),n},e.PingPong=function(t,i){var n=e.Repeat(t,2*i);return i-Math.abs(n-i)},e.SmoothStep=function(t,i,n){var r=e.Clamp(n);return i*(r=-2*r*r*r+3*r*r)+t*(1-r)},e.MoveTowards=function(t,i,n){return Math.abs(i-t)<=n?i:t+e.Sign(i-t)*n},e.MoveTowardsAngle=function(t,i,n){var r=e.DeltaAngle(t,i),o=0;return-n180&&(r-=360),t+r*e.Clamp(n)},e.InverseLerp=function(t,i,n){return t!=i?e.Clamp((n-t)/(i-t)):0},e.Hermite=function(e,t,i,n,r){var o=r*r,a=r*o;return e*(2*a-3*o+1)+i*(-2*a+3*o)+t*(a-2*o+r)+n*(a-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},e.PercentToRange=function(e,t,i){return(i-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.TwoPi=2*Math.PI,e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return h}));var n=i(8),r=i(20),o=i(22),a=i(4),s=i(48),c=i(2),l=i(9),u=i(119),h=function(){function e(){}return e.BindEyePosition=function(e,t,i){if(void 0===i&&(i=\"vEyePosition\"),t._forcedViewPosition)e.setVector3(i,t._forcedViewPosition);else{var n=t.activeCamera.globalPosition;n||(n=t.activeCamera.devicePosition),e.setVector3(i,t._mirroredCameraPosition?t._mirroredCameraPosition:n)}},e.PrepareDefinesForMergedUV=function(e,t,i){t._needUVs=!0,t[i]=!0,e.getTextureMatrix().isIdentityAs3x2()?(t[i+\"DIRECTUV\"]=e.coordinatesIndex+1,0===e.coordinatesIndex?t.MAINUV1=!0:t.MAINUV2=!0):t[i+\"DIRECTUV\"]=0},e.BindTextureMatrix=function(e,t,i){var n=e.getTextureMatrix();t.updateMatrix(i+\"Matrix\",n)},e.GetFogState=function(e,t){return t.fogEnabled&&e.applyFog&&t.fogMode!==r.a.FOGMODE_NONE},e.PrepareDefinesForMisc=function(e,t,i,n,r,o,a){a._areMiscDirty&&(a.LOGARITHMICDEPTH=i,a.POINTSIZE=n,a.FOG=r&&this.GetFogState(e,t),a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=o)},e.PrepareDefinesForFrameBoundValues=function(e,t,i,n,r,o){void 0===r&&(r=null),void 0===o&&(o=!1);var a,s,c,l,u,h,d=!1;a=null==r?void 0!==e.clipPlane&&null!==e.clipPlane:r,s=null==r?void 0!==e.clipPlane2&&null!==e.clipPlane2:r,c=null==r?void 0!==e.clipPlane3&&null!==e.clipPlane3:r,l=null==r?void 0!==e.clipPlane4&&null!==e.clipPlane4:r,u=null==r?void 0!==e.clipPlane5&&null!==e.clipPlane5:r,h=null==r?void 0!==e.clipPlane6&&null!==e.clipPlane6:r,i.CLIPPLANE!==a&&(i.CLIPPLANE=a,d=!0),i.CLIPPLANE2!==s&&(i.CLIPPLANE2=s,d=!0),i.CLIPPLANE3!==c&&(i.CLIPPLANE3=c,d=!0),i.CLIPPLANE4!==l&&(i.CLIPPLANE4=l,d=!0),i.CLIPPLANE5!==u&&(i.CLIPPLANE5=u,d=!0),i.CLIPPLANE6!==h&&(i.CLIPPLANE6=h,d=!0),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,d=!0),i.INSTANCES!==n&&(i.INSTANCES=n,d=!0),i.THIN_INSTANCES!==o&&(i.THIN_INSTANCES=o,d=!0),d&&i.markAsUnprocessed()},e.PrepareDefinesForBones=function(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;var i=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&i)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!i&&void 0;var n=e.getScene().prePassRenderer;if(n&&n.enabled){var r=-1===n.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=r}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0},e.PrepareDefinesForMorphTargets=function(e,t){var i=e.morphTargetManager;i?(t.MORPHTARGETS_UV=i.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=i.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=i.supportsNormals&&t.NORMAL,t.MORPHTARGETS=i.numInfluencers>0,t.NUM_MORPH_INFLUENCERS=i.numInfluencers):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)},e.PrepareDefinesForAttributes=function(e,t,i,n,r,o){if(void 0===r&&(r=!1),void 0===o&&(o=!0),!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;if(t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(a.b.NormalKind),t._needNormals&&e.isVerticesDataPresent(a.b.TangentKind)&&(t.TANGENT=!0),t._needUVs?(t.UV1=e.isVerticesDataPresent(a.b.UVKind),t.UV2=e.isVerticesDataPresent(a.b.UV2Kind)):(t.UV1=!1,t.UV2=!1),i){var s=e.useVertexColors&&e.isVerticesDataPresent(a.b.ColorKind);t.VERTEXCOLOR=s,t.VERTEXALPHA=e.hasVertexAlpha&&s&&o}return n&&this.PrepareDefinesForBones(e,t),r&&this.PrepareDefinesForMorphTargets(e,t),!0},e.PrepareDefinesForMultiview=function(e,t){if(e.activeCamera){var i=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=i&&t.markAsUnprocessed()}},e.PrepareDefinesForPrePass=function(e,t,i){var n=t.PREPASS;if(t._arePrePassDirty){var r=[{type:c.a.PREPASS_POSITION_TEXTURE_TYPE,define:\"PREPASS_POSITION\",index:\"PREPASS_POSITION_INDEX\"},{type:c.a.PREPASS_VELOCITY_TEXTURE_TYPE,define:\"PREPASS_VELOCITY\",index:\"PREPASS_VELOCITY_INDEX\"},{type:c.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:\"PREPASS_REFLECTIVITY\",index:\"PREPASS_REFLECTIVITY_INDEX\"},{type:c.a.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:\"PREPASS_IRRADIANCE\",index:\"PREPASS_IRRADIANCE_INDEX\"},{type:c.a.PREPASS_ALBEDO_TEXTURE_TYPE,define:\"PREPASS_ALBEDO\",index:\"PREPASS_ALBEDO_INDEX\"},{type:c.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,define:\"PREPASS_DEPTHNORMAL\",index:\"PREPASS_DEPTHNORMAL_INDEX\"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&i){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount;for(var o=0;o0&&(a.shadowEnabled=!0,c.prepareDefines(r,n))}}i.lightmapMode!=s.a.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,r[\"LIGHTMAPEXCLUDED\"+n]=!0,r[\"LIGHTMAPNOSPECULAR\"+n]=i.lightmapMode==s.a.LIGHTMAP_SHADOWSONLY):(r[\"LIGHTMAPEXCLUDED\"+n]=!1,r[\"LIGHTMAPNOSPECULAR\"+n]=!1)},e.PrepareDefinesForLights=function(e,t,i,n,r,o){if(void 0===r&&(r=4),void 0===o&&(o=!1),!i._areLightsDirty)return i._needNormals;var a=0,s={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!o)for(var c=0,l=t.lightSources;c0&&(r=n+o,t.addFallback(r,\"LIGHT\"+o)),e.SHADOWS||(e[\"SHADOW\"+o]&&t.addFallback(n,\"SHADOW\"+o),e[\"SHADOWPCF\"+o]&&t.addFallback(n,\"SHADOWPCF\"+o),e[\"SHADOWPCSS\"+o]&&t.addFallback(n,\"SHADOWPCSS\"+o),e[\"SHADOWPOISSON\"+o]&&t.addFallback(n,\"SHADOWPOISSON\"+o),e[\"SHADOWESM\"+o]&&t.addFallback(n,\"SHADOWESM\"+o),e[\"SHADOWCLOSEESM\"+o]&&t.addFallback(n,\"SHADOWCLOSEESM\"+o));return r++},e.PrepareAttributesForMorphTargetsInfluencers=function(e,t,i){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=i,this.PrepareAttributesForMorphTargets(e,t,this._TmpMorphInfluencers)},e.PrepareAttributesForMorphTargets=function(e,t,i){var r=i.NUM_MORPH_INFLUENCERS;if(r>0&&o.a.LastCreatedEngine)for(var s=o.a.LastCreatedEngine.getCaps().maxVertexAttribs,c=t.morphTargetManager,l=c&&c.supportsNormals&&i.NORMAL,u=c&&c.supportsTangents&&i.TANGENT,h=c&&c.supportsUVs&&i.UV1,d=0;ds&&n.a.Error(\"Cannot add more vertex attributes for mesh \"+t.name)},e.PrepareAttributesForBones=function(e,t,i,n){i.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,t),e.push(a.b.MatricesIndicesKind),e.push(a.b.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(e.push(a.b.MatricesIndicesExtraKind),e.push(a.b.MatricesWeightsExtraKind)))},e.PrepareAttributesForInstances=function(e,t){(t.INSTANCES||t.THIN_INSTANCES)&&this.PushAttributesForInstances(e)},e.PushAttributesForInstances=function(e){e.push(\"world0\"),e.push(\"world1\"),e.push(\"world2\"),e.push(\"world3\")},e.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+\"\")},e.BindLight=function(e,t,i,n,r,o){void 0===o&&(o=!1),e._bindLight(t,i,n,r,o)},e.BindLights=function(e,t,i,n,r,o){void 0===r&&(r=4),void 0===o&&(o=!1);for(var a=Math.min(t.lightSources.length,r),s=0;s-1){var o=r.getTransformMatrixTexture(t);i.setTexture(\"boneSampler\",o),i.setFloat(\"boneTextureWidth\",4*(r.bones.length+1))}else{var a=r.getTransformMatrices(t);a&&(i.setMatrices(\"mBones\",a),n&&t.getScene().prePassRenderer&&t.getScene().prePassRenderer.getIndex(c.a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(n.previousBones[t.uniqueId]&&i.setMatrices(\"mPreviousBones\",n.previousBones[t.uniqueId]),e._CopyBonesTransformationMatrices(a,n.previousBones[t.uniqueId])))}}},e._CopyBonesTransformationMatrices=function(e,t){return t.set(e),t},e.BindMorphTargetParameters=function(e,t){var i=e.morphTargetManager;e&&i&&t.setFloatArray(\"morphTargetInfluences\",i.influences)},e.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat(\"logarithmicDepthConstant\",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},e.BindClipPlane=function(e,t){u.a.BindClipPlane(e,t)},e._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},e._tempFogColor=l.a.Black(),e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return c}));var n=i(0),r=i(4),o=i(21),a=i(9),s=i(8),c=function(){function e(){}return e.prototype.set=function(e,t){switch(e.length||s.a.Warn(\"Setting vertex data kind '\"+t+\"' with an empty array\"),t){case r.b.PositionKind:this.positions=e;break;case r.b.NormalKind:this.normals=e;break;case r.b.TangentKind:this.tangents=e;break;case r.b.UVKind:this.uvs=e;break;case r.b.UV2Kind:this.uvs2=e;break;case r.b.UV3Kind:this.uvs3=e;break;case r.b.UV4Kind:this.uvs4=e;break;case r.b.UV5Kind:this.uvs5=e;break;case r.b.UV6Kind:this.uvs6=e;break;case r.b.ColorKind:this.colors=e;break;case r.b.MatricesIndicesKind:this.matricesIndices=e;break;case r.b.MatricesWeightsKind:this.matricesWeights=e;break;case r.b.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case r.b.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}},e.prototype.applyToMesh=function(e,t){return this._applyTo(e,t),this},e.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t),this},e.prototype.updateMesh=function(e){return this._update(e),this},e.prototype.updateGeometry=function(e){return this._update(e),this},e.prototype._applyTo=function(e,t){return void 0===t&&(t=!1),this.positions&&e.setVerticesData(r.b.PositionKind,this.positions,t),this.normals&&e.setVerticesData(r.b.NormalKind,this.normals,t),this.tangents&&e.setVerticesData(r.b.TangentKind,this.tangents,t),this.uvs&&e.setVerticesData(r.b.UVKind,this.uvs,t),this.uvs2&&e.setVerticesData(r.b.UV2Kind,this.uvs2,t),this.uvs3&&e.setVerticesData(r.b.UV3Kind,this.uvs3,t),this.uvs4&&e.setVerticesData(r.b.UV4Kind,this.uvs4,t),this.uvs5&&e.setVerticesData(r.b.UV5Kind,this.uvs5,t),this.uvs6&&e.setVerticesData(r.b.UV6Kind,this.uvs6,t),this.colors&&e.setVerticesData(r.b.ColorKind,this.colors,t),this.matricesIndices&&e.setVerticesData(r.b.MatricesIndicesKind,this.matricesIndices,t),this.matricesWeights&&e.setVerticesData(r.b.MatricesWeightsKind,this.matricesWeights,t),this.matricesIndicesExtra&&e.setVerticesData(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),this.matricesWeightsExtra&&e.setVerticesData(r.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),this.indices?e.setIndices(this.indices,null,t):e.setIndices([],null),this},e.prototype._update=function(e,t,i){return this.positions&&e.updateVerticesData(r.b.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(r.b.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(r.b.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(r.b.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(r.b.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(r.b.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(r.b.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(r.b.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(r.b.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(r.b.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(r.b.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(r.b.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(r.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this},e.prototype.transform=function(e){var t,i=e.determinant()<0,r=n.e.Zero();if(this.positions){var o=n.e.Zero();for(t=0;tr.bbSize.y?r.bbSize.x:r.bbSize.y;$=$>r.bbSize.z?$:r.bbSize.z,N=r.subDiv.X*M/r.bbSize.x,L=r.subDiv.Y*M/r.bbSize.y,w=r.subDiv.Z*M/r.bbSize.z,F=r.subDiv.max*r.subDiv.max,r.facetPartitioning.length=0}for(o=0;oe.LongPressDelay&&!n._isPointerSwiping()&&(n._startingPointerTime=0,o.processTrigger(S.a.ACTION_OnLongPressTrigger,b.a.CreateNew(t.pickedMesh,i)))}),e.LongPressDelay)}}else for(var a=0,s=r._pointerDownStage;ae.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>e.DragMovementThreshold},e.prototype.simulatePointerUp=function(e,t,i){var n=new PointerEvent(\"pointerup\",t),r=new I;i?r.doubleClick=!0:r.singleClick=!0,this._checkPrePointerObservable(e,n,x.a.POINTERUP)||this._processPointerUp(e,n,r)},e.prototype._processPointerUp=function(e,t,i){var n=this._scene;if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(n.onPointerPick&&n.onPointerPick(t,e),i.singleClick&&!i.ignore&&n.onPointerObservable.hasObservers())){var r=x.a.POINTERPICK,o=new x.b(r,t,e);this._setRayOnPointerInfo(o),n.onPointerObservable.notifyObservers(o,r)}var a=e.pickedMesh._getActionManagerForTrigger();if(a&&!i.ignore){a.processTrigger(S.a.ACTION_OnPickUpTrigger,b.a.CreateNew(e.pickedMesh,t)),!i.hasSwiped&&i.singleClick&&a.processTrigger(S.a.ACTION_OnPickTrigger,b.a.CreateNew(e.pickedMesh,t));var s=e.pickedMesh._getActionManagerForTrigger(S.a.ACTION_OnDoublePickTrigger);i.doubleClick&&s&&s.processTrigger(S.a.ACTION_OnDoublePickTrigger,b.a.CreateNew(e.pickedMesh,t))}}else if(!i.ignore)for(var c=0,l=n._pointerUpStage;ce.DoubleClickDelay&&!a._doubleClickOccured||t!==a._previousButtonPressed)&&(a._doubleClickOccured=!1,i.singleClick=!0,i.ignore=!1,n(i,a._currentPickResult))},this._initClickEvent=function(t,i,n,r){var o=new I;a._currentPickResult=null;var s=null,c=t.hasSpecificMask(x.a.POINTERPICK)||i.hasSpecificMask(x.a.POINTERPICK)||t.hasSpecificMask(x.a.POINTERTAP)||i.hasSpecificMask(x.a.POINTERTAP)||t.hasSpecificMask(x.a.POINTERDOUBLETAP)||i.hasSpecificMask(x.a.POINTERDOUBLETAP);!c&&O.a&&(s=a._initActionManager(s,o))&&(c=s.hasPickTriggers);var l=!1;if(c){var u=n.button;if(o.hasSwiped=a._isPointerSwiping(),!o.hasSwiped){var h=!e.ExclusiveDoubleClickMode;h||(h=!t.hasSpecificMask(x.a.POINTERDOUBLETAP)&&!i.hasSpecificMask(x.a.POINTERDOUBLETAP))&&!O.a.HasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)&&(s=a._initActionManager(s,o))&&(h=!s.hasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)),h?(Date.now()-a._previousStartingPointerTime>e.DoubleClickDelay||u!==a._previousButtonPressed)&&(o.singleClick=!0,r(o,a._currentPickResult),l=!0):(a._previousDelayedSimpleClickTimeout=a._delayedSimpleClickTimeout,a._delayedSimpleClickTimeout=window.setTimeout(a._delayedSimpleClick.bind(a,u,o,r),e.DoubleClickDelay));var d=t.hasSpecificMask(x.a.POINTERDOUBLETAP)||i.hasSpecificMask(x.a.POINTERDOUBLETAP);!d&&O.a.HasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)&&(s=a._initActionManager(s,o))&&(d=s.hasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)),d&&(u===a._previousButtonPressed&&Date.now()-a._previousStartingPointerTime0){for(var e=0,t=this._transientComponents;e0)return!1;for(e=0;e0,r=0,o=this._isReadyForMeshStage;r0)for(var a=0,s=this.activeCameras;a0},enumerable:!1,configurable:!0}),t.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},t.prototype.whenReadyAsync=function(){var e=this;return new Promise((function(t){e.executeWhenReady((function(){t()}))}))},t.prototype._checkIsReady=function(){var e=this;return this._registerTransientComponents(),this.isReady()?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1)):void(this._executeWhenReadyTimeoutId=setTimeout((function(){e._checkIsReady()}),150))},Object.defineProperty(t.prototype,\"animatables\",{get:function(){return this._activeAnimatables},enumerable:!1,configurable:!0}),t.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=o.a.Now},t.prototype.getViewMatrix=function(){return this._viewMatrix},t.prototype.getProjectionMatrix=function(){return this._projectionMatrix},t.prototype.getTransformMatrix=function(){return this._transformMatrix},t.prototype.setTransformMatrix=function(e,t,i,n){this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?w.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=w.a.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,n):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix(\"viewProjection\",this._transformMatrix),this._sceneUbo.updateMatrix(\"view\",this._viewMatrix),this._sceneUbo.update()))},t.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},t.prototype.getUniqueId=function(){return F.a.UniqueId},t.prototype.addMesh=function(e,t){var i=this;void 0===t&&(t=!1),this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),this.onNewMeshAddedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.addMesh(e)})))},t.prototype.removeMesh=function(e,t){var i=this;void 0===t&&(t=!1);var n=this.meshes.indexOf(e);return-1!==n&&(this.meshes[n]=this.meshes[this.meshes.length-1],this.meshes.pop(),e.parent||e._removeFromSceneRootNodes()),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.removeMesh(e)})),n},t.prototype.addTransformNode=function(e){this._blockEntityCollection||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))},t.prototype.removeTransformNode=function(e){var t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){var i=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=i,i._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t},t.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e)),t},t.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},t.prototype.removeLight=function(e){var t=this.lights.indexOf(e);if(-1!==t){for(var i=0,n=this.meshes;i0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},t.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&this.particleSystems.splice(t,1),t},t.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},t.prototype.stopAnimation=function(e,t,i){},t.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},t.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t},t.prototype.removeMaterial=function(e){var t=e._indexInSceneMaterialArray;if(-1!==t&&t=0;t--)if(this.materials[t].id===e)return this.materials[t];return null},t.prototype.getMaterialByName=function(e){for(var t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},t.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},t.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getTransformNodeByID(e);if(i)return i;var n=this.getLightByID(e);if(n)return n;var r=this.getCameraByID(e);if(r)return r;var o=this.getBoneByID(e);return o||null},t.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getTransformNodeByName(e);if(i)return i;var n=this.getLightByName(e);if(n)return n;var r=this.getCameraByName(e);if(r)return r;var o=this.getBoneByName(e);return o||null},t.prototype.getMeshByName=function(e){for(var t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},t.prototype.getSkeletonByUniqueId=function(e){for(var t=0;t0&&0!=(s.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||s.alwaysSelectAsActiveMesh||s.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),c!==s&&c._activate(this._renderId,!1);for(var l=0,u=this._preActiveMeshStage;l0)for(var i=this.getActiveSubMeshCandidates(t),n=i.length,r=0;r1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var e=this.activeCamera.outputRenderTarget.getInternalTexture();e?this.getEngine().bindFramebuffer(e):P.a.Error(\"Camera contains invalid customDefaultRenderTarget\")}}else this.getEngine().restoreDefaultFramebuffer()},t.prototype._renderForCamera=function(e,t){if(!e||!e._skipRendering){var i=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error(\"Active camera not set\");i.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.getEngine().getCaps().multiview&&e.outputRenderTarget&&e.outputRenderTarget.getViewCount()>1?this.setTransformMatrix(e._rigCameras[0].getViewMatrix(),e._rigCameras[0].getProjectionMatrix(),e._rigCameras[1].getViewMatrix(),e._rigCameras[1].getProjectionMatrix()):this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var n=0;n0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets);for(var a=0,s=this._gatherActiveCameraRenderTargetsStage;a0){r.b.StartPerformanceCounter(\"Render targets\",this._renderTargets.length>0);for(var l=0;l0),this._renderId++}for(var d=0,f=this._cameraDrawRenderTargetStage;d1&&this.getEngine().getCaps().multiview)return this._renderForCamera(e),void this.onAfterRenderCameraObservable.notifyObservers(e);if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else for(var t=0;t-1&&(n.trigger===S.a.ACTION_OnIntersectionExitTrigger&&n._executeCurrent(b.a.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(S.a.ACTION_OnIntersectionExitTrigger,(function(e){var t=e instanceof d.a?e:e.mesh;return o===t}))&&n.trigger!==S.a.ACTION_OnIntersectionExitTrigger||t._intersectionsInProgress.splice(s,1))}}}},t.prototype._advancePhysicsEngineStep=function(e){},t.prototype._animate=function(){},t.prototype.animate=function(){if(this._engine.isDeterministicLockStep()){var e=Math.max(t.MinDeltaTime,Math.min(this._engine.getDeltaTime(),t.MaxDeltaTime))+this._timeAccumulator,i=this._engine.getTimeStep(),n=1e3/i/1e3,r=0,o=this._engine.getLockstepMaxSteps(),a=Math.floor(e/i);for(a=Math.min(a,o);e>0&&r0)for(var o=0;o0),this._intermediateRendering=!0;for(var u=0;u0),this._intermediateRendering=!1,this._renderId++}this.activeCamera=l,this._activeCamera&&this._activeCamera.cameraRigMode!==f.a.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var d=0,p=this._beforeClearStage;d0)for(o=0;o0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[o]);else{if(!this.activeCamera)throw new Error(\"No camera defined\");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var g=0,v=this._afterRenderStage;g-1&&this._engine.scenes.splice(r,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(t.prototype,\"isDisposed\",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),t.prototype.clearCachedVertexData=function(){for(var e=0;e-1?(u.a.Error(\"You're trying to reuse a post process not defined as reusable.\"),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},t.prototype._getViewMatrix=function(){return c.a.Identity()},t.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()||(this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix)),this._computedViewMatrix},t.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},t.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},t.prototype.getProjectionMatrix=function(e){var i,n,r,o,a,s,l,u;if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var h=this.getEngine(),d=this.getScene();if(this.mode===t.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=h.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1);var f=h.useReverseDepthBuffer;(d.useRightHandedSystem?f?c.a.PerspectiveFovReverseRHToRef:c.a.PerspectiveFovRHToRef:f?c.a.PerspectiveFovReverseLHToRef:c.a.PerspectiveFovLHToRef)(this.fov,h.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED)}else{var p=h.getRenderWidth()/2,_=h.getRenderHeight()/2;d.useRightHandedSystem?c.a.OrthoOffCenterRHToRef(null!==(i=this.orthoLeft)&&void 0!==i?i:-p,null!==(n=this.orthoRight)&&void 0!==n?n:p,null!==(r=this.orthoBottom)&&void 0!==r?r:-_,null!==(o=this.orthoTop)&&void 0!==o?o:_,this.minZ,this.maxZ,this._projectionMatrix):c.a.OrthoOffCenterLHToRef(null!==(a=this.orthoLeft)&&void 0!==a?a:-p,null!==(s=this.orthoRight)&&void 0!==s?s:p,null!==(l=this.orthoBottom)&&void 0!==l?l:-_,null!==(u=this.orthoTop)&&void 0!==u?u:_,this.minZ,this.maxZ,this._projectionMatrix),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=h.getRenderWidth(),this._cache.renderHeight=h.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},t.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},t.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?p.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=p.a.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},t.prototype.isInFrustum=function(e,t){if(void 0===t&&(t=!1),this._updateFrustumPlanes(),t&&this.rigCameras.length>0){var i=!1;return this.rigCameras.forEach((function(t){t._updateFrustumPlanes(),i=i||e.isInFrustum(t._frustumPlanes)})),i}return e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,t,i){throw void 0===e&&(e=100),d.a.WarnImport(\"Ray\")},t.prototype.getForwardRayToRef=function(e,t,i,n){throw void 0===t&&(t=100),d.a.WarnImport(\"Ray\")},t.prototype.dispose=function(i,n){for(void 0===n&&(n=!1),this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){var r=this._rigCameras.pop();r&&r.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==t.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var o=this._postProcesses.length;--o>=0;){var a=this._postProcesses[o];a&&a.dispose(this)}for(o=this.customRenderTargets.length;--o>=0;)this.customRenderTargets[o].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),e.prototype.dispose.call(this,i,n)},Object.defineProperty(t.prototype,\"isLeftCamera\",{get:function(){return this._isLeftCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"isRightCamera\",{get:function(){return this._isRightCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"leftCamera\",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"rightCamera\",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!1,configurable:!0}),t.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},t.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},t.prototype.setCameraRigMode=function(e,i){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var n=this._rigCameras.pop();n&&n.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=i.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=a.b.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var r=this.createRigCamera(this.name+\"_L\",0);r&&(r._isLeftCamera=!0);var o=this.createRigCamera(this.name+\"_R\",1);o&&(o._isRightCamera=!0),r&&o&&(this._rigCameras.push(r),this._rigCameras.push(o))}switch(this.cameraRigMode){case t.RIG_MODE_STEREOSCOPIC_ANAGLYPH:t._setStereoscopicAnaglyphRigMode(this);break;case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case t.RIG_MODE_STEREOSCOPIC_OVERUNDER:case t.RIG_MODE_STEREOSCOPIC_INTERLACED:t._setStereoscopicRigMode(this);break;case t.RIG_MODE_VR:t._setVRRigMode(this,i);break;case t.RIG_MODE_WEBVR:t._setWebVRRigMode(this,i)}this._cascadePostProcessesToRigCams(),this.update()}},t._setStereoscopicRigMode=function(e){throw\"Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode\"},t._setStereoscopicAnaglyphRigMode=function(e){throw\"Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode\"},t._setVRRigMode=function(e,t){throw\"Import Cameras/RigModes/vrRigMode before using VR rig mode\"},t._setWebVRRigMode=function(e,t){throw\"Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode\"},t.prototype._getVRProjectionMatrix=function(){return c.a.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},t.prototype._updateCameraRotationMatrix=function(){},t.prototype._updateWebVRCameraRotationMatrix=function(){},t.prototype._getWebVRProjectionMatrix=function(){return c.a.Identity()},t.prototype._getWebVRViewMatrix=function(){return c.a.Identity()},t.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,\"interaxialDistance\"===e&&(this._cameraRigParams.stereoHalfAngle=a.b.ToRadians(t/.0637))},t.prototype.createRigCamera=function(e,t){return null},t.prototype._updateRigCameras=function(){for(var e=0;e=1)&&(this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha)},e.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest},e.prototype._shouldTurnAlphaTestOn=function(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.markDirty=function(){for(var e=0,t=this.getScene().meshes;e1&&s.renderbufferStorageMultisample?s.renderbufferStorageMultisample(s.RENDERBUFFER,i,r,e,t):s.renderbufferStorage(s.RENDERBUFFER,n,e,t),s.framebufferRenderbuffer(s.FRAMEBUFFER,a,s.RENDERBUFFER,c),s.bindRenderbuffer(s.RENDERBUFFER,null),c},this._boundUniforms={};var h=null;if(t){if(n=n||{},b.a.SetMatrixPrecision(!!n.useHighPrecisionMatrix),t.getContext){if(h=t,this._renderingCanvas=h,null!=i&&(n.antialias=i),void 0===n.deterministicLockstep&&(n.deterministicLockstep=!1),void 0===n.lockstepMaxSteps&&(n.lockstepMaxSteps=4),void 0===n.timeStep&&(n.timeStep=1/60),void 0===n.preserveDrawingBuffer&&(n.preserveDrawingBuffer=!1),void 0===n.audioEngine&&(n.audioEngine=!0),void 0===n.stencil&&(n.stencil=!0),!1===n.premultipliedAlpha&&(this.premultipliedAlpha=!1),void 0===n.xrCompatible&&(n.xrCompatible=!0),this._doNotHandleContextLost=!!n.doNotHandleContextLost,navigator&&navigator.userAgent){var m=navigator.userAgent;this.hostInformation.isMobile=-1!==m.indexOf(\"Mobile\");for(var g=0,v=e.ExceptionList;g0)if(parseInt(C[C.length-1])>=P)continue}for(var R=0,x=S;R1?this._shaderProcessor=new _.a:this._shaderProcessor=new p,this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this._creationOptions=n,console.log(\"Babylon.js v\"+e.Version+\" - \"+this.description)}}return Object.defineProperty(e,\"NpmPackage\",{get:function(){return\"babylonjs@4.2.2\"},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"Version\",{get:function(){return\"4.2.2\"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"description\",{get:function(){var e=\"WebGL\"+this.webGLVersion;return this._caps.parallelShaderCompile&&(e+=\" - Parallel shader compilation\"),e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"ShadersRepository\",{get:function(){return r.a.ShadersRepository},set:function(e){r.a.ShadersRepository=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"supportsUniformBuffers\",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"_shouldUseHighPrecisionShader\",{get:function(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"needPOTTextures\",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"doNotHandleContextLost\",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"_supportsHardwareTextureRescaling\",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"framebufferDimensionsObject\",{set:function(e){this._framebufferDimensionsObject=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"currentViewport\",{get:function(){return this._cachedViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"emptyTexture\",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"emptyTexture3D\",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"emptyTexture2DArray\",{get:function(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture2DArray},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"emptyCubeTexture\",{get:function(){if(!this._emptyCubeTexture){var e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,u.a.TEXTUREFORMAT_RGBA,u.a.TEXTURETYPE_UNSIGNED_INT,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!1,configurable:!0}),e.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),parallelShaderCompile:this._gl.getExtension(\"KHR_parallel_shader_compile\"),standardDerivatives:this._webGLVersion>1||null!==this._gl.getExtension(\"OES_standard_derivatives\"),maxAnisotropy:1,astc:this._gl.getExtension(\"WEBGL_compressed_texture_astc\")||this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_astc\"),bptc:this._gl.getExtension(\"EXT_texture_compression_bptc\")||this._gl.getExtension(\"WEBKIT_EXT_texture_compression_bptc\"),s3tc:this._gl.getExtension(\"WEBGL_compressed_texture_s3tc\")||this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_s3tc\"),pvrtc:this._gl.getExtension(\"WEBGL_compressed_texture_pvrtc\")||this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_pvrtc\"),etc1:this._gl.getExtension(\"WEBGL_compressed_texture_etc1\")||this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_etc1\"),etc2:this._gl.getExtension(\"WEBGL_compressed_texture_etc\")||this._gl.getExtension(\"WEBKIT_WEBGL_compressed_texture_etc\")||this._gl.getExtension(\"WEBGL_compressed_texture_es3_0\"),textureAnisotropicFilterExtension:this._gl.getExtension(\"EXT_texture_filter_anisotropic\")||this._gl.getExtension(\"WEBKIT_EXT_texture_filter_anisotropic\")||this._gl.getExtension(\"MOZ_EXT_texture_filter_anisotropic\"),uintIndices:this._webGLVersion>1||null!==this._gl.getExtension(\"OES_element_index_uint\"),fragmentDepthSupported:this._webGLVersion>1||null!==this._gl.getExtension(\"EXT_frag_depth\"),highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension(\"EXT_disjoint_timer_query_webgl2\")||this._gl.getExtension(\"EXT_disjoint_timer_query\"),canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:this._webGLVersion>1&&this._gl.getExtension(\"EXT_color_buffer_float\"),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension(\"OES_texture_float\")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension(\"OES_texture_half_float\")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension(\"EXT_shader_texture_lod\")),blendMinMax:!1,multiview:this._gl.getExtension(\"OVR_multiview2\"),oculusMultiview:this._gl.getExtension(\"OCULUS_multiview\"),depthTextureExtension:!1},this._glVersion=this._gl.getParameter(this._gl.VERSION);var e=this._gl.getExtension(\"WEBGL_debug_renderer_info\");if(null!=e&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=\"Unknown vendor\"),this._glRenderer||(this._glRenderer=\"Unknown renderer\"),36193!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=36193),34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(1===this._webGLVersion&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)>0),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension(\"OES_texture_float_linear\")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension(\"OES_texture_half_float_linear\")),this._webGLVersion>1&&5131!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=this._gl.getParameter(this._gl.MAX_SAMPLES);else{var t=this._gl.getExtension(\"WEBGL_draw_buffers\");if(null!==t){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var i=0;i<16;i++)this._gl[\"COLOR_ATTACHMENT\"+i+\"_WEBGL\"]=t[\"COLOR_ATTACHMENT\"+i+\"_WEBGL\"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{var n=this._gl.getExtension(\"WEBGL_depth_texture\");null!=n&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=n.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var r=this._gl.getExtension(\"OES_vertex_array_object\");null!=r&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=r.createVertexArrayOES.bind(r),this._gl.bindVertexArray=r.bindVertexArrayOES.bind(r),this._gl.deleteVertexArray=r.deleteVertexArrayOES.bind(r))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var o=this._gl.getExtension(\"ANGLE_instanced_arrays\");null!=o?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=o.drawArraysInstancedANGLE.bind(o),this._gl.drawElementsInstanced=o.drawElementsInstancedANGLE.bind(o),this._gl.vertexAttribDivisor=o.vertexAttribDivisorANGLE.bind(o)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){var a=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);a&&s&&(this._caps.highPrecisionShaderSupported=0!==a.precision&&0!==s.precision)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{var c=this._gl.getExtension(\"EXT_blend_minmax\");null!=c&&(this._caps.blendMinMax=!0,this._gl.MAX=c.MAX_EXT,this._gl.MIN=c.MIN_EXT)}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var l=0;l=0&&this._activeRenderLoops.splice(t,1)}else this._activeRenderLoops=[]},e.prototype._renderLoop=function(){if(!this._contextWasLost){var e=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(e=!1),e){this.beginFrame();for(var t=0;t0?this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},e.prototype.getRenderingCanvas=function(){return this._renderingCanvas},e.prototype.getHostWindow=function(){return f.a.IsWindowObjectExist()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null},e.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth},e.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight},e.prototype._queueNewFrame=function(t,i){return e.QueueNewFrame(t,i)},e.prototype.runRenderLoop=function(e){-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._boundRenderFunction=this._renderLoop.bind(this),this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))},e.prototype.clear=function(e,t,i,n){void 0===n&&(n=!1),this.applyStates();var r=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),r|=this._gl.COLOR_BUFFER_BIT),i&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GREATER,this._gl.clearDepth(0)):this._gl.clearDepth(1),r|=this._gl.DEPTH_BUFFER_BIT),n&&(this._gl.clearStencil(0),r|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(r)},e.prototype._viewport=function(e,t,i,n){e===this._viewportCached.x&&t===this._viewportCached.y&&i===this._viewportCached.z&&n===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=n,this._gl.viewport(e,t,i,n))},e.prototype.setViewport=function(e,t,i){var n=t||this.getRenderWidth(),r=i||this.getRenderHeight(),o=e.x||0,a=e.y||0;this._cachedViewport=e,this._viewport(o*n,a*r,n*e.width,r*e.height)},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer()},e.prototype.resize=function(){var e,t;f.a.IsWindowObjectExist()?(e=this._renderingCanvas?this._renderingCanvas.clientWidth||this._renderingCanvas.width:window.innerWidth,t=this._renderingCanvas?this._renderingCanvas.clientHeight||this._renderingCanvas.height:window.innerHeight):(e=this._renderingCanvas?this._renderingCanvas.width:100,t=this._renderingCanvas?this._renderingCanvas.height:100),this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)},e.prototype.setSize=function(e,t){return!!this._renderingCanvas&&(e|=0,t|=0,(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t)&&(this._renderingCanvas.width=e,this._renderingCanvas.height=t,!0))},e.prototype.bindFramebuffer=function(e,t,i,n,r,o,a){void 0===t&&(t=0),void 0===o&&(o=0),void 0===a&&(a=0),this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var s=this._gl;e.is2DArray?s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,e._webGLTexture,o,a):e.isCube&&s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,e._webGLTexture,o);var c=e._depthStencilTexture;if(c){var l=c._generateStencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;e.is2DArray?s.framebufferTextureLayer(s.FRAMEBUFFER,l,c._webGLTexture,o,a):e.isCube?s.framebufferTexture2D(s.FRAMEBUFFER,l,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,c._webGLTexture,o):s.framebufferTexture2D(s.FRAMEBUFFER,l,s.TEXTURE_2D,c._webGLTexture,o)}this._cachedViewport&&!r?this.setViewport(this._cachedViewport,i,n):(i||(i=e.width,o&&(i/=Math.pow(2,o))),n||(n=e.height,o&&(n/=Math.pow(2,o))),this._viewport(0,0,i,n)),this.wipeCaches()},e.prototype._bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},e.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var n=this._gl;if(e._MSAAFramebuffer){if(e._textureArray)return void this.unBindMultiColorAttachmentFramebuffer(e._textureArray,t,i);n.bindFramebuffer(n.READ_FRAMEBUFFER,e._MSAAFramebuffer),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,e._framebuffer),n.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,n.COLOR_BUFFER_BIT,n.NEAREST)}!e.generateMipMaps||t||e.isCube||(this._bindTextureDirectly(n.TEXTURE_2D,e,!0),n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null)),i&&(e._MSAAFramebuffer&&this._bindUnboundFramebuffer(e._framebuffer),i()),this._bindUnboundFramebuffer(null)},e.prototype.flushFramebuffer=function(){this._gl.flush()},e.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},e.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},e.prototype.createVertexBuffer=function(e){return this._createVertexBuffer(e,this._gl.STATIC_DRAW)},e.prototype._createVertexBuffer=function(e,t){var i=this._gl.createBuffer();if(!i)throw new Error(\"Unable to create vertex buffer\");var n=new m.a(i);return this.bindArrayBuffer(n),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),n.references=1,n},e.prototype.createDynamicVertexBuffer=function(e){return this._createVertexBuffer(e,this._gl.DYNAMIC_DRAW)},e.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},e.prototype.createIndexBuffer=function(e,t){var i=this._gl.createBuffer(),n=new m.a(i);if(!i)throw new Error(\"Unable to create index buffer\");this.bindIndexBuffer(n);var r=this._normalizeIndexData(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),n.references=1,n.is32Bits=4===r.BYTES_PER_ELEMENT,n},e.prototype._normalizeIndexData=function(e){if(e instanceof Uint16Array)return e;if(this._caps.uintIndices){if(e instanceof Uint32Array)return e;for(var t=0;t=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)},e.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},e.prototype.bindUniformBlock=function(e,t,i){var n=e.program,r=this._gl.getUniformBlockIndex(n,t);this._gl.uniformBlockBinding(n,r,i)},e.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},e.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)},e.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},e.prototype._vertexAttribPointer=function(e,t,i,n,r,o,a){var s=this._currentBufferPointers[t];if(s){var c=!1;s.active?(s.buffer!==e&&(s.buffer=e,c=!0),s.size!==i&&(s.size=i,c=!0),s.type!==n&&(s.type=n,c=!0),s.normalized!==r&&(s.normalized=r,c=!0),s.stride!==o&&(s.stride=o,c=!0),s.offset!==a&&(s.offset=a,c=!0)):(c=!0,s.active=!0,s.index=t,s.size=i,s.type=n,s.normalized=r,s.stride=o,s.offset=a,s.buffer=e),(c||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,n,r,o,a))}},e.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},e.prototype._bindVertexBuffersAttributes=function(e,t){var i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var n=0;n=0){var o=e[i[n]];if(!o)continue;this._gl.enableVertexAttribArray(r),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[r]=!0);var a=o.getBuffer();a&&(this._vertexAttribPointer(a,r,o.getSize(),o.type,o.normalized,o.byteStride,o.byteOffset),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(r,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(r),this._currentInstanceBuffers.push(a))))}}},e.prototype.recordVertexArrayObject=function(e,t,i){var n=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(n),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),n},e.prototype.bindVertexArrayObject=function(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)},e.prototype.bindBuffersDirectly=function(e,t,i,n,r){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==r){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=r;var o=r.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var a=0,s=0;s=0&&(this._gl.enableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!0,this._vertexAttribPointer(e,c,i[s],this._gl.FLOAT,!1,n,a)),a+=4*i[s]}}this._bindIndexBufferWithCache(t)},e.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},e.prototype.bindBuffers=function(e,t,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===i||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i)),this._bindIndexBufferWithCache(t)},e.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1?\"#version 300 es\\n#define WEBGL2 \\n\":\"\",s=this._compileShader(t,\"vertex\",n,a),c=this._compileShader(i,\"fragment\",n,a);return this._createShaderProgram(e,s,c,r,o)},e.prototype.createPipelineContext=function(){var e=new g.a;return e.engine=this,this._caps.parallelShaderCompile&&(e.isParallelCompiled=!0),e},e.prototype._createShaderProgram=function(e,t,i,n,r){void 0===r&&(r=null);var o=n.createProgram();if(e.program=o,!o)throw new Error(\"Unable to create program\");return n.attachShader(o,t),n.attachShader(o,i),n.linkProgram(o),e.context=n,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},e.prototype._finalizePipelineContext=function(e){var t=e.context,i=e.vertexShader,n=e.fragmentShader,r=e.program;if(!t.getProgramParameter(r,t.LINK_STATUS)){var o,a;if(!this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(i))throw e.vertexCompilationError=o,new Error(\"VERTEX SHADER \"+o);if(!this._gl.getShaderParameter(n,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(n))throw e.fragmentCompilationError=o,new Error(\"FRAGMENT SHADER \"+o);if(a=t.getProgramInfoLog(r))throw e.programLinkError=a,new Error(a)}if(this.validateShaderPrograms&&(t.validateProgram(r),!t.getProgramParameter(r,t.VALIDATE_STATUS)&&(a=t.getProgramInfoLog(r))))throw e.programValidationError=a,new Error(a);t.deleteShader(i),t.deleteShader(n),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)},e.prototype._preparePipelineContext=function(e,t,i,n,r,o,a){var s=e;s.program=n?this.createRawShaderProgram(s,t,i,void 0,a):this.createShaderProgram(s,t,i,o,void 0,a),s.program.__SPECTOR_rebuildProgram=r},e.prototype._isRenderingStateCompiled=function(e){var t=e;return!!this._gl.getProgramParameter(t.program,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)&&(this._finalizePipelineContext(t),!0)},e.prototype._executeWhenRenderingStateIsCompiled=function(e,t){var i=e;if(i.isParallelCompiled){var n=i.onCompiled;i.onCompiled=n?function(){n(),t()}:t}else t()},e.prototype.getUniforms=function(e,t){for(var i=new Array,n=e,r=0;r-1?t.substring(A).toLowerCase():\"\"),C=null;P.indexOf(\"?\")>-1&&(P=P.split(\"?\")[0]);for(var R=0,x=e._TextureLoaders;Rc||e.height>c||!v._supportsHardwareTextureRescaling)return v._prepareWorkingCanvas(),!(!v._workingCanvas||!v._workingContext)&&(v._workingCanvas.width=t,v._workingCanvas.height=i,v._workingContext.drawImage(e,0,0,e.width,e.height,0,0,t,i),r.texImage2D(r.TEXTURE_2D,0,s,s,r.UNSIGNED_BYTE,v._workingCanvas),E.width=t,E.height=i,!1);var l=new h.a(v,h.b.Temp);return v._bindTextureDirectly(r.TEXTURE_2D,l,!0),r.texImage2D(r.TEXTURE_2D,0,s,s,r.UNSIGNED_BYTE,e),v._rescaleTexture(l,E,o,s,(function(){v._releaseTexture(l),v._bindTextureDirectly(r.TEXTURE_2D,E,!0),n()})),!0}),a)};!b||T?l&&(l.decoding||l.close)?N(l):e._FileToolsLoadImage(t,N,I,o?o.offlineProvider:null,m):\"string\"==typeof l||l instanceof ArrayBuffer||ArrayBuffer.isView(l)||l instanceof Blob?e._FileToolsLoadImage(l,N,I,o?o.offlineProvider:null,m):l&&N(l)}return E},e._FileToolsLoadImage=function(e,t,i,n,r){throw o.a.WarnImport(\"FileTools\")},e.prototype._rescaleTexture=function(e,t,i,n,r){},e.prototype.createRawTexture=function(e,t,i,n,r,a,s,c,l){throw void 0===c&&(c=null),void 0===l&&(l=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport(\"Engine.RawTexture\")},e.prototype.createRawCubeTexture=function(e,t,i,n,r,a,s,c){throw void 0===c&&(c=null),o.a.WarnImport(\"Engine.RawTexture\")},e.prototype.createRawTexture3D=function(e,t,i,n,r,a,s,c,l,h){throw void 0===l&&(l=null),void 0===h&&(h=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport(\"Engine.RawTexture\")},e.prototype.createRawTexture2DArray=function(e,t,i,n,r,a,s,c,l,h){throw void 0===l&&(l=null),void 0===h&&(h=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport(\"Engine.RawTexture\")},e.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},e.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},e.prototype._getTextureTarget=function(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D},e.prototype.updateTextureSamplingMode=function(e,t,i){void 0===i&&(i=!1);var n=this._getTextureTarget(t),r=this._getSamplingParameters(e,t.generateMipMaps||i);this._setTextureParameterInteger(n,this._gl.TEXTURE_MAG_FILTER,r.mag,t),this._setTextureParameterInteger(n,this._gl.TEXTURE_MIN_FILTER,r.min),i&&(t.generateMipMaps=!0,this._gl.generateMipmap(n)),this._bindTextureDirectly(n,null),t.samplingMode=e},e.prototype.updateTextureWrappingMode=function(e,t,i,n){void 0===i&&(i=null),void 0===n&&(n=null);var r=this._getTextureTarget(e);null!==t&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),null!==i&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&null!==n&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(n),e),e._cachedWrapR=n),this._bindTextureDirectly(r,null)},e.prototype._setupDepthStencilTexture=function(e,t,i,n,r){var o=t.width||t,a=t.height||t,s=t.layers||0;e.baseWidth=o,e.baseHeight=a,e.width=o,e.height=a,e.is2DArray=s>0,e.depth=s,e.isReady=!0,e.samples=1,e.generateMipMaps=!1,e._generateDepthBuffer=!0,e._generateStencilBuffer=i,e.samplingMode=n?u.a.TEXTURE_BILINEAR_SAMPLINGMODE:u.a.TEXTURE_NEAREST_SAMPLINGMODE,e.type=u.a.TEXTURETYPE_UNSIGNED_INT,e._comparisonFunction=r;var c=this._gl,l=this._getTextureTarget(e),h=this._getSamplingParameters(e.samplingMode,!1);c.texParameteri(l,c.TEXTURE_MAG_FILTER,h.mag),c.texParameteri(l,c.TEXTURE_MIN_FILTER,h.min),c.texParameteri(l,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(l,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),0===r?(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,u.a.LEQUAL),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.NONE)):(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,r),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE))},e.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){void 0===o&&(o=0),void 0===a&&(a=0);var s=this._gl,c=s.TEXTURE_2D;e.isCube&&(c=s.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._gl.compressedTexImage2D(c,a,t,i,n,0,r)},e.prototype._uploadDataToTextureDirectly=function(e,t,i,n,r,o){void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=!1);var a=this._gl,s=this._getWebGLTextureType(e.type),c=this._getInternalFormat(e.format),l=void 0===r?this._getRGBABufferInternalSizedFormat(e.type,e.format):this._getInternalFormat(r);this._unpackFlipY(e.invertY);var u=a.TEXTURE_2D;e.isCube&&(u=a.TEXTURE_CUBE_MAP_POSITIVE_X+i);var h=Math.round(Math.log(e.width)*Math.LOG2E),d=Math.round(Math.log(e.height)*Math.LOG2E),f=o?e.width:Math.pow(2,Math.max(h-n,0)),p=o?e.height:Math.pow(2,Math.max(d-n,0));a.texImage2D(u,n,l,f,p,0,c,s,t)},e.prototype.updateTextureData=function(e,t,i,n,r,o,a,s){void 0===a&&(a=0),void 0===s&&(s=0);var c=this._gl,l=this._getWebGLTextureType(e.type),u=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);var h=c.TEXTURE_2D;e.isCube&&(h=c.TEXTURE_CUBE_MAP_POSITIVE_X+a),c.texSubImage2D(h,s,i,n,r,o,u,l,t)},e.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0);var r=this._gl,o=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,i,n),this._bindTextureDirectly(o,null,!0)},e.prototype._prepareWebGLTextureContinuation=function(e,t,i,n,r){var o=this._gl;if(o){var a=this._getSamplingParameters(r,!i);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,a.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,a.min),i||n||o.generateMipmap(o.TEXTURE_2D),this._bindTextureDirectly(o.TEXTURE_2D,null),t&&t._removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},e.prototype._prepareWebGLTexture=function(t,i,n,r,o,a,s,c,l){var h=this;void 0===l&&(l=u.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var d=this.getCaps().maxTextureSize,f=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(n,d):n),p=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(r,d):r),_=this._gl;_&&(t._webGLTexture?(this._bindTextureDirectly(_.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===o||!!o),t.baseWidth=n,t.baseHeight=r,t.width=f,t.height=p,t.isReady=!0,c(f,p,(function(){h._prepareWebGLTextureContinuation(t,i,a,s,l)}))||this._prepareWebGLTextureContinuation(t,i,a,s,l)):i&&i._removePendingData(t))},e.prototype._setupFramebufferDepthAttachments=function(e,t,i,n,r){void 0===r&&(r=1);var o=this._gl;if(e&&t)return this._getDepthStencilBuffer(i,n,r,o.DEPTH_STENCIL,o.DEPTH24_STENCIL8,o.DEPTH_STENCIL_ATTACHMENT);if(t){var a=o.DEPTH_COMPONENT16;return this._webGLVersion>1&&(a=o.DEPTH_COMPONENT32F),this._getDepthStencilBuffer(i,n,r,a,a,o.DEPTH_ATTACHMENT)}return e?this._getDepthStencilBuffer(i,n,r,o.STENCIL_INDEX8,o.STENCIL_INDEX8,o.STENCIL_ATTACHMENT):null},e.prototype._releaseFramebufferObjects=function(e){var t=this._gl;e._framebuffer&&(t.deleteFramebuffer(e._framebuffer),e._framebuffer=null),e._depthStencilBuffer&&(t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(t.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(t.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null)},e.prototype._releaseTexture=function(e){this._releaseFramebufferObjects(e),this._deleteTexture(e._webGLTexture),this.unbindAllTextures();var t=this._internalTexturesCache.indexOf(e);-1!==t&&this._internalTexturesCache.splice(t,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()},e.prototype._deleteTexture=function(e){this._gl.deleteTexture(e)},e.prototype._setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},e.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.program);for(var i=e.getSamplers(),n=0;n-1;return i&&o&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||n?(this._activateCurrentTexture(),t&&t.isMultiview?this._gl.bindTexture(e,t?t._colorTextureArray:null):this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)):i&&(r=!0,this._activateCurrentTexture()),o&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),r},e.prototype._bindTexture=function(e,t){if(void 0!==e){t&&(t._associatedChannel=e),this._activeChannel=e;var i=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(i,t)}},e.prototype.unbindAllTextures=function(){for(var e=0;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))},e.prototype.setTexture=function(e,t,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},e.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i&&i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},e.prototype._getTextureWrapMode=function(e){switch(e){case u.a.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case u.a.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case u.a.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},e.prototype._setTexture=function(e,t,i,n){if(void 0===i&&(i=!1),void 0===n&&(n=!1),!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video)this._activeChannel=e,t.update();else if(t.delayLoadState===u.a.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;var r;r=n?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!i&&r&&(r._associatedChannel=e);var o=!0;this._boundTexturesCache[e]===r&&(i||this._bindSamplerUniformToChannel(r._associatedChannel,e),o=!1),this._activeChannel=e;var a=this._getTextureTarget(r);if(o&&this._bindTextureDirectly(a,r,i),r&&!r.isMultiview){if(r.isCube&&r._cachedCoordinatesMode!==t.coordinatesMode){r._cachedCoordinatesMode=t.coordinatesMode;var s=t.coordinatesMode!==u.a.TEXTURE_CUBIC_MODE&&t.coordinatesMode!==u.a.TEXTURE_SKYBOX_MODE?u.a.TEXTURE_WRAP_ADDRESSMODE:u.a.TEXTURE_CLAMP_ADDRESSMODE;t.wrapU=s,t.wrapV=s}r._cachedWrapU!==t.wrapU&&(r._cachedWrapU=t.wrapU,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),r)),r._cachedWrapV!==t.wrapV&&(r._cachedWrapV=t.wrapV,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),r)),r.is3D&&r._cachedWrapR!==t.wrapR&&(r._cachedWrapR=t.wrapR,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),r)),this._setAnisotropicLevel(a,r,t.anisotropicFilteringLevel)}return!0},e.prototype.setTextureArray=function(e,t,i){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var n=0;n=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}},e.prototype.releaseEffects=function(){for(var e in this._compiledEffects){var t=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(t)}this._compiledEffects={}},e.prototype.dispose=function(){this.stopRenderLoop(),this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.releaseEffects(),this.unbindAllAttributes(),this._boundUniforms=[],f.a.IsWindowObjectExist()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener(\"webglcontextlost\",this._onContextLost),this._renderingCanvas.removeEventListener(\"webglcontextrestored\",this._onContextRestored))),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this._boundRenderFunction=null,r.a.ResetCache();for(var e=0,t=this._activeRequests;e1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(u.a.TEXTURETYPE_FLOAT)},e.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(u.a.TEXTURETYPE_HALF_FLOAT)},e.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var i=!0,n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if((i=(i=i&&o===t.FRAMEBUFFER_COMPLETE)&&t.getError()===t.NO_ERROR)&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var a=t.RGBA,s=t.UNSIGNED_BYTE,c=new Uint8Array(4);t.readPixels(0,0,1,1,a,s,c),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(n),t.deleteFramebuffer(r),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},e.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case u.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case u.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case u.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case u.a.TEXTURETYPE_BYTE:return this._gl.BYTE;case u.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case u.a.TEXTURETYPE_SHORT:return this._gl.SHORT;case u.a.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case u.a.TEXTURETYPE_INT:return this._gl.INT;case u.a.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case u.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case u.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case u.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case u.a.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case u.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case u.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case u.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},e.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case u.a.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case u.a.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case u.a.TEXTUREFORMAT_RED:t=this._gl.RED;break;case u.a.TEXTUREFORMAT_RG:t=this._gl.RG;break;case u.a.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case u.a.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}if(this._webGLVersion>1)switch(e){case u.a.TEXTUREFORMAT_RED_INTEGER:t=this._gl.RED_INTEGER;break;case u.a.TEXTUREFORMAT_RG_INTEGER:t=this._gl.RG_INTEGER;break;case u.a.TEXTUREFORMAT_RGB_INTEGER:t=this._gl.RGB_INTEGER;break;case u.a.TEXTUREFORMAT_RGBA_INTEGER:t=this._gl.RGBA_INTEGER}return t},e.prototype._getRGBABufferInternalSizedFormat=function(e,t){if(1===this._webGLVersion){if(void 0!==t)switch(t){case u.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case u.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB}return this._gl.RGBA}switch(e){case u.a.TEXTURETYPE_BYTE:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case u.a.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case u.a.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R8;case u.a.TEXTUREFORMAT_RG:return this._gl.RG8;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB8;case u.a.TEXTUREFORMAT_RGBA:return this._gl.RGBA8;case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case u.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case u.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case u.a.TEXTURETYPE_SHORT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case u.a.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case u.a.TEXTURETYPE_INT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case u.a.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case u.a.TEXTURETYPE_FLOAT:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R32F;case u.a.TEXTUREFORMAT_RG:return this._gl.RG32F;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case u.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case u.a.TEXTURETYPE_HALF_FLOAT:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R16F;case u.a.TEXTUREFORMAT_RG:return this._gl.RG16F;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case u.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case u.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case u.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case u.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case u.a.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return this._gl.RGBA8},e.prototype._getRGBAMultiSampleBufferFormat=function(e){return e===u.a.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===u.a.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},e.prototype._loadFile=function(t,i,n,r,o,a){var s=this,c=e._FileToolsLoadFile(t,i,n,r,o,a);return this._activeRequests.push(c),c.onCompleteObservable.add((function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)})),c},e._FileToolsLoadFile=function(e,t,i,n,r,a){throw o.a.WarnImport(\"FileTools\")},e.prototype.readPixels=function(e,t,i,n,r){void 0===r&&(r=!0);var o=r?4:3,a=r?this._gl.RGBA:this._gl.RGB,s=new Uint8Array(n*i*o);return this._gl.readPixels(e,t,i,n,a,this._gl.UNSIGNED_BYTE,s),s},Object.defineProperty(e,\"IsSupported\",{get:function(){return this.isSupported()},enumerable:!1,configurable:!0}),e.isSupported=function(){if(null!==this._HasMajorPerformanceCaveat)return!this._HasMajorPerformanceCaveat;if(null===this._IsSupported)try{var e=v.a.CreateCanvas(1,1),t=e.getContext(\"webgl\")||e.getContext(\"experimental-webgl\");this._IsSupported=null!=t&&!!window.WebGLRenderingContext}catch(e){this._IsSupported=!1}return this._IsSupported},Object.defineProperty(e,\"HasMajorPerformanceCaveat\",{get:function(){if(null===this._HasMajorPerformanceCaveat)try{var e=v.a.CreateCanvas(1,1),t=e.getContext(\"webgl\",{failIfMajorPerformanceCaveat:!0})||e.getContext(\"experimental-webgl\",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch(e){this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat},enumerable:!1,configurable:!0}),e.CeilingPOT=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},e.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},e.NearestPOT=function(t){var i=e.CeilingPOT(t),n=e.FloorPOT(t);return i-t>t-n?n:i},e.GetExponentOfTwo=function(t,i,n){var r;switch(void 0===n&&(n=u.a.SCALEMODE_NEAREST),n){case u.a.SCALEMODE_FLOOR:r=e.FloorPOT(t);break;case u.a.SCALEMODE_NEAREST:r=e.NearestPOT(t);break;case u.a.SCALEMODE_CEILING:default:r=e.CeilingPOT(t)}return Math.min(r,i)},e.QueueNewFrame=function(e,t){return f.a.IsWindowObjectExist()?(t||(t=window),t.requestPostAnimationFrame?t.requestPostAnimationFrame(e):t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)):\"undefined\"!=typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16)},e.prototype.getHostDocument=function(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:document},e.ExceptionList=[{key:\"Chrome/63.0\",capture:\"63\\\\.0\\\\.3239\\\\.(\\\\d+)\",captureConstraint:108,targets:[\"uniformBuffer\"]},{key:\"Firefox/58\",capture:null,captureConstraint:null,targets:[\"uniformBuffer\"]},{key:\"Firefox/59\",capture:null,captureConstraint:null,targets:[\"uniformBuffer\"]},{key:\"Chrome/72.+?Mobile\",capture:null,captureConstraint:null,targets:[\"vao\"]},{key:\"Chrome/73.+?Mobile\",capture:null,captureConstraint:null,targets:[\"vao\"]},{key:\"Chrome/74.+?Mobile\",capture:null,captureConstraint:null,targets:[\"vao\"]},{key:\"Mac OS.+Chrome/71\",capture:null,captureConstraint:null,targets:[\"vao\"]},{key:\"Mac OS.+Chrome/72\",capture:null,captureConstraint:null,targets:[\"vao\"]}],e._TextureLoaders=[],e.CollisionsEpsilon=.001,e._IsSupported=null,e._HasMajorPerformanceCaveat=null,e}()},function(e,t,i){\"use strict\";i.d(t,\"b\",(function(){return n})),i.d(t,\"a\",(function(){return c}));var n,r=i(6),o=i(102),a=i(2),s=i(21);!function(e){e[e.Unknown=0]=\"Unknown\",e[e.Url=1]=\"Url\",e[e.Temp=2]=\"Temp\",e[e.Raw=3]=\"Raw\",e[e.Dynamic=4]=\"Dynamic\",e[e.RenderTarget=5]=\"RenderTarget\",e[e.MultiRenderTarget=6]=\"MultiRenderTarget\",e[e.Cube=7]=\"Cube\",e[e.CubeRaw=8]=\"CubeRaw\",e[e.CubePrefiltered=9]=\"CubePrefiltered\",e[e.Raw3D=10]=\"Raw3D\",e[e.Raw2DArray=11]=\"Raw2DArray\",e[e.Depth=12]=\"Depth\",e[e.CubeRawRGBD=13]=\"CubeRawRGBD\"}(n||(n={}));var c=function(){function e(e,t,i){void 0===i&&(i=!1),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url=\"\",this.samplingMode=-1,this.generateMipMaps=!1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new r.c,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=n.Unknown,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension=\"\",this._files=null,this._workingCanvas=null,this._workingContext=null,this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._MSAARenderBuffer=null,this._attachments=null,this._textureArray=null,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._isDisabled=!1,this._compression=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._comparisonFunction=0,this._sphericalPolynomial=null,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._webGLTexture=null,this._references=1,this._gammaSpace=null,this._engine=e,this._source=t,i||(this._webGLTexture=e._createTexture())}return e.prototype.getEngine=function(){return this._engine},Object.defineProperty(e.prototype,\"source\",{get:function(){return this._source},enumerable:!1,configurable:!0}),e.prototype.incrementReferences=function(){this._references++},e.prototype.updateSize=function(e,t,i){void 0===i&&(i=1),this.width=e,this.height=t,this.depth=i,this.baseWidth=e,this.baseHeight=t,this.baseDepth=i,this._size=e*t*i},e.prototype._rebuild=function(){var t,i,r=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this.source){case n.Temp:return;case n.Url:return void(i=this._engine.createTexture(null!==(t=this._originalUrl)&&void 0!==t?t:this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(function(){i._swapAndDie(r),r.isReady=!0}),null,this._buffer,void 0,this.format));case n.Raw:return(i=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case n.Raw3D:return(i=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case n.Raw2DArray:return(i=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case n.Dynamic:return(i=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode))._swapAndDie(this),void this._engine.updateDynamicTexture(this,this._engine.getRenderingCanvas(),this.invertY,void 0,void 0,!0);case n.RenderTarget:var s=new o.a;if(s.generateDepthBuffer=this._generateDepthBuffer,s.generateMipMaps=this.generateMipMaps,s.generateStencilBuffer=this._generateStencilBuffer,s.samplingMode=this.samplingMode,s.type=this.type,this.isCube)i=this._engine.createRenderTargetCubeTexture(this.width,s);else{var c={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};i=this._engine.createRenderTargetTexture(c,s)}return i._swapAndDie(this),void(this.isReady=!0);case n.Depth:var l={bilinearFiltering:this.samplingMode!==a.a.TEXTURE_BILINEAR_SAMPLINGMODE,comparisonFunction:this._comparisonFunction,generateStencil:this._generateStencilBuffer,isCube:this.isCube},u={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};return(i=this._engine.createDepthStencilTexture(u,l))._swapAndDie(this),void(this.isReady=!0);case n.Cube:return void(i=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(function(){i._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension));case n.CubeRaw:return(i=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case n.CubeRawRGBD:return i=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),void e._UpdateRGBDAsync(i,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then((function(){i._swapAndDie(r),r.isReady=!0}));case n.CubePrefiltered:return void((i=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(function(e){e&&e._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}},e.prototype._swapAndDie=function(e){e._webGLTexture=this._webGLTexture,e._isRGBD=this._isRGBD,this._framebuffer&&(e._framebuffer=this._framebuffer),this._depthStencilBuffer&&(e._depthStencilBuffer=this._depthStencilBuffer),e._depthStencilTexture=this._depthStencilTexture,this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);var t,i=this._engine.getLoadedTexturesCache();-1!==(t=i.indexOf(this))&&i.splice(t,1),-1===(t=i.indexOf(e))&&i.push(e)},e.prototype.dispose=function(){this._webGLTexture&&(this._references--,0===this._references&&(this._engine._releaseTexture(this),this._webGLTexture=null))},e._UpdateRGBDAsync=function(e,t,i,n,r){throw s.a.WarnImport(\"environmentTextureTools\")},e}()},function(e,t,i){\"use strict\";i.d(t,\"b\",(function(){return n})),i.d(t,\"c\",(function(){return r})),i.d(t,\"a\",(function(){return o}));var n=1/2.2,r=2.2,o=.001},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return l}));var n=i(1),r=i(0),o=i(3),a=i(6),s=i(22),c=i(21),l=function(){function e(e,t){void 0===t&&(t=null),this.state=\"\",this.metadata=null,this.reservedDataStore=null,this._doNotSerialize=!1,this._isDisposed=!1,this.animations=new Array,this._ranges={},this.onReady=null,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=r.a.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._sceneRootNodesIndex=-1,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new a.c,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||s.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}return e.AddNodeConstructor=function(e,t){this._NodeConstructors[e]=t},e.Construct=function(e,t,i,n){var r=this._NodeConstructors[e];return r?r(t,i,n):null},Object.defineProperty(e.prototype,\"doNotSerialize\",{get:function(){return!!this._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize},set:function(e){this._doNotSerialize=e},enumerable:!1,configurable:!0}),e.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(e.prototype,\"parent\",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){var t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){var i=this._parentNode._children.indexOf(this);-1!==i&&this._parentNode._children.splice(i,1),e||this._isDisposed||this._addToSceneRootNodes()}this._parentNode=e,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}},enumerable:!1,configurable:!0}),e.prototype._addToSceneRootNodes=function(){-1===this._sceneRootNodesIndex&&(this._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))},e.prototype._removeFromSceneRootNodes=function(){if(-1!==this._sceneRootNodesIndex){var e=this._scene.rootNodes,t=e.length-1;e[this._sceneRootNodesIndex]=e[t],e[this._sceneRootNodesIndex]._sceneRootNodesIndex=this._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._sceneRootNodesIndex=-1}},Object.defineProperty(e.prototype,\"animationPropertiesOverride\",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return\"Node\"},Object.defineProperty(e.prototype,\"onDispose\",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._scene.getEngine()},e.prototype.addBehavior=function(e,t){var i=this;return void 0===t&&(t=!1),-1!==this._behaviors.indexOf(e)||(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce((function(){e.attach(i)})):e.attach(this),this._behaviors.push(e)),this},e.prototype.removeBehavior=function(e){var t=this._behaviors.indexOf(e);return-1===t||(this._behaviors[t].detach(),this._behaviors.splice(t,1)),this},Object.defineProperty(e.prototype,\"behaviors\",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),e.prototype.getBehaviorByName=function(e){for(var t=0,i=this._behaviors;t\\n#if defined(BUMP) || !defined(NORMAL)\\n#extension GL_OES_standard_derivatives : enable\\n#endif\\n#include[SCENE_MRT_COUNT]\\n#define CUSTOM_FRAGMENT_BEGIN\\n#ifdef LOGARITHMICDEPTH\\n#extension GL_EXT_frag_depth : enable\\n#endif\\n\\n#define RECIPROCAL_PI2 0.15915494\\nuniform vec3 vEyePosition;\\nuniform vec3 vAmbientColor;\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#ifdef MAINUV1\\nvarying vec2 vMainUV1;\\n#endif\\n#ifdef MAINUV2\\nvarying vec2 vMainUV2;\\n#endif\\n\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include\\n\\n#ifdef DIFFUSE\\n#if DIFFUSEDIRECTUV == 1\\n#define vDiffuseUV vMainUV1\\n#elif DIFFUSEDIRECTUV == 2\\n#define vDiffuseUV vMainUV2\\n#else\\nvarying vec2 vDiffuseUV;\\n#endif\\nuniform sampler2D diffuseSampler;\\n#endif\\n#ifdef AMBIENT\\n#if AMBIENTDIRECTUV == 1\\n#define vAmbientUV vMainUV1\\n#elif AMBIENTDIRECTUV == 2\\n#define vAmbientUV vMainUV2\\n#else\\nvarying vec2 vAmbientUV;\\n#endif\\nuniform sampler2D ambientSampler;\\n#endif\\n#ifdef OPACITY\\n#if OPACITYDIRECTUV == 1\\n#define vOpacityUV vMainUV1\\n#elif OPACITYDIRECTUV == 2\\n#define vOpacityUV vMainUV2\\n#else\\nvarying vec2 vOpacityUV;\\n#endif\\nuniform sampler2D opacitySampler;\\n#endif\\n#ifdef EMISSIVE\\n#if EMISSIVEDIRECTUV == 1\\n#define vEmissiveUV vMainUV1\\n#elif EMISSIVEDIRECTUV == 2\\n#define vEmissiveUV vMainUV2\\n#else\\nvarying vec2 vEmissiveUV;\\n#endif\\nuniform sampler2D emissiveSampler;\\n#endif\\n#ifdef LIGHTMAP\\n#if LIGHTMAPDIRECTUV == 1\\n#define vLightmapUV vMainUV1\\n#elif LIGHTMAPDIRECTUV == 2\\n#define vLightmapUV vMainUV2\\n#else\\nvarying vec2 vLightmapUV;\\n#endif\\nuniform sampler2D lightmapSampler;\\n#endif\\n#ifdef REFRACTION\\n#ifdef REFRACTIONMAP_3D\\nuniform samplerCube refractionCubeSampler;\\n#else\\nuniform sampler2D refraction2DSampler;\\n#endif\\n#endif\\n#if defined(SPECULAR) && defined(SPECULARTERM)\\n#if SPECULARDIRECTUV == 1\\n#define vSpecularUV vMainUV1\\n#elif SPECULARDIRECTUV == 2\\n#define vSpecularUV vMainUV2\\n#else\\nvarying vec2 vSpecularUV;\\n#endif\\nuniform sampler2D specularSampler;\\n#endif\\n#ifdef ALPHATEST\\nuniform float alphaCutOff;\\n#endif\\n\\n#include\\n\\n#ifdef REFLECTION\\n#ifdef REFLECTIONMAP_3D\\nuniform samplerCube reflectionCubeSampler;\\n#else\\nuniform sampler2D reflection2DSampler;\\n#endif\\n#ifdef REFLECTIONMAP_SKYBOX\\nvarying vec3 vPositionUVW;\\n#else\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvarying vec3 vDirectionW;\\n#endif\\n#endif\\n#include\\n#endif\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#define CUSTOM_FRAGMENT_DEFINITIONS\\nvoid main(void) {\\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\nvec4 baseColor=vec4(1.,1.,1.,1.);\\nvec3 diffuseColor=vDiffuseColor.rgb;\\n\\nfloat alpha=vDiffuseColor.a;\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\\n#endif\\n#include\\n#ifdef TWOSIDEDLIGHTING\\nnormalW=gl_FrontFacing ? normalW : -normalW;\\n#endif\\n#ifdef DIFFUSE\\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\\n#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)\\nif (baseColor.a\\n#ifdef VERTEXCOLOR\\nbaseColor.rgb*=vColor.rgb;\\n#endif\\n#ifdef DETAIL\\nbaseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);\\n#endif\\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\\n\\nvec3 baseAmbientColor=vec3(1.,1.,1.);\\n#ifdef AMBIENT\\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\\n#endif\\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\\n\\n#ifdef SPECULARTERM\\nfloat glossiness=vSpecularColor.a;\\nvec3 specularColor=vSpecularColor.rgb;\\n#ifdef SPECULAR\\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\\nspecularColor=specularMapColor.rgb;\\n#ifdef GLOSSINESS\\nglossiness=glossiness*specularMapColor.a;\\n#endif\\n#endif\\n#else\\nfloat glossiness=0.;\\n#endif\\n\\nvec3 diffuseBase=vec3(0.,0.,0.);\\nlightingInfo info;\\n#ifdef SPECULARTERM\\nvec3 specularBase=vec3(0.,0.,0.);\\n#endif\\nfloat shadow=1.;\\n#ifdef LIGHTMAP\\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\\n#ifdef RGBDLIGHTMAP\\nlightmapColor.rgb=fromRGBD(lightmapColor);\\n#endif\\nlightmapColor.rgb*=vLightmapInfos.y;\\n#endif\\n#include[0..maxSimultaneousLights]\\n\\nvec4 refractionColor=vec4(0.,0.,0.,1.);\\n#ifdef REFRACTION\\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\\n#ifdef REFRACTIONMAP_3D\\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\\nif (dot(refractionVector,viewDirectionW)<1.0) {\\nrefractionColor=textureCube(refractionCubeSampler,refractionVector);\\n}\\n#else\\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\\nrefractionCoords.y=1.0-refractionCoords.y;\\nrefractionColor=texture2D(refraction2DSampler,refractionCoords);\\n#endif\\n#ifdef RGBDREFRACTION\\nrefractionColor.rgb=fromRGBD(refractionColor);\\n#endif\\n#ifdef IS_REFRACTION_LINEAR\\nrefractionColor.rgb=toGammaSpace(refractionColor.rgb);\\n#endif\\nrefractionColor.rgb*=vRefractionInfos.x;\\n#endif\\n\\nvec4 reflectionColor=vec4(0.,0.,0.,1.);\\n#ifdef REFLECTION\\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\\n#ifdef REFLECTIONMAP_3D\\n#ifdef ROUGHNESS\\nfloat bias=vReflectionInfos.y;\\n#ifdef SPECULARTERM\\n#ifdef SPECULAR\\n#ifdef GLOSSINESS\\nbias*=(1.0-specularMapColor.a);\\n#endif\\n#endif\\n#endif\\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);\\n#else\\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);\\n#endif\\n#else\\nvec2 coords=vReflectionUVW.xy;\\n#ifdef REFLECTIONMAP_PROJECTION\\ncoords/=vReflectionUVW.z;\\n#endif\\ncoords.y=1.0-coords.y;\\nreflectionColor=texture2D(reflection2DSampler,coords);\\n#endif\\n#ifdef RGBDREFLECTION\\nreflectionColor.rgb=fromRGBD(reflectionColor);\\n#endif\\n#ifdef IS_REFLECTION_LINEAR\\nreflectionColor.rgb=toGammaSpace(reflectionColor.rgb);\\n#endif\\nreflectionColor.rgb*=vReflectionInfos.x;\\n#ifdef REFLECTIONFRESNEL\\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\\n#ifdef REFLECTIONFRESNELFROMSPECULAR\\n#ifdef SPECULARTERM\\nreflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\\n#else\\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\\n#endif\\n#else\\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\\n#endif\\n#endif\\n#endif\\n#ifdef REFRACTIONFRESNEL\\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\\nrefractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\\n#endif\\n#ifdef OPACITY\\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\\n#ifdef OPACITYRGB\\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\\n#else\\nalpha*=opacityMap.a*vOpacityInfos.y;\\n#endif\\n#endif\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n#ifdef OPACITYFRESNEL\\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\\n#endif\\n#ifdef ALPHATEST\\n#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS\\nif (alpha\\n#include\\n\\n\\n#ifdef IMAGEPROCESSINGPOSTPROCESS\\ncolor.rgb=toLinearSpace(color.rgb);\\n#else\\n#ifdef IMAGEPROCESSING\\ncolor.rgb=toLinearSpace(color.rgb);\\ncolor=applyImageProcessing(color);\\n#endif\\n#endif\\ncolor.a*=visibility;\\n#ifdef PREMULTIPLYALPHA\\n\\ncolor.rgb*=color.a;\\n#endif\\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\\n#ifdef PREPASS\\ngl_FragData[0]=color;\\n#ifdef PREPASS_POSITION\\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);\\n#endif\\n#ifdef PREPASS_VELOCITY\\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\\nvec2 velocity=abs(a-b);\\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\\n#endif\\n#ifdef PREPASS_IRRADIANCE\\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,1.0);\\n#endif\\n#ifdef PREPASS_DEPTHNORMAL\\ngl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);\\n#endif\\n#ifdef PREPASS_ALBEDO\\ngl_FragData[PREPASS_ALBEDO_INDEX]=vec4(0.0,0.0,0.0,1.0);\\n#endif\\n#ifdef PREPASS_REFLECTIVITY\\n#if defined(SPECULAR)\\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=specularMapColor;\\n#else\\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);\\n#endif\\n#endif\\n#endif\\n#if !defined(PREPASS) || defined(WEBGL2)\\ngl_FragColor=color;\\n#endif\\n}\\n\";b.a.ShadersStore.defaultPixelShader=E;var S=\"\\nuniform mat4 viewProjection;\\nuniform mat4 view;\\n#ifdef DIFFUSE\\nuniform mat4 diffuseMatrix;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#ifdef AMBIENT\\nuniform mat4 ambientMatrix;\\nuniform vec2 vAmbientInfos;\\n#endif\\n#ifdef OPACITY\\nuniform mat4 opacityMatrix;\\nuniform vec2 vOpacityInfos;\\n#endif\\n#ifdef EMISSIVE\\nuniform vec2 vEmissiveInfos;\\nuniform mat4 emissiveMatrix;\\n#endif\\n#ifdef LIGHTMAP\\nuniform vec2 vLightmapInfos;\\nuniform mat4 lightmapMatrix;\\n#endif\\n#if defined(SPECULAR) && defined(SPECULARTERM)\\nuniform vec2 vSpecularInfos;\\nuniform mat4 specularMatrix;\\n#endif\\n#ifdef BUMP\\nuniform vec3 vBumpInfos;\\nuniform mat4 bumpMatrix;\\n#endif\\n#ifdef REFLECTION\\nuniform mat4 reflectionMatrix;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\";b.a.IncludesShadersStore.defaultVertexDeclaration=S;i(78),i(79),i(163),i(164),i(117),i(137),i(93),i(94),i(100),i(80),i(81),i(165),i(156),i(111),i(157),i(138);b.a.IncludesShadersStore.pointCloudVertex=\"#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\";i(158);var A=\"#include<__decl__defaultVertex>\\n\\n#define CUSTOM_VERTEX_BEGIN\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef TANGENT\\nattribute vec4 tangent;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n#include\\n\\n#include\\n#include\\n#ifdef MAINUV1\\nvarying vec2 vMainUV1;\\n#endif\\n#ifdef MAINUV2\\nvarying vec2 vMainUV2;\\n#endif\\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\\nvarying vec2 vDiffuseUV;\\n#endif\\n#if defined(DETAIL) && DETAILDIRECTUV == 0\\nvarying vec2 vDetailUV;\\n#endif\\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\\nvarying vec2 vAmbientUV;\\n#endif\\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\\nvarying vec2 vOpacityUV;\\n#endif\\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\\nvarying vec2 vEmissiveUV;\\n#endif\\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\\nvarying vec2 vLightmapUV;\\n#endif\\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\\nvarying vec2 vSpecularUV;\\n#endif\\n#if defined(BUMP) && BUMPDIRECTUV == 0\\nvarying vec2 vBumpUV;\\n#endif\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include[0..maxSimultaneousMorphTargets]\\n#ifdef REFLECTIONMAP_SKYBOX\\nvarying vec3 vPositionUVW;\\n#endif\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvarying vec3 vDirectionW;\\n#endif\\n#include\\n#define CUSTOM_VERTEX_DEFINITIONS\\nvoid main(void) {\\n#define CUSTOM_VERTEX_MAIN_BEGIN\\nvec3 positionUpdated=position;\\n#ifdef NORMAL\\nvec3 normalUpdated=normal;\\n#endif\\n#ifdef TANGENT\\nvec4 tangentUpdated=tangent;\\n#endif\\n#ifdef UV1\\nvec2 uvUpdated=uv;\\n#endif\\n#include[0..maxSimultaneousMorphTargets]\\n#ifdef REFLECTIONMAP_SKYBOX\\nvPositionUVW=positionUpdated;\\n#endif\\n#define CUSTOM_VERTEX_UPDATE_POSITION\\n#define CUSTOM_VERTEX_UPDATE_NORMAL\\n#include\\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\\n\\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\\n#endif\\n#include\\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\\n#ifdef NORMAL\\nmat3 normalWorld=mat3(finalWorld);\\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\\nvNormalW=normalize(normalWorld*vNormalW);\\n#else\\n#ifdef NONUNIFORMSCALING\\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\\n#endif\\nvNormalW=normalize(normalWorld*normalUpdated);\\n#endif\\n#endif\\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\\n#ifdef MULTIVIEW\\nif (gl_ViewID_OVR == 0u) {\\ngl_Position=viewProjection*worldPos;\\n} else {\\ngl_Position=viewProjectionR*worldPos;\\n}\\n#else\\ngl_Position=viewProjection*worldPos;\\n#endif\\nvPositionW=vec3(worldPos);\\n#include\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uvUpdated=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef MAINUV1\\nvMainUV1=uvUpdated;\\n#endif\\n#ifdef MAINUV2\\nvMainUV2=uv2;\\n#endif\\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\\nif (vDiffuseInfos.x == 0.)\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(DETAIL) && DETAILDIRECTUV == 0\\nif (vDetailInfos.x == 0.)\\n{\\nvDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\\nif (vAmbientInfos.x == 0.)\\n{\\nvAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\\nif (vOpacityInfos.x == 0.)\\n{\\nvOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\\nif (vEmissiveInfos.x == 0.)\\n{\\nvEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\\nif (vLightmapInfos.x == 0.)\\n{\\nvLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\\nif (vSpecularInfos.x == 0.)\\n{\\nvSpecularUV=vec2(specularMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(BUMP) && BUMPDIRECTUV == 0\\nif (vBumpInfos.x == 0.)\\n{\\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#include\\n#include\\n#include\\n#include[0..maxSimultaneousLights]\\n#ifdef VERTEXCOLOR\\n\\nvColor=color;\\n#endif\\n#include\\n#include\\n#define CUSTOM_VERTEX_MAIN_END\\n}\\n\";b.a.ShadersStore.defaultVertexShader=A;var P=i(2),C=i(67),R=i(92),x={effect:null,subMesh:null},O=function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.DETAIL=!1,t.DETAILDIRECTUV=0,t.DETAIL_NORMALBLENDMETHOD=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.BONETEXTURE=!1,t.BONES_VELOCITY_ENABLED=!1,t.INSTANCES=!1,t.THIN_INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.OBJECTSPACE_NORMALMAP=!1,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_UV=!1,t.NUM_MORPH_INFLUENCERS=0,t.NONUNIFORMSCALING=!1,t.PREMULTIPLYALPHA=!1,t.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,t.ALPHABLEND=!0,t.PREPASS=!1,t.PREPASS_IRRADIANCE=!1,t.PREPASS_IRRADIANCE_INDEX=-1,t.PREPASS_ALBEDO=!1,t.PREPASS_ALBEDO_INDEX=-1,t.PREPASS_DEPTHNORMAL=!1,t.PREPASS_DEPTHNORMAL_INDEX=-1,t.PREPASS_POSITION=!1,t.PREPASS_POSITION_INDEX=-1,t.PREPASS_VELOCITY=!1,t.PREPASS_VELOCITY_INDEX=-1,t.PREPASS_REFLECTIVITY=!1,t.PREPASS_REFLECTIVITY_INDEX=-1,t.SCENE_MRT_COUNT=0,t.RGBDLIGHTMAP=!1,t.RGBDREFLECTION=!1,t.RGBDREFRACTION=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.MULTIVIEW=!1,t.IS_REFLECTION_LINEAR=!1,t.IS_REFRACTION_LINEAR=!1,t.EXPOSURE=!1,t.rebuild(),t}return Object(n.d)(t,e),t.prototype.setReflectionMode=function(e){for(var t=0,i=[\"REFLECTIONMAP_CUBIC\",\"REFLECTIONMAP_EXPLICIT\",\"REFLECTIONMAP_PLANAR\",\"REFLECTIONMAP_PROJECTION\",\"REFLECTIONMAP_PROJECTION\",\"REFLECTIONMAP_SKYBOX\",\"REFLECTIONMAP_SPHERICAL\",\"REFLECTIONMAP_EQUIRECTANGULAR\",\"REFLECTIONMAP_EQUIRECTANGULAR_FIXED\",\"REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\"];t0,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===m.a.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,o.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case m.a.EXPLICIT_MODE:o.setReflectionMode(\"REFLECTIONMAP_EXPLICIT\");break;case m.a.PLANAR_MODE:o.setReflectionMode(\"REFLECTIONMAP_PLANAR\");break;case m.a.PROJECTION_MODE:o.setReflectionMode(\"REFLECTIONMAP_PROJECTION\");break;case m.a.SKYBOX_MODE:o.setReflectionMode(\"REFLECTIONMAP_SKYBOX\");break;case m.a.SPHERICAL_MODE:o.setReflectionMode(\"REFLECTIONMAP_SPHERICAL\");break;case m.a.EQUIRECTANGULAR_MODE:o.setReflectionMode(\"REFLECTIONMAP_EQUIRECTANGULAR\");break;case m.a.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode(\"REFLECTIONMAP_EQUIRECTANGULAR_FIXED\");break;case m.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode(\"REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\");break;case m.a.CUBIC_MODE:case m.a.INVCUBIC_MODE:default:o.setReflectionMode(\"REFLECTIONMAP_CUBIC\")}o.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else o.REFLECTION=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._emissiveTexture,o,\"EMISSIVE\")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._lightmapTexture,o,\"LIGHTMAP\"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,o.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else o.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._specularTexture,o,\"SPECULAR\"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(r.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;_.a.PrepareDefinesForMergedUV(this._bumpTexture,o,\"BUMP\"),o.PARALLAX=this._useParallax,o.PARALLAXOCCLUSION=this._useParallaxOcclusion,o.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else o.BUMP=!1;if(this._refractionTexture&&t.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;o._needUVs=!0,o.REFRACTION=!0,o.REFRACTIONMAP_3D=this._refractionTexture.isCube,o.RGBDREFRACTION=this._refractionTexture.isRGBD}else o.REFRACTION=!1;o.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else o.DIFFUSE=!1,o.AMBIENT=!1,o.OPACITY=!1,o.REFLECTION=!1,o.EMISSIVE=!1,o.LIGHTMAP=!1,o.BUMP=!1,o.REFRACTION=!1;o.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),o.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,o.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,o.SPECULAROVERALPHA=this._useSpecularOverAlpha,o.PREMULTIPLYALPHA=this.alphaMode===P.a.ALPHA_PREMULTIPLIED||this.alphaMode===P.a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,o.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(!this.detailMap.isReadyForSubMesh(o,r))return!1;if(o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(o._areFresnelDirty&&(t.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(o.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,o.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,o.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,o.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,o.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,o.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,o._needNormals=!0,o.FRESNEL=!0):o.FRESNEL=!1),_.a.PrepareDefinesForMisc(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,o),_.a.PrepareDefinesForAttributes(e,o,!0,!0,!0),_.a.PrepareDefinesForFrameBoundValues(r,a,o,n,null,i.getRenderingMesh().hasThinInstances),this.detailMap.prepareDefines(o,r),o.isDirty){var s=o._areLightsDisposed;o.markAsProcessed();var c=new C.a;o.REFLECTION&&c.addFallback(0,\"REFLECTION\"),o.SPECULAR&&c.addFallback(0,\"SPECULAR\"),o.BUMP&&c.addFallback(0,\"BUMP\"),o.PARALLAX&&c.addFallback(1,\"PARALLAX\"),o.PARALLAXOCCLUSION&&c.addFallback(0,\"PARALLAXOCCLUSION\"),o.SPECULAROVERALPHA&&c.addFallback(0,\"SPECULAROVERALPHA\"),o.FOG&&c.addFallback(1,\"FOG\"),o.POINTSIZE&&c.addFallback(0,\"POINTSIZE\"),o.LOGARITHMICDEPTH&&c.addFallback(0,\"LOGARITHMICDEPTH\"),_.a.HandleFallbacksForShadows(o,c,this._maxSimultaneousLights),o.SPECULARTERM&&c.addFallback(0,\"SPECULARTERM\"),o.DIFFUSEFRESNEL&&c.addFallback(1,\"DIFFUSEFRESNEL\"),o.OPACITYFRESNEL&&c.addFallback(2,\"OPACITYFRESNEL\"),o.REFLECTIONFRESNEL&&c.addFallback(3,\"REFLECTIONFRESNEL\"),o.EMISSIVEFRESNEL&&c.addFallback(4,\"EMISSIVEFRESNEL\"),o.FRESNEL&&c.addFallback(4,\"FRESNEL\"),o.MULTIVIEW&&c.addFallback(0,\"MULTIVIEW\");var d=[l.b.PositionKind];o.NORMAL&&d.push(l.b.NormalKind),o.UV1&&d.push(l.b.UVKind),o.UV2&&d.push(l.b.UV2Kind),o.VERTEXCOLOR&&d.push(l.b.ColorKind),_.a.PrepareAttributesForBones(d,e,o,c),_.a.PrepareAttributesForInstances(d,o),_.a.PrepareAttributesForMorphTargets(d,e,o);var f=\"default\",p=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vAmbientColor\",\"vDiffuseColor\",\"vSpecularColor\",\"vEmissiveColor\",\"visibility\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vDiffuseInfos\",\"vAmbientInfos\",\"vOpacityInfos\",\"vReflectionInfos\",\"vEmissiveInfos\",\"vSpecularInfos\",\"vBumpInfos\",\"vLightmapInfos\",\"vRefractionInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"diffuseMatrix\",\"ambientMatrix\",\"opacityMatrix\",\"reflectionMatrix\",\"emissiveMatrix\",\"specularMatrix\",\"bumpMatrix\",\"normalMatrix\",\"lightmapMatrix\",\"refractionMatrix\",\"diffuseLeftColor\",\"diffuseRightColor\",\"opacityParts\",\"reflectionLeftColor\",\"reflectionRightColor\",\"emissiveLeftColor\",\"emissiveRightColor\",\"refractionLeftColor\",\"refractionRightColor\",\"vReflectionPosition\",\"vReflectionSize\",\"logarithmicDepthConstant\",\"vTangentSpaceParams\",\"alphaCutOff\",\"boneTextureWidth\"],g=[\"diffuseSampler\",\"ambientSampler\",\"opacitySampler\",\"reflectionCubeSampler\",\"reflection2DSampler\",\"emissiveSampler\",\"specularSampler\",\"bumpSampler\",\"lightmapSampler\",\"refractionCubeSampler\",\"refraction2DSampler\",\"boneSampler\"],v=[\"Material\",\"Scene\"];R.a.AddUniforms(p),R.a.AddSamplers(g),u.a.AddUniforms(p),u.a.AddSamplers(p),h.a&&(h.a.PrepareUniforms(p,o),h.a.PrepareSamplers(g,o)),_.a.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:v,samplers:g,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var b={};this.customShaderNameResolve&&(f=this.customShaderNameResolve(f,p,v,g,o,d,b));var y=o.toString(),T=i.effect,E=r.getEngine().createEffect(f,{attributes:d,uniformsNames:p,uniformBuffersNames:v,samplers:g,defines:y,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS},processFinalCode:b.processFinalCode,multiTarget:o.PREPASS},a);if(E)if(this._onEffectCreatedObservable&&(x.effect=E,x.subMesh=i,this._onEffectCreatedObservable.notifyObservers(x)),this.allowShaderHotSwapping&&T&&!E.isReady()){if(E=T,this._rebuildInParallel=!0,o.markAsUnprocessed(),s)return o._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,r.resetCachedMaterial(),i.setEffect(E,o),this.buildUniformLayout()}return!(!i.effect||!i.effect.isReady())&&(o._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,!0)},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform(\"diffuseLeftColor\",4),e.addUniform(\"diffuseRightColor\",4),e.addUniform(\"opacityParts\",4),e.addUniform(\"reflectionLeftColor\",4),e.addUniform(\"reflectionRightColor\",4),e.addUniform(\"refractionLeftColor\",4),e.addUniform(\"refractionRightColor\",4),e.addUniform(\"emissiveLeftColor\",4),e.addUniform(\"emissiveRightColor\",4),e.addUniform(\"vDiffuseInfos\",2),e.addUniform(\"vAmbientInfos\",2),e.addUniform(\"vOpacityInfos\",2),e.addUniform(\"vReflectionInfos\",2),e.addUniform(\"vReflectionPosition\",3),e.addUniform(\"vReflectionSize\",3),e.addUniform(\"vEmissiveInfos\",2),e.addUniform(\"vLightmapInfos\",2),e.addUniform(\"vSpecularInfos\",2),e.addUniform(\"vBumpInfos\",3),e.addUniform(\"diffuseMatrix\",16),e.addUniform(\"ambientMatrix\",16),e.addUniform(\"opacityMatrix\",16),e.addUniform(\"reflectionMatrix\",16),e.addUniform(\"emissiveMatrix\",16),e.addUniform(\"lightmapMatrix\",16),e.addUniform(\"specularMatrix\",16),e.addUniform(\"bumpMatrix\",16),e.addUniform(\"vTangentSpaceParams\",2),e.addUniform(\"pointSize\",1),e.addUniform(\"refractionMatrix\",16),e.addUniform(\"vRefractionInfos\",4),e.addUniform(\"vSpecularColor\",4),e.addUniform(\"vEmissiveColor\",3),e.addUniform(\"visibility\",1),e.addUniform(\"vDiffuseColor\",4),R.a.PrepareUniformBuffer(e),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture(\"reflection2DSampler\",null),t=!0),this._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture(\"refraction2DSampler\",null),t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,i,n){var r=this.getScene(),o=n._materialDefines;if(o){var s=n.effect;if(s){this._activeEffect=s,o.INSTANCES&&!o.THIN_INSTANCES||this.bindOnlyWorldMatrix(e),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,i,e,this.isFrozen),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var l=this._mustRebind(r,s,i.visibility);_.a.BindBonesParameters(i,s);var u=this._uniformBuffer;if(l){if(u.bindToEffect(s,\"Material\"),this.bindViewProjection(s),!u.useUbo||!this.isFrozen||!u.isSync){if(t.FresnelEnabled&&o.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(u.updateColor4(\"diffuseLeftColor\",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),u.updateColor4(\"diffuseRightColor\",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&u.updateColor4(\"opacityParts\",new c.a(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(u.updateColor4(\"reflectionLeftColor\",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),u.updateColor4(\"reflectionRightColor\",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(u.updateColor4(\"refractionLeftColor\",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),u.updateColor4(\"refractionRightColor\",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(u.updateColor4(\"emissiveLeftColor\",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),u.updateColor4(\"emissiveRightColor\",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),r.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(u.updateFloat2(\"vDiffuseInfos\",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),_.a.BindTextureMatrix(this._diffuseTexture,u,\"diffuse\")),this._ambientTexture&&t.AmbientTextureEnabled&&(u.updateFloat2(\"vAmbientInfos\",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),_.a.BindTextureMatrix(this._ambientTexture,u,\"ambient\")),this._opacityTexture&&t.OpacityTextureEnabled&&(u.updateFloat2(\"vOpacityInfos\",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),_.a.BindTextureMatrix(this._opacityTexture,u,\"opacity\")),this._hasAlphaChannel()&&s.setFloat(\"alphaCutOff\",this.alphaCutOff),this._reflectionTexture&&t.ReflectionTextureEnabled&&(u.updateFloat2(\"vReflectionInfos\",this._reflectionTexture.level,this.roughness),u.updateMatrix(\"reflectionMatrix\",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var h=this._reflectionTexture;u.updateVector3(\"vReflectionPosition\",h.boundingBoxPosition),u.updateVector3(\"vReflectionSize\",h.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(u.updateFloat2(\"vEmissiveInfos\",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),_.a.BindTextureMatrix(this._emissiveTexture,u,\"emissive\")),this._lightmapTexture&&t.LightmapTextureEnabled&&(u.updateFloat2(\"vLightmapInfos\",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),_.a.BindTextureMatrix(this._lightmapTexture,u,\"lightmap\")),this._specularTexture&&t.SpecularTextureEnabled&&(u.updateFloat2(\"vSpecularInfos\",this._specularTexture.coordinatesIndex,this._specularTexture.level),_.a.BindTextureMatrix(this._specularTexture,u,\"specular\")),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(u.updateFloat3(\"vBumpInfos\",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),_.a.BindTextureMatrix(this._bumpTexture,u,\"bump\"),r._mirroredCameraPosition?u.updateFloat2(\"vTangentSpaceParams\",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):u.updateFloat2(\"vTangentSpaceParams\",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var d=1;this._refractionTexture.isCube||(u.updateMatrix(\"refractionMatrix\",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(d=this._refractionTexture.depth)),u.updateFloat4(\"vRefractionInfos\",this._refractionTexture.level,this.indexOfRefraction,d,this.invertRefractionY?-1:1)}}this.pointsCloud&&u.updateFloat(\"pointSize\",this.pointSize),o.SPECULARTERM&&u.updateColor4(\"vSpecularColor\",this.specularColor,this.specularPower),u.updateColor3(\"vEmissiveColor\",t.EmissiveTextureEnabled?this.emissiveColor:c.a.BlackReadOnly),u.updateColor4(\"vDiffuseColor\",this.diffuseColor,this.alpha)}if(u.updateFloat(\"visibility\",i.visibility),r.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&s.setTexture(\"diffuseSampler\",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&s.setTexture(\"ambientSampler\",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&s.setTexture(\"opacitySampler\",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?s.setTexture(\"reflectionCubeSampler\",this._reflectionTexture):s.setTexture(\"reflection2DSampler\",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&s.setTexture(\"emissiveSampler\",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&s.setTexture(\"lightmapSampler\",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&s.setTexture(\"specularSampler\",this._specularTexture),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&s.setTexture(\"bumpSampler\",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled)){d=1;this._refractionTexture.isCube?s.setTexture(\"refractionCubeSampler\",this._refractionTexture):s.setTexture(\"refraction2DSampler\",this._refractionTexture)}this.detailMap.bindForSubMesh(u,r,this.isFrozen),_.a.BindClipPlane(s,r),r.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),_.a.BindEyePosition(s,r),s.setColor3(\"vAmbientColor\",this._globalAmbientColor)}!l&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&_.a.BindLights(r,i,s,o,this._maxSimultaneousLights,this._rebuildInParallel),(r.fogEnabled&&i.applyFog&&r.fogMode!==a.a.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(s),_.a.BindFogParameters(r,i,s),o.NUM_MORPH_INFLUENCERS&&_.a.BindMorphTargetParameters(i,s),this.useLogarithmicDepth&&_.a.BindLogDepth(o,s,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),u.update(),this._afterBind(i,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this.detailMap.getAnimatables(e),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._specularTexture&&t.push(this._specularTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),this.detailMap.getActiveTextures(t),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._emissiveTexture===t||(this._specularTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||(this._refractionTexture===t||this.detailMap.hasTexture(t))))))))))},t.prototype.dispose=function(t,i){var n,r,o,a,s,c,l,u,h;i&&(null===(n=this._diffuseTexture)||void 0===n||n.dispose(),null===(r=this._ambientTexture)||void 0===r||r.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(a=this._reflectionTexture)||void 0===a||a.dispose(),null===(s=this._emissiveTexture)||void 0===s||s.dispose(),null===(c=this._specularTexture)||void 0===c||c.dispose(),null===(l=this._bumpTexture)||void 0===l||l.dispose(),null===(u=this._lightmapTexture)||void 0===u||u.dispose(),null===(h=this._refractionTexture)||void 0===h||h.dispose()),this.detailMap.dispose(i),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.prototype.clone=function(e){var i=this,n=r.a.Clone((function(){return new t(e,i.getScene())}),this);return n.name=e,n.id=e,n},t.prototype.serialize=function(){return r.a.Serialize(this)},t.Parse=function(e,i,n){return r.a.Parse((function(){return new t(e.name,i)}),e,i,n)},Object.defineProperty(t,\"DiffuseTextureEnabled\",{get:function(){return v.a.DiffuseTextureEnabled},set:function(e){v.a.DiffuseTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"DetailTextureEnabled\",{get:function(){return v.a.DetailTextureEnabled},set:function(e){v.a.DetailTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"AmbientTextureEnabled\",{get:function(){return v.a.AmbientTextureEnabled},set:function(e){v.a.AmbientTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"OpacityTextureEnabled\",{get:function(){return v.a.OpacityTextureEnabled},set:function(e){v.a.OpacityTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"ReflectionTextureEnabled\",{get:function(){return v.a.ReflectionTextureEnabled},set:function(e){v.a.ReflectionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"EmissiveTextureEnabled\",{get:function(){return v.a.EmissiveTextureEnabled},set:function(e){v.a.EmissiveTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"SpecularTextureEnabled\",{get:function(){return v.a.SpecularTextureEnabled},set:function(e){v.a.SpecularTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"BumpTextureEnabled\",{get:function(){return v.a.BumpTextureEnabled},set:function(e){v.a.BumpTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"LightmapTextureEnabled\",{get:function(){return v.a.LightmapTextureEnabled},set:function(e){v.a.LightmapTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"RefractionTextureEnabled\",{get:function(){return v.a.RefractionTextureEnabled},set:function(e){v.a.RefractionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"ColorGradingTextureEnabled\",{get:function(){return v.a.ColorGradingTextureEnabled},set:function(e){v.a.ColorGradingTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"FresnelEnabled\",{get:function(){return v.a.FresnelEnabled},set:function(e){v.a.FresnelEnabled=e},enumerable:!1,configurable:!0}),Object(n.c)([Object(r.m)(\"diffuseTexture\")],t.prototype,\"_diffuseTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesAndMiscDirty\")],t.prototype,\"diffuseTexture\",void 0),Object(n.c)([Object(r.m)(\"ambientTexture\")],t.prototype,\"_ambientTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"ambientTexture\",void 0),Object(n.c)([Object(r.m)(\"opacityTexture\")],t.prototype,\"_opacityTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesAndMiscDirty\")],t.prototype,\"opacityTexture\",void 0),Object(n.c)([Object(r.m)(\"reflectionTexture\")],t.prototype,\"_reflectionTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionTexture\",void 0),Object(n.c)([Object(r.m)(\"emissiveTexture\")],t.prototype,\"_emissiveTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"emissiveTexture\",void 0),Object(n.c)([Object(r.m)(\"specularTexture\")],t.prototype,\"_specularTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"specularTexture\",void 0),Object(n.c)([Object(r.m)(\"bumpTexture\")],t.prototype,\"_bumpTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"bumpTexture\",void 0),Object(n.c)([Object(r.m)(\"lightmapTexture\")],t.prototype,\"_lightmapTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"lightmapTexture\",void 0),Object(n.c)([Object(r.m)(\"refractionTexture\")],t.prototype,\"_refractionTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"refractionTexture\",void 0),Object(n.c)([Object(r.e)(\"ambient\")],t.prototype,\"ambientColor\",void 0),Object(n.c)([Object(r.e)(\"diffuse\")],t.prototype,\"diffuseColor\",void 0),Object(n.c)([Object(r.e)(\"specular\")],t.prototype,\"specularColor\",void 0),Object(n.c)([Object(r.e)(\"emissive\")],t.prototype,\"emissiveColor\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"specularPower\",void 0),Object(n.c)([Object(r.c)(\"useAlphaFromDiffuseTexture\")],t.prototype,\"_useAlphaFromDiffuseTexture\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesAndMiscDirty\")],t.prototype,\"useAlphaFromDiffuseTexture\",void 0),Object(n.c)([Object(r.c)(\"useEmissiveAsIllumination\")],t.prototype,\"_useEmissiveAsIllumination\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useEmissiveAsIllumination\",void 0),Object(n.c)([Object(r.c)(\"linkEmissiveWithDiffuse\")],t.prototype,\"_linkEmissiveWithDiffuse\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"linkEmissiveWithDiffuse\",void 0),Object(n.c)([Object(r.c)(\"useSpecularOverAlpha\")],t.prototype,\"_useSpecularOverAlpha\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useSpecularOverAlpha\",void 0),Object(n.c)([Object(r.c)(\"useReflectionOverAlpha\")],t.prototype,\"_useReflectionOverAlpha\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useReflectionOverAlpha\",void 0),Object(n.c)([Object(r.c)(\"disableLighting\")],t.prototype,\"_disableLighting\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(n.c)([Object(r.c)(\"useObjectSpaceNormalMap\")],t.prototype,\"_useObjectSpaceNormalMap\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useObjectSpaceNormalMap\",void 0),Object(n.c)([Object(r.c)(\"useParallax\")],t.prototype,\"_useParallax\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useParallax\",void 0),Object(n.c)([Object(r.c)(\"useParallaxOcclusion\")],t.prototype,\"_useParallaxOcclusion\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useParallaxOcclusion\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"parallaxScaleBias\",void 0),Object(n.c)([Object(r.c)(\"roughness\")],t.prototype,\"_roughness\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"roughness\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"indexOfRefraction\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"invertRefractionY\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"alphaCutOff\",void 0),Object(n.c)([Object(r.c)(\"useLightmapAsShadowmap\")],t.prototype,\"_useLightmapAsShadowmap\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useLightmapAsShadowmap\",void 0),Object(n.c)([Object(r.h)(\"diffuseFresnelParameters\")],t.prototype,\"_diffuseFresnelParameters\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsFresnelDirty\")],t.prototype,\"diffuseFresnelParameters\",void 0),Object(n.c)([Object(r.h)(\"opacityFresnelParameters\")],t.prototype,\"_opacityFresnelParameters\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsFresnelAndMiscDirty\")],t.prototype,\"opacityFresnelParameters\",void 0),Object(n.c)([Object(r.h)(\"reflectionFresnelParameters\")],t.prototype,\"_reflectionFresnelParameters\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsFresnelDirty\")],t.prototype,\"reflectionFresnelParameters\",void 0),Object(n.c)([Object(r.h)(\"refractionFresnelParameters\")],t.prototype,\"_refractionFresnelParameters\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsFresnelDirty\")],t.prototype,\"refractionFresnelParameters\",void 0),Object(n.c)([Object(r.h)(\"emissiveFresnelParameters\")],t.prototype,\"_emissiveFresnelParameters\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsFresnelDirty\")],t.prototype,\"emissiveFresnelParameters\",void 0),Object(n.c)([Object(r.c)(\"useReflectionFresnelFromSpecular\")],t.prototype,\"_useReflectionFresnelFromSpecular\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsFresnelDirty\")],t.prototype,\"useReflectionFresnelFromSpecular\",void 0),Object(n.c)([Object(r.c)(\"useGlossinessFromSpecularMapAlpha\")],t.prototype,\"_useGlossinessFromSpecularMapAlpha\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useGlossinessFromSpecularMapAlpha\",void 0),Object(n.c)([Object(r.c)(\"maxSimultaneousLights\")],t.prototype,\"_maxSimultaneousLights\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),Object(n.c)([Object(r.c)(\"invertNormalMapX\")],t.prototype,\"_invertNormalMapX\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"invertNormalMapX\",void 0),Object(n.c)([Object(r.c)(\"invertNormalMapY\")],t.prototype,\"_invertNormalMapY\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"invertNormalMapY\",void 0),Object(n.c)([Object(r.c)(\"twoSidedLighting\")],t.prototype,\"_twoSidedLighting\",void 0),Object(n.c)([Object(r.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"twoSidedLighting\",void 0),Object(n.c)([Object(r.c)()],t.prototype,\"useLogarithmicDepth\",null),t}(p.a);g.a.RegisteredTypes[\"BABYLON.StandardMaterial\"]=M,a.a.DefaultMaterialFactory=function(e){return new M(\"default material\",e)}},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return S}));var n=i(1),r=i(12),o=i(6),a=i(0),s=i(13),c=i(4),l=i(16),u=i(46),h=i(54),d=i(43),f=i(2),p=i(147),_=i(21),m=i(101),g=i(9),v=i(28),b=i(23),y=i(11),T=function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=a.e.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1},E=function(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new T,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=null,this._currentLODIsUpToDate=!1},S=function(e){function t(i,n){void 0===n&&(n=null);var r=e.call(this,i,n,!1)||this;return r._internalAbstractMeshDataInfo=new E,r.cullingStrategy=t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,r.onCollideObservable=new o.c,r.onCollisionPositionChangeObservable=new o.c,r.onMaterialChangedObservable=new o.c,r.definedFacingForward=!0,r._occlusionQuery=null,r._renderingGroup=null,r.alphaIndex=Number.MAX_VALUE,r.isVisible=!0,r.isPickable=!0,r.showSubMeshesBoundingBox=!1,r.isBlocker=!1,r.enablePointerMoveEvents=!1,r._renderingGroupId=0,r._material=null,r.outlineColor=g.a.Red(),r.outlineWidth=.02,r.overlayColor=g.a.Red(),r.overlayAlpha=.5,r.useOctreeForRenderingSelection=!0,r.useOctreeForPicking=!0,r.useOctreeForCollisions=!0,r.alwaysSelectAsActiveMesh=!1,r.doNotSyncBoundingInfo=!1,r.actionManager=null,r._meshCollisionData=new p.a,r.ellipsoid=new a.e(.5,1,.5),r.ellipsoidOffset=new a.e(0,0,0),r.edgesWidth=1,r.edgesColor=new g.b(1,0,0,1),r._edgesRenderer=null,r._masterMesh=null,r._boundingInfo=null,r._renderId=0,r._intersectionsInProgress=new Array,r._unIndexed=!1,r._lightSources=new Array,r._waitingData={lods:null,actions:null,freezeWorldMatrix:null},r._bonesTransformMatrices=null,r._transformMatrixTexture=null,r.onRebuildObservable=new o.c,r._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),t.subtractToRef(r._meshCollisionData._oldPositionForCollisions,r._meshCollisionData._diffPositionForCollisions),r._meshCollisionData._diffPositionForCollisions.length()>s.a.CollisionsEpsilon&&r.position.addInPlace(r._meshCollisionData._diffPositionForCollisions),i&&r.onCollideObservable.notifyObservers(i),r.onCollisionPositionChangeObservable.notifyObservers(r.position)},r.getScene().addMesh(r),r._resyncLightSources(),r}return Object(n.d)(t,e),Object.defineProperty(t,\"BILLBOARDMODE_NONE\",{get:function(){return u.a.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"BILLBOARDMODE_X\",{get:function(){return u.a.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"BILLBOARDMODE_Y\",{get:function(){return u.a.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"BILLBOARDMODE_Z\",{get:function(){return u.a.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"BILLBOARDMODE_ALL\",{get:function(){return u.a.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"BILLBOARDMODE_USE_POSITION\",{get:function(){return u.a.BILLBOARDMODE_USE_POSITION},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"facetNb\",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"partitioningSubdivisions\",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"partitioningBBoxRatio\",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"mustDepthSortFacets\",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"facetDepthSortFrom\",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"isFacetDataEnabled\",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,configurable:!0}),t.prototype._updateNonUniformScalingState=function(t){return!!e.prototype._updateNonUniformScalingState.call(this,t)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(t.prototype,\"onCollide\",{set:function(e){this._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver),this._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"onCollisionPositionChange\",{set:function(e){this._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver),this._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"visibility\",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){this._internalAbstractMeshDataInfo._visibility!==e&&(this._internalAbstractMeshDataInfo._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"renderingGroupId\",{get:function(){return this._renderingGroupId},set:function(e){this._renderingGroupId=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"material\",{get:function(){return this._material},set:function(e){this._material!==e&&(this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&this._unBindEffect())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"receiveShadows\",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"hasVertexAlpha\",{get:function(){return this._internalAbstractMeshDataInfo._hasVertexAlpha},set:function(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"useVertexColors\",{get:function(){return this._internalAbstractMeshDataInfo._useVertexColors},set:function(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"computeBonesUsingShaders\",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"numBoneInfluencers\",{get:function(){return this._internalAbstractMeshDataInfo._numBoneInfluencers},set:function(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"applyFog\",{get:function(){return this._internalAbstractMeshDataInfo._applyFog},set:function(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"layerMask\",{get:function(){return this._internalAbstractMeshDataInfo._layerMask},set:function(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"collisionMask\",{get:function(){return this._meshCollisionData._collisionMask},set:function(e){this._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"collisionResponse\",{get:function(){return this._meshCollisionData._collisionResponse},set:function(e){this._meshCollisionData._collisionResponse=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"collisionGroup\",{get:function(){return this._meshCollisionData._collisionGroup},set:function(e){this._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"surroundingMeshes\",{get:function(){return this._meshCollisionData._surroundingMeshes},set:function(e){this._meshCollisionData._surroundingMeshes=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"lightSources\",{get:function(){return this._lightSources},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"_positions\",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"skeleton\",{get:function(){return this._internalAbstractMeshDataInfo._skeleton},set:function(e){var t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"AbstractMesh\"},t.prototype.toString=function(e){var t=\"Name: \"+this.name+\", isInstance: \"+(\"InstancedMesh\"!==this.getClassName()?\"YES\":\"NO\");t+=\", # of submeshes: \"+(this.subMeshes?this.subMeshes.length:0);var i=this._internalAbstractMeshDataInfo._skeleton;return i&&(t+=\", skeleton: \"+i.name),e&&(t+=\", billboard mode: \"+[\"NONE\",\"X\",\"Y\",null,\"Z\",null,null,\"ALL\"][this.billboardMode],t+=\", freeze wrld mat: \"+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?\"YES\":\"NO\")),t},t.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==u.a.BILLBOARDMODE_NONE?this._masterMesh:e.prototype._getEffectiveParent.call(this)},t.prototype._getActionManagerForTrigger=function(e,t){if(void 0===t&&(t=!0),this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},t.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var e=0,t=this.subMeshes;e4,s=o?this.getVerticesData(c.b.MatricesIndicesExtraKind):null,l=o?this.getVerticesData(c.b.MatricesWeightsExtraKind):null;this.skeleton.prepare();for(var u=this.skeleton.getTransformMatrices(this),h=a.c.Vector3[0],d=a.c.Matrix[0],f=a.c.Matrix[1],p=0,_=0;_0&&(a.a.FromFloat32ArrayToRefScaled(u,Math.floor(16*i[p+m]),g,f),d.addToSelf(f));if(o)for(m=0;m<4;m++)(g=l[p+m])>0&&(a.a.FromFloat32ArrayToRefScaled(u,Math.floor(16*s[p+m]),g,f),d.addToSelf(f));a.e.TransformCoordinatesFromFloatsToRef(t[_],t[_+1],t[_+2],d,h),h.toArray(t,_),this._positions&&this._positions[_/3].copyFrom(h)}}}return t},t.prototype._updateBoundingInfo=function(){var e=this._effectiveMesh;return this._boundingInfo?this._boundingInfo.update(e.worldMatrixFromCache):this._boundingInfo=new d.a(this.absolutePosition,this.absolutePosition,e.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(e.worldMatrixFromCache),this},t.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var t=this.subMeshes.length,i=0;i1||!n.IsGlobal)&&n.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||this._updateBoundingInfo()},Object.defineProperty(t.prototype,\"_effectiveMesh\",{get:function(){return this.skeleton&&this.skeleton.overrideMesh||this},enumerable:!1,configurable:!0}),t.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isCompletelyInFrustum(e)},t.prototype.intersectsMesh=function(e,t,i){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(i)for(var n=0,r=this.getChildMeshes();n1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},t.prototype._checkCollision=function(e){if(!this._boundingInfo||!this._boundingInfo._checkCollision(e))return this;var t=a.c.Matrix[0],i=a.c.Matrix[1];return a.a.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this},t.prototype._generatePointsArray=function(){return!1},t.prototype.intersects=function(e,t,i,n,r,o){var s;void 0===n&&(n=!1),void 0===o&&(o=!1);var c=new h.a,l=\"InstancedLinesMesh\"===this.getClassName()||\"LinesMesh\"===this.getClassName()?this.intersectionThreshold:0,u=this._boundingInfo;if(!this.subMeshes||!u)return c;if(!(o||e.intersectsSphere(u.boundingSphere,l)&&e.intersectsBox(u.boundingBox,l)))return c;if(n)return c.hit=!o,c.pickedMesh=o?null:this,c.distance=o?0:a.e.Distance(e.origin,u.boundingSphere.center),c.subMeshId=0,c;if(!this._generatePointsArray())return c;for(var d=null,p=this._scene.getIntersectingSubMeshCandidates(this,e),_=p.length,m=!1,g=0;g<_;g++){var v=(b=p.data[g]).getMaterial();if(v&&((null===(s=this.getIndices())||void 0===s?void 0:s.length)&&(v.fillMode==f.a.MATERIAL_TriangleStripDrawMode||v.fillMode==f.a.MATERIAL_TriangleFillMode||v.fillMode==f.a.MATERIAL_WireFrameFillMode||v.fillMode==f.a.MATERIAL_PointFillMode))){m=!0;break}}if(!m)return c.hit=!0,c.pickedMesh=this,c.distance=a.e.Distance(e.origin,u.boundingSphere.center),c.subMeshId=-1,c;for(g=0;g<_;g++){var b=p.data[g];if(!(_>1)||b.canIntersects(e)){var y=b.intersects(e,this._positions,this.getIndices(),t,i);if(y&&(t||!d||y.distance65535){o=!0;break}e.depthSortedIndices=o?new Uint32Array(i):new Uint16Array(i)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var u=this.getScene().activeCamera;e.facetDepthSortFrom=u?u.position:a.e.Zero()}e.depthSortedFacets=[];for(var h=0;hv.a?r.maximum.x-r.minimum.x:v.a,e.bbSize.y=r.maximum.y-r.minimum.y>v.a?r.maximum.y-r.minimum.y:v.a,e.bbSize.z=r.maximum.z-r.minimum.z>v.a?r.maximum.z-r.minimum.z:v.a;var f=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(f=f>e.bbSize.z?f:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/f),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/f),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/f),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=r,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),a.e.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,l.a.ComputeNormals(t,i,n,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var p=e.depthSortedIndices.length/3|0;for(h=0;hr.subDiv.max||a<0||a>r.subDiv.max||s<0||s>r.subDiv.max?null:r.facetPartitioning[o+r.subDiv.max*a+r.subDiv.max*r.subDiv.max*s]},t.prototype.getClosestFacetAtCoordinates=function(e,t,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0);var s=this.getWorldMatrix(),c=a.c.Matrix[5];s.invertToRef(c);var l=a.c.Vector3[8];a.e.TransformCoordinatesFromFloatsToRef(e,t,i,c,l);var u=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,n,r,o);return n&&a.e.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,s,n),u},t.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0);var a=null,s=0,c=0,l=0,u=0,h=0,d=0,f=0,p=0,_=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,i);if(!g)return null;for(var v,b,y,T=Number.MAX_VALUE,E=T,S=0;S=0||r&&!o&&u<=0)&&(u=b.x*y.x+b.y*y.y+b.z*y.z,h=-(b.x*e+b.y*t+b.z*i-u)/(b.x*b.x+b.y*b.y+b.z*b.z),(E=(s=(d=e+b.x*h)-e)*s+(c=(f=t+b.y*h)-t)*c+(l=(p=i+b.z*h)-i)*l)100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=o.b.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new o.b),this._options.mass=void 0===i.mass?0:i.mass,this._options.friction=void 0===i.friction?.2:i.friction,this._options.restitution=void 0===i.restitution?.2:i.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=void 0===i.pressure?200:i.pressure,this._options.stiffness=void 0===i.stiffness?1:i.stiffness,this._options.velocityIterations=void 0===i.velocityIterations?20:i.velocityIterations,this._options.positionIterations=void 0===i.positionIterations?20:i.positionIterations,this._options.fixedPoints=void 0===i.fixedPoints?0:i.fixedPoints,this._options.margin=void 0===i.margin?0:i.margin,this._options.damping=void 0===i.damping?0:i.damping,this._options.path=void 0===i.path?null:i.path,this._options.shape=void 0===i.shape?null:i.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&n.a.Warn(\"You must affect impostors to children before affecting impostor to parent.\")):n.a.Error(\"Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.\"))):n.a.Error(\"No object was provided. A physics object is obligatory\")}return Object.defineProperty(e.prototype,\"isDisposed\",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"mass\",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(e){this.setMass(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"friction\",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"restitution\",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"pressure\",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.setBodyPressure?e.getBodyPressure(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPressure&&t.setBodyPressure(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stiffness\",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyStiffness?e.getBodyStiffness(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyStiffness&&t.setBodyStiffness(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"velocityIterations\",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyVelocityIterations?e.getBodyVelocityIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyVelocityIterations&&t.setBodyVelocityIterations(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"positionIterations\",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyPositionIterations?e.getBodyPositionIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPositionIterations&&t.setBodyPositionIterations(this,e)}},enumerable:!1,configurable:!0}),e.prototype._init=function(){this._physicsEngine&&(this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),this._isDisposed||this.parent&&!this._options.ignoreParent||this._physicsEngine.addImpostor(this))},e.prototype._getPhysicsParent=function(){return this.object.parent instanceof a.a?this.object.parent.physicsImpostor:null},e.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},e.prototype.setScalingUpdated=function(){this.forceUpdate()},e.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(e.prototype,\"physicsBody\",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"parent\",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion,i=this.object.scaling.clone();this.object.rotationQuaternion=e.IDENTITY_QUATERNION;var n=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);n&&n.decompose(i,void 0,void 0);var r=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(i);return this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),r}return e.DEFAULT_OBJECT_SIZE},e.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},e.prototype.getParam=function(e){return this._options[e]},e.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},e.prototype.setMass=function(e){this.getParam(\"mass\")!==e&&this.setParam(\"mass\",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},e.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):o.e.Zero()},e.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},e.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):o.e.Zero()},e.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},e.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},e.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},e.prototype.unregisterBeforePhysicsStep=function(e){var t=this._onBeforePhysicsStepCallbacks.indexOf(e);t>-1?this._onBeforePhysicsStepCallbacks.splice(t,1):n.a.Warn(\"Function to remove was not found\")},e.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},e.prototype.unregisterAfterPhysicsStep=function(e){var t=this._onAfterPhysicsStepCallbacks.indexOf(e);t>-1?this._onAfterPhysicsStepCallbacks.splice(t,1):n.a.Warn(\"Function to remove was not found\")},e.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},e.prototype.unregisterOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e],r=-1;this._onPhysicsCollideCallbacks.some((function(e,n){if(e.callback===t&&e.otherImpostors.length===i.length){var o=e.otherImpostors.every((function(e){return i.indexOf(e)>-1}));return o&&(r=n),o}return!1}))?this._onPhysicsCollideCallbacks.splice(r,1):n.a.Warn(\"Function to remove was not found\")},e.prototype.getParentsRotation=function(){var e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):o.b.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,e.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),e=e.parent;return this._tmpQuat},e.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},e.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},e.prototype.createJoint=function(e,t,i){var n=new c.e(t,i);return this.addJoint(e,n),this},e.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},e.prototype.addAnchor=function(e,t,i,n,r){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendAnchor(this,e,t,i,n,r),this):this},e.prototype.addHook=function(e,t,i,n){if(!this._physicsEngine)return this;var r=this._physicsEngine.getPhysicsPlugin();return r.appendAnchor?(this._physicsEngine&&r.appendHook(this,e,t,i,n),this):this},e.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},e.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},e.prototype.clone=function(t){return t?new e(t,this.type,this._options,this._scene):null},e.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine&&e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},e.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},e.prototype.setDeltaRotation=function(e){this._deltaRotation||(this._deltaRotation=new o.b),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()},e.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},e.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},e.prototype.syncBoneWithImpostor=function(t,i,n,r,o){var a=e._tmpVecs[0],s=this.object;if(s.rotationQuaternion)if(o){var c=e._tmpQuat;s.rotationQuaternion.multiplyToRef(o,c),t.setRotationQuaternion(c,l.c.WORLD,i)}else t.setRotationQuaternion(s.rotationQuaternion,l.c.WORLD,i);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,t.getDirectionToRef(a,i,a),null==r&&(r=n.length()),a.x*=r,a.y*=r,a.z*=r),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,i)):(i.setAbsolutePosition(s.getAbsolutePosition()),i.position.x-=a.x,i.position.y-=a.y,i.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,i,n,r,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var c=e._tmpQuat;t.getRotationQuaternionToRef(l.c.WORLD,i,c),c.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(l.c.WORLD,i,s.rotationQuaternion);var u=e._tmpVecs[0],h=e._tmpVecs[1];a||((a=e._tmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,i,h),t.getAbsolutePositionToRef(i,u),null==r&&n&&(r=n.length()),null!=r&&(u.x+=h.x*r,u.y+=h.y*r,u.z+=h.z*r),s.setAbsolutePosition(u)},e.DEFAULT_OBJECT_SIZE=new o.e(1,1,1),e.IDENTITY_QUATERNION=o.b.Identity(),e._tmpVecs=r.a.BuildArray(3,o.e.Zero),e._tmpQuat=o.b.Identity(),e.NoImpostor=0,e.SphereImpostor=1,e.BoxImpostor=2,e.PlaneImpostor=3,e.MeshImpostor=4,e.CapsuleImpostor=6,e.CylinderImpostor=7,e.ParticleImpostor=8,e.HeightmapImpostor=9,e.ConvexHullImpostor=10,e.CustomImpostor=100,e.RopeImpostor=101,e.ClothImpostor=102,e.SoftbodyImpostor=103,e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r})),i.d(t,\"b\",(function(){return o}));var n=i(1),r=function(){function e(t){this.length=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)},e.prototype.forEach=function(e){for(var t=0;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.indexOf(e)},e._GlobalId=0,e}(),o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return Object(n.d)(t,e),t.prototype.push=function(t){e.prototype.push.call(this,t),t.__smartArrayFlags||(t.__smartArrayFlags={}),t.__smartArrayFlags[this._id]=this._duplicateId},t.prototype.pushNoDuplicate=function(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)},t.prototype.reset=function(){e.prototype.reset.call(this),this._duplicateId++},t.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t>2,o=(3&t)<<4|(i=u>4,a=(15&i)<<2|(n=u>6,s=63&n,isNaN(i)?a=s=64:isNaN(n)&&(s=64),l+=c.charAt(r)+c.charAt(o)+c.charAt(a)+c.charAt(s);return l},e.PadNumber=function(e,t){for(var i=String(e);i.length0)):!i._pointerCaptures[c.pointerId]&&a.distance>s.distance&&(i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(s.pickedMesh)?(i._notifyObservers(t,s,c),t.skipOnPointerObservable=!0):i._lastPointerEvents[c.pointerId]&&(i.onPointerOutObservable.notifyObservers(c.pointerId),delete i._lastPointerEvents[c.pointerId])),t.type===o.a.POINTERUP&&i._pointerCaptures[c.pointerId]&&(i._pointerCaptures[c.pointerId]=!1))}}}})),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterCameraRenderObservable.add((function(e){i.shouldRender&&e==i.getRenderCamera()&&i.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){i.dispose()})),this._updateCamera()}return e.prototype.getRenderCamera=function(e){if(this._renderCamera)return this._renderCamera;var t=void 0;return t=this.originalScene.activeCameras&&this.originalScene.activeCameras.length>1?this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.originalScene.activeCamera,e&&t&&t.isRigCamera?t.rigParent:t},e.prototype.setRenderCamera=function(e){this._renderCamera=e},e.prototype._getSharedGizmoLight=function(){return this._sharedGizmoLight||(this._sharedGizmoLight=new s.a(\"shared gizmo light\",new c.e(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=l.a.Gray()),this._sharedGizmoLight},Object.defineProperty(e,\"DefaultUtilityLayer\",{get:function(){return null==e._DefaultUtilityLayer&&(e._DefaultUtilityLayer=new e(a.a.LastCreatedScene),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultUtilityLayer=null}))),e._DefaultUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"DefaultKeepDepthUtilityLayer\",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(a.a.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),e.prototype._notifyObservers=function(e,t,i){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(e.type,e.event,t),e.type),this._lastPointerEvents[i.pointerId]=!0)},e.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}},e.prototype.dispose=function(){this.onPointerOutObservable.clear(),this._afterRenderObserver&&this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()},e.prototype._updateCamera=function(){this.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()},e._DefaultUtilityLayer=null,e._DefaultKeepDepthUtilityLayer=null,e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r}));var n=i(139),r=function(){function e(){}return e.EnableFor=function(t){t._tags=t._tags||{},t.hasTags=function(){return e.HasTags(t)},t.addTags=function(i){return e.AddTagsTo(t,i)},t.removeTags=function(i){return e.RemoveTagsFrom(t,i)},t.matchesTagsQuery=function(i){return e.MatchesQuery(t,i)}},e.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},e.HasTags=function(e){if(!e._tags)return!1;var t=e._tags;for(var i in t)if(t.hasOwnProperty(i))return!0;return!1},e.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var n in e._tags)e._tags.hasOwnProperty(n)&&!0===e._tags[n]&&i.push(n);return i.join(\" \")}return e._tags},e.AddTagsTo=function(t,i){i&&(\"string\"==typeof i&&i.split(\" \").forEach((function(i,n,r){e._AddTagTo(t,i)})))},e._AddTagTo=function(t,i){\"\"!==(i=i.trim())&&\"true\"!==i&&\"false\"!==i&&(i.match(/[\\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(e.EnableFor(t),t._tags[i]=!0))},e.RemoveTagsFrom=function(t,i){if(e.HasTags(t)){var n=i.split(\" \");for(var r in n)e._RemoveTagFrom(t,n[r])}},e._RemoveTagFrom=function(e,t){delete e._tags[t]},e.MatchesQuery=function(t,i){return void 0===i||(\"\"===i?e.HasTags(t):n.a.Eval(i,(function(i){return e.HasTags(t)&&t._tags[i]})))},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){}return e.IsWindowObjectExist=function(){return\"undefined\"!=typeof window},e.IsNavigatorAvailable=function(){return\"undefined\"!=typeof navigator},e.IsDocumentAvailable=function(){return\"undefined\"!=typeof document},e.GetDOMTextContent=function(e){for(var t=\"\",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return l}));var n=i(44),r=i(0),o=i(54),a=i(114),s=i(20),c=i(24),l=function(){function e(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}return e.prototype.intersectsBoxMinMax=function(t,i,n){void 0===n&&(n=0);var r,o,a,s,c=e._TmpVector3[0].copyFromFloats(t.x-n,t.y-n,t.z-n),l=e._TmpVector3[1].copyFromFloats(i.x+n,i.y+n,i.z+n),u=0,h=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xl.x)return!1}else if(r=1/this.direction.x,o=(c.x-this.origin.x)*r,(a=(l.x-this.origin.x)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yl.y)return!1}else if(r=1/this.direction.y,o=(c.y-this.origin.y)*r,(a=(l.y-this.origin.y)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zl.z)return!1}else if(r=1/this.direction.z,o=(c.z-this.origin.z)*r,(a=(l.z-this.origin.z)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;return!0},e.prototype.intersectsBox=function(e,t){return void 0===t&&(t=0),this.intersectsBoxMinMax(e.minimum,e.maximum,t)},e.prototype.intersectsSphere=function(e,t){void 0===t&&(t=0);var i=e.center.x-this.origin.x,n=e.center.y-this.origin.y,r=e.center.z-this.origin.z,o=i*i+n*n+r*r,a=e.radius+t,s=a*a;if(o<=s)return!0;var c=i*this.direction.x+n*this.direction.y+r*this.direction.z;return!(c<0)&&o-c*c<=s},e.prototype.intersectsTriangle=function(t,i,n){var o=e._TmpVector3[0],s=e._TmpVector3[1],c=e._TmpVector3[2],l=e._TmpVector3[3],u=e._TmpVector3[4];i.subtractToRef(t,o),n.subtractToRef(t,s),r.e.CrossToRef(this.direction,s,c);var h=r.e.Dot(o,c);if(0===h)return null;var d=1/h;this.origin.subtractToRef(t,l);var f=r.e.Dot(l,c)*d;if(f<0||f>1)return null;r.e.CrossToRef(l,o,u);var p=r.e.Dot(this.direction,u)*d;if(p<0||f+p>1)return null;var _=r.e.Dot(s,u)*d;return _>this.length?null:new a.a(1-f-p,f,_)},e.prototype.intersectsPlane=function(e){var t,i=r.e.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var n=r.e.Dot(e.normal,this.origin);return(t=(-e.d-n)/i)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case\"y\":return(i=(this.origin.y-t)/this.direction.y)>0?null:new r.e(this.origin.x+this.direction.x*-i,t,this.origin.z+this.direction.z*-i);case\"x\":return(i=(this.origin.x-t)/this.direction.x)>0?null:new r.e(t,this.origin.y+this.direction.y*-i,this.origin.z+this.direction.z*-i);case\"z\":var i;return(i=(this.origin.z-t)/this.direction.z)>0?null:new r.e(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t);default:return null}},e.prototype.intersectsMesh=function(t,i){var n=r.c.Matrix[0];return t.getWorldMatrix().invertToRef(n),this._tmpRay?e.TransformToRef(this,n,this._tmpRay):this._tmpRay=e.Transform(this,n),t.intersects(this._tmpRay,i)},e.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var n=0;nt.distance?1:0},e.prototype.intersectionSegment=function(t,i,n){var o=this.origin,a=r.c.Vector3[0],s=r.c.Vector3[1],c=r.c.Vector3[2],l=r.c.Vector3[3];i.subtractToRef(t,a),this.direction.scaleToRef(e.rayl,c),o.addToRef(c,s),t.subtractToRef(o,l);var u,h,d,f,p=r.e.Dot(a,a),_=r.e.Dot(a,c),m=r.e.Dot(c,c),g=r.e.Dot(a,l),v=r.e.Dot(c,l),b=p*m-_*_,y=b,T=b;by&&(h=y,f=v+_,T=m)),f<0?(f=0,-g<0?h=0:-g>p?h=y:(h=-g,y=p)):f>T&&(f=T,-g+_<0?h=0:-g+_>p?h=y:(h=-g+_,y=p)),u=Math.abs(h)0&&d<=this.length&&A.lengthSquared()=e.distance?null:l:null},s.a.prototype._internalPick=function(e,t,i,n,a){if(!o.a)return null;for(var s=null,c=0;c0&&(t.push(s-1),t.push(s)),s++}var d=new o.a;return d.indices=t,d.positions=i,r&&(d.colors=a),d},o.a.CreateDashedLines=function(e){var t,i,r=e.dashSize||3,a=e.gapSize||1,s=e.dashNb||200,c=e.points,l=new Array,u=new Array,h=n.e.Zero(),d=0,f=0,p=0,_=0,m=0;for(m=0;m0)if(\"object\"==typeof u[0])for(var d=0;dl.max||l.min>c.max)},d=function(){function e(e,t,i){this._isLocked=!1,this.boundingBox=new a.a(e,t,i),this.boundingSphere=new s.a(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)},Object.defineProperty(e.prototype,\"minimum\",{get:function(){return this.boundingBox.minimum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"maximum\",{get:function(){return this.boundingBox.maximum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isLocked\",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!1,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,i){var n=e.TmpVector3[0].copyFrom(t).subtractInPlace(i),r=e.TmpVector3[1].copyFrom(t).addInPlace(i);return this.boundingBox.reConstruct(n,r,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(n,r,this.boundingBox.getWorldMatrix()),this},e.prototype.scale=function(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this},e.prototype.isInFrustum=function(e,t){return void 0===t&&(t=o.a.MESHES_CULLINGSTRATEGY_STANDARD),!(t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(t!==o.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||this.boundingBox.isInFrustum(e))},Object.defineProperty(e.prototype,\"diagonalLength\",{get:function(){var t=this.boundingBox;return t.maximumWorld.subtractToRef(t.minimumWorld,e.TmpVector3[0]).length()},enumerable:!1,configurable:!0}),e.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},e.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},e.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},e.prototype.intersects=function(e,t){if(!s.a.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!a.a.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var i=this.boundingBox,n=e.boundingBox;return!!h(i.directions[0],i,n)&&(!!h(i.directions[1],i,n)&&(!!h(i.directions[2],i,n)&&(!!h(n.directions[0],i,n)&&(!!h(n.directions[1],i,n)&&(!!h(n.directions[2],i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[1]),i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[2]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[1]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[2]),i,n)&&(!!h(r.e.Cross(i.directions[2],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[2],n.directions[1]),i,n)&&!!h(r.e.Cross(i.directions[2],n.directions[2]),i,n))))))))))))))},e.TmpVector3=n.a.BuildArray(2,r.e.Zero),e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){}return e.BuildArray=function(e,t){for(var i=[],n=0;n1)?1:e.arc||1,c=e.slice&&e.slice<=0?1:e.slice||1,l=0===e.sideOrientation?0:e.sideOrientation||o.a.DEFAULTSIDE,u=!!e.dedupTopBottomIndices,h=new n.e(i/2,r/2,a/2),d=2+t,f=2*d,p=[],_=[],m=[],g=[],v=0;v<=d;v++){for(var b=v/d,y=b*Math.PI*c,T=0;T<=f;T++){var E=T/f,S=E*Math.PI*2*s,A=n.a.RotationZ(-y),P=n.a.RotationY(S),C=n.e.TransformCoordinates(n.e.Up(),A),R=n.e.TransformCoordinates(C,P),x=R.multiply(h),O=R.divide(h).normalize();_.push(x.x,x.y,x.z),m.push(O.x,O.y,O.z),g.push(E,b)}if(v>0)for(var M=_.length/3,I=M-2*(f+1);I+f+21&&(p.push(I),p.push(I+1),p.push(I+f+1)),(v0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},t.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var n=0,r=this.getScene().meshes;n0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((function(t){e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(t){e.includedOnlyMeshesIds.push(t.id)}))),r.a.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.GetConstructorFromName=function(e,t,i){var n=s.a.Construct(\"Light_Type_\"+e,t,i);return n||null},t.Parse=function(e,i){var n=t.GetConstructorFromName(e.type,e.name,i);if(!n)return null;var o=r.a.Parse(n,e,i);if(e.excludedMeshesIds&&(o._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(o._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId&&(o._waitingParentId=e.parentId),void 0!==e.falloffType&&(o.falloffType=e.falloffType),void 0!==e.lightmapMode&&(o.lightmapMode=e.lightmapMode),e.animations){for(var a=0;a=0&&this._scene.textures.splice(t,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),e.prototype.dispose.call(this)},t.prototype.serialize=function(){if(!this.name)return null;var e=r.a.Serialize(this);return r.a.AppendSerializedAnimations(this,e),e},t.WhenAllReady=function(e,t){var i=e.length;if(0!==i)for(var n=0;n1)?1:e.arc||1,m=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,g=e.faceUV||new Array(3),v=e.faceColors,b=2+(1+(1!==_&&f?2:0))*(d?h:1);for(l=0;l1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e}()},function(e,t,i){\"use strict\";i.d(t,\"b\",(function(){return f})),i.d(t,\"d\",(function(){return p})),i.d(t,\"c\",(function(){return _})),i.d(t,\"a\",(function(){return m}));var n=i(1),r=i(49),o=i(38),a=i(6),s=i(83),c=i(140),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),u=i(34),h=i(26),d=i(128),f=function(e){function t(i,n){var o=e.call(this,i)||this;return o.name=\"LoadFileError\",l._setPrototypeOf(o,t.prototype),n instanceof r.a?o.request=n:o.file=n,o}return Object(n.d)(t,e),t}(l),p=function(e){function t(i,n){var r=e.call(this,i)||this;return r.request=n,r.name=\"RequestFileError\",l._setPrototypeOf(r,t.prototype),r}return Object(n.d)(t,e),t}(l),_=function(e){function t(i,n){var r=e.call(this,i)||this;return r.file=n,r.name=\"ReadFileError\",l._setPrototypeOf(r,t.prototype),r}return Object(n.d)(t,e),t}(l),m=function(){function e(){}return e._CleanUrl=function(e){return e=e.replace(/#/gm,\"%23\")},e.SetCorsBehavior=function(t,i){if((!t||0!==t.indexOf(\"data:\"))&&e.CorsBehavior)if(\"string\"==typeof e.CorsBehavior||this.CorsBehavior instanceof String)i.crossOrigin=e.CorsBehavior;else{var n=e.CorsBehavior(t);n&&(i.crossOrigin=n)}},e.LoadImage=function(t,i,n,r,o){var a;void 0===o&&(o=\"\");var c=!1;if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)?\"undefined\"!=typeof Blob?(a=URL.createObjectURL(new Blob([t],{type:o})),c=!0):a=\"data:\"+o+\";base64,\"+u.a.EncodeArrayBufferToBase64(t):t instanceof Blob?(a=URL.createObjectURL(t),c=!0):(a=e._CleanUrl(t),a=e.PreprocessUrl(t)),\"undefined\"==typeof Image)return e.LoadFile(a,(function(e){createImageBitmap(new Blob([e],{type:o})).then((function(e){i(e),c&&URL.revokeObjectURL(a)})).catch((function(e){n&&n(\"Error while trying to load image: \"+t,e)}))}),void 0,r||void 0,!0,(function(e,i){n&&n(\"Error while trying to load image: \"+t,i)})),null;var l=new Image;e.SetCorsBehavior(a,l);var h=function(){l.removeEventListener(\"load\",h),l.removeEventListener(\"error\",d),i(l),c&&l.src&&URL.revokeObjectURL(l.src)},d=function(e){if(l.removeEventListener(\"load\",h),l.removeEventListener(\"error\",d),n){var i=t.toString();n(\"Error while trying to load image: \"+(i.length<32?i:i.slice(0,32)+\"...\"),e)}c&&l.src&&URL.revokeObjectURL(l.src)};l.addEventListener(\"load\",h),l.addEventListener(\"error\",d);var f=function(){l.src=a};if(\"data:\"!==a.substr(0,5)&&r&&r.enableTexturesOffline)r.open((function(){r&&r.loadImage(a,l)}),f);else{if(-1!==a.indexOf(\"file:\")){var p=decodeURIComponent(a.substring(5).toLowerCase());if(s.a.FilesToLoad[p]){try{var _;try{_=URL.createObjectURL(s.a.FilesToLoad[p])}catch(e){_=URL.createObjectURL(s.a.FilesToLoad[p])}l.src=_,c=!0}catch(e){l.src=\"\"}return l}}f()}return l},e.ReadFile=function(e,t,i,n,r){var o=new FileReader,s={onCompleteObservable:new a.c,abort:function(){return o.abort()}};return o.onloadend=function(e){return s.onCompleteObservable.notifyObservers(s)},r&&(o.onerror=function(t){r(new _(\"Unable to read \"+e.name,e))}),o.onload=function(e){t(e.target.result)},i&&(o.onprogress=i),n?o.readAsArrayBuffer(e):o.readAsText(e),s},e.LoadFile=function(t,i,n,r,o,a){if(-1!==t.indexOf(\"file:\")){var c=decodeURIComponent(t.substring(5).toLowerCase());0===c.indexOf(\"./\")&&(c=c.substring(2));var l=s.a.FilesToLoad[c];if(l)return e.ReadFile(l,i,n,o,a?function(e){return a(void 0,new f(e.message,e.file))}:void 0)}return e.RequestFile(t,(function(e,t){i(e,t?t.responseURL:void 0)}),n,r,o,a?function(e){a(e.request,new f(e.message,e.request))}:void 0)},e.RequestFile=function(t,i,n,s,c,l,u){t=e._CleanUrl(t),t=e.PreprocessUrl(t);var h=e.BaseUrl+t,d=!1,f={onCompleteObservable:new a.c,abort:function(){return d=!0}},_=function(){var t=new r.a,a=null;f.abort=function(){d=!0,t.readyState!==(XMLHttpRequest.DONE||4)&&t.abort(),null!==a&&(clearTimeout(a),a=null)};var s=function(_){t.open(\"GET\",h),u&&u(t),c&&(t.responseType=\"arraybuffer\"),n&&t.addEventListener(\"progress\",n);var m=function(){t.removeEventListener(\"loadend\",m),f.onCompleteObservable.notifyObservers(f),f.onCompleteObservable.clear()};t.addEventListener(\"loadend\",m);var g=function(){if(!d&&t.readyState===(XMLHttpRequest.DONE||4)){if(t.removeEventListener(\"readystatechange\",g),t.status>=200&&t.status<300||0===t.status&&(!o.a.IsWindowObjectExist()||e.IsFileURL()))return void i(c?t.response:t.responseText,t);var n=e.DefaultRetryStrategy;if(n){var u=n(h,t,_);if(-1!==u)return t.removeEventListener(\"loadend\",m),t=new r.a,void(a=setTimeout((function(){return s(_+1)}),u))}var f=new p(\"Error status: \"+t.status+\" \"+t.statusText+\" - Unable to load \"+h,t);l&&l(f)}};t.addEventListener(\"readystatechange\",g),t.send()};s(0)};if(s&&s.enableSceneOffline){var m=function(e){e&&e.status>400?l&&l(e):_()};s.open((function(){s&&s.loadFile(e.BaseUrl+t,(function(e){d||i(e),f.onCompleteObservable.notifyObservers(f)}),n?function(e){d||n(e)}:void 0,m,c)}),m)}else _();return f},e.IsFileURL=function(){return\"undefined\"!=typeof location&&\"file:\"===location.protocol},e.DefaultRetryStrategy=c.a.ExponentialBackoff(),e.BaseUrl=\"\",e.CorsBehavior=\"anonymous\",e.PreprocessUrl=function(e){return e},e}();h.a._FileToolsLoadImage=m.LoadImage.bind(m),h.a._FileToolsLoadFile=m.LoadFile.bind(m),d.a._FileToolsLoadFile=m.LoadFile.bind(m)},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r}));var n=i(38),r=function(){function e(){}return Object.defineProperty(e,\"Now\",{get:function(){return n.a.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!1,configurable:!0}),e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(e,t,i,n){this.x=e,this.y=t,this.width=i,this.height=n}return e.prototype.toGlobal=function(t,i){return new e(this.x*t,this.y*i,this.width*t,this.height*i)},e.prototype.toGlobalToRef=function(e,t,i){return i.x=this.x*e,i.y=this.y*t,i.width=this.width*e,i.height=this.height*t,this},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e}()},function(e,t,i){\"use strict\";var n=\"helperFunctions\",r=\"const float PI=3.1415926535897932384626433832795;\\nconst float HALF_MIN=5.96046448e-08;\\nconst float LinearEncodePowerApprox=2.2;\\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\\nconst float Epsilon=0.0000001;\\n#define saturate(x) clamp(x,0.0,1.0)\\n#define absEps(x) abs(x)+Epsilon\\n#define maxEps(x) max(x,Epsilon)\\n#define saturateEps(x) clamp(x,Epsilon,1.0)\\nmat3 transposeMat3(mat3 inMatrix) {\\nvec3 i0=inMatrix[0];\\nvec3 i1=inMatrix[1];\\nvec3 i2=inMatrix[2];\\nmat3 outMatrix=mat3(\\nvec3(i0.x,i1.x,i2.x),\\nvec3(i0.y,i1.y,i2.y),\\nvec3(i0.z,i1.z,i2.z)\\n);\\nreturn outMatrix;\\n}\\n\\nmat3 inverseMat3(mat3 inMatrix) {\\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\\nfloat b01=a22*a11-a12*a21;\\nfloat b11=-a22*a10+a12*a20;\\nfloat b21=a21*a10-a11*a20;\\nfloat det=a00*b01+a01*b11+a02*b21;\\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\\n}\\nfloat toLinearSpace(float color)\\n{\\nreturn pow(color,LinearEncodePowerApprox);\\n}\\nvec3 toLinearSpace(vec3 color)\\n{\\nreturn pow(color,vec3(LinearEncodePowerApprox));\\n}\\nvec4 toLinearSpace(vec4 color)\\n{\\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\\n}\\nvec3 toGammaSpace(vec3 color)\\n{\\nreturn pow(color,vec3(GammaEncodePowerApprox));\\n}\\nvec4 toGammaSpace(vec4 color)\\n{\\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\\n}\\nfloat toGammaSpace(float color)\\n{\\nreturn pow(color,GammaEncodePowerApprox);\\n}\\nfloat square(float value)\\n{\\nreturn value*value;\\n}\\nfloat pow5(float value) {\\nfloat sq=value*value;\\nreturn sq*sq*value;\\n}\\nfloat getLuminance(vec3 color)\\n{\\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\\n}\\n\\nfloat getRand(vec2 seed) {\\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\\n}\\nfloat dither(vec2 seed,float varianceAmount) {\\nfloat rand=getRand(seed);\\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\\nreturn dither;\\n}\\n\\nconst float rgbdMaxRange=255.0;\\nvec4 toRGBD(vec3 color) {\\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\\nfloat D=max(rgbdMaxRange/maxRGB,1.);\\nD=clamp(floor(D)/255.0,0.,1.);\\n\\nvec3 rgb=color.rgb*D;\\n\\nrgb=toGammaSpace(rgb);\\nreturn vec4(rgb,D);\\n}\\nvec3 fromRGBD(vec4 rgbd) {\\n\\nrgbd.rgb=toLinearSpace(rgbd.rgb);\\n\\nreturn rgbd.rgb/rgbd.a;\\n}\\n\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r}));var n=i(0),r=function(){function e(){}return e._RemoveAndStorePivotPoint=function(t){t&&0===e._PivotCached&&(t.getPivotPointToRef(e._OldPivotPoint),e._PivotPostMultiplyPivotMatrix=t._postMultiplyPivotMatrix,e._OldPivotPoint.equalsToFloats(0,0,0)||(t.setPivotMatrix(n.a.IdentityReadOnly),e._OldPivotPoint.subtractToRef(t.getPivotPoint(),e._PivotTranslation),e._PivotTmpVector.copyFromFloats(1,1,1),e._PivotTmpVector.subtractInPlace(t.scaling),e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),t.position.addInPlace(e._PivotTmpVector))),e._PivotCached++},e._RestorePivotPoint=function(t){t&&!e._OldPivotPoint.equalsToFloats(0,0,0)&&1===e._PivotCached&&(t.setPivotPoint(e._OldPivotPoint),t._postMultiplyPivotMatrix=e._PivotPostMultiplyPivotMatrix,e._PivotTmpVector.copyFromFloats(1,1,1),e._PivotTmpVector.subtractInPlace(t.scaling),e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),t.position.subtractInPlace(e._PivotTmpVector)),this._PivotCached--},e._PivotCached=0,e._OldPivotPoint=new n.e,e._PivotTranslation=new n.e,e._PivotTmpVector=new n.e,e._PivotPostMultiplyPivotMatrix=!1,e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return c}));var n=i(4),r=i(114),o=i(43),a=i(2),s=i(101),c=function(){function e(e,t,i,n,r,o,a,s,c){void 0===s&&(s=!0),void 0===c&&(c=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=n,this.indexCount=r,this._materialDefines=null,this._materialEffect=null,this._effectOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=o,this._renderingMesh=a||o,c&&o.subMeshes.push(this),this._trianglePlanes=[],this._id=o.subMeshes.length-1,s&&(this.refreshBoundingInfo(),o.computeWorldMatrix(!0))}return Object.defineProperty(e.prototype,\"materialDefines\",{get:function(){return this._materialDefines},set:function(e){this._materialDefines=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"effect\",{get:function(){var e;return null!==(e=this._effectOverride)&&void 0!==e?e:this._materialEffect},enumerable:!1,configurable:!0}),e.prototype.setEffect=function(e,t){void 0===t&&(t=null),this._materialEffect!==e?(this._materialDefines=t,this._materialEffect=e):e||(this._materialDefines=null)},e.AddToMesh=function(t,i,n,r,o,a,s,c){return void 0===c&&(c=!0),new e(t,i,n,r,o,a,s,c)},Object.defineProperty(e.prototype,\"IsGlobal\",{get:function(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()},enumerable:!1,configurable:!0}),e.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},e.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},e.prototype.getMesh=function(){return this._mesh},e.prototype.getRenderingMesh=function(){return this._renderingMesh},e.prototype.getReplacementMesh=function(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null},e.prototype.getEffectiveMesh=function(){var e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh},e.prototype.getMaterial=function(){var e=this._renderingMesh.material;if(null==e)return this._mesh.getScene().defaultMaterial;if(this._IsMultiMaterial(e)){var t=e.getSubMaterial(this.materialIndex);return this._currentMaterial!==t&&(this._currentMaterial=t,this._materialDefines=null),t}return e},e.prototype._IsMultiMaterial=function(e){return void 0!==e.getSubMaterial},e.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=null),this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(n.b.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var t,i=this._renderingMesh.getIndices();if(0===this.indexStart&&this.indexCount===i.length){var r=this._renderingMesh.getBoundingInfo();t={minimum:r.minimum.clone(),maximum:r.maximum.clone()}}else t=Object(s.b)(e,i,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(t.minimum,t.maximum):this._boundingInfo=new o.a(t.minimum,t.maximum),this},e.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},e.prototype.updateBoundingInfo=function(e){var t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this},e.prototype.isInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)},e.prototype.isCompletelyInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)},e.prototype.render=function(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this},e.prototype._getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var i=[],n=this.indexStart;ns&&(s=u)}return new e(t,a,s-a+1,i,n,r,o)},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return c}));var n=i(1),r=i(8),o=i(10),a=i(2),s=(i(126),i(70)),c=function(e){function t(t,i,n,r,c,l,u){void 0===n&&(n=null),void 0===c&&(c=a.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=a.a.TEXTUREFORMAT_RGBA);var h=e.call(this,null,n,!r,u,c,void 0,void 0,void 0,void 0,l)||this;h.name=t,h.wrapU=o.a.CLAMP_ADDRESSMODE,h.wrapV=o.a.CLAMP_ADDRESSMODE,h._generateMipMaps=r;var d=h._getEngine();if(!d)return h;i.getContext?(h._canvas=i,h._texture=d.createDynamicTexture(i.width,i.height,r,c)):(h._canvas=s.a.CreateCanvas(1,1),i.width||0===i.width?h._texture=d.createDynamicTexture(i.width,i.height,r,c):h._texture=d.createDynamicTexture(i,i,r,c));var f=h.getSize();return h._canvas.width=f.width,h._canvas.height=f.height,h._context=h._canvas.getContext(\"2d\"),h}return Object(n.d)(t,e),t.prototype.getClassName=function(){return\"DynamicTexture\"},Object.defineProperty(t.prototype,\"canRescale\",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)},t.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},t.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},t.prototype.getContext=function(){return this._context},t.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},t.prototype.update=function(e,t){void 0===t&&(t=!1),this._getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},t.prototype.drawText=function(e,t,i,n,r,o,a,s){void 0===s&&(s=!0);var c=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,c.width,c.height)),this._context.font=n,null==t){var l=this._context.measureText(e);t=(c.width-l.width)/2}if(null==i){var u=parseInt(n.replace(/\\D/g,\"\"));i=c.height/2+u/3.65}this._context.fillStyle=r||\"\",this._context.fillText(e,t,i),s&&this.update(a)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),n=new t(this.name,i,e,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.wrapU=this.wrapU,n.wrapV=this.wrapV,n},t.prototype.serialize=function(){var t=this.getScene();t&&!t.isReady()&&r.a.Warn(\"The scene must be ready before serializing the dynamic texture\");var i=e.prototype.serialize.call(this);return this._IsCanvasElement(this._canvas)&&(i.base64String=this._canvas.toDataURL()),i.invertY=this._invertY,i.samplingMode=this.samplingMode,i},t.prototype._IsCanvasElement=function(e){return void 0!==e.toDataURL},t.prototype._rebuild=function(){this.update()},t}(o.a)},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return s}));var n=i(0),r=i(9),o=i(7),a=i(16);a.a.CreateBox=function(e){var t,i=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],o=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],s=[],c=e.width||e.size||1,l=e.height||e.size||1,u=e.depth||e.size||1,h=e.wrap||!1,d=void 0===e.topBaseAt?1:e.topBaseAt,f=void 0===e.bottomBaseAt?0:e.bottomBaseAt,p=[2,0,3,1][d=(d+4)%4],_=[2,0,1,3][f=(f+4)%4],m=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(h){i=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],m=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];for(var g=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],v=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],b=[17,18,19,16],y=[22,23,20,21];p>0;)g.unshift(g.pop()),b.unshift(b.pop()),p--;for(;_>0;)v.unshift(v.pop()),y.unshift(y.pop()),_--;g=g.flat(),v=v.flat(),m=m.concat(g).concat(v),i.push(b[0],b[2],b[3],b[0],b[1],b[2]),i.push(y[0],y[2],y[3],y[0],y[1],y[2])}var T=[c/2,l/2,u/2];t=m.reduce((function(e,t,i){return e.concat(t*T[i%3])}),[]);for(var E=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,S=e.faceUV||new Array(6),A=e.faceColors,P=[],C=0;C<6;C++)void 0===S[C]&&(S[C]=new n.f(0,0,1,1)),A&&void 0===A[C]&&(A[C]=new r.b(1,1,1,1));for(var R=0;R<6;R++)if(s.push(S[R].z,S[R].w),s.push(S[R].x,S[R].w),s.push(S[R].x,S[R].y),s.push(S[R].z,S[R].y),A)for(var x=0;x<4;x++)P.push(A[R].r,A[R].g,A[R].b,A[R].a);a.a._ComputeSides(E,t,i,o,s,e.frontUVs,e.backUVs);var O=new a.a;if(O.indices=i,O.positions=t,O.normals=o,O.uvs=s,A){var M=E===a.a.DOUBLESIDE?P.concat(P):P;O.colors=M}return O},o.a.CreateBox=function(e,t,i,n,r){void 0===i&&(i=null);var o={size:t,sideOrientation:r,updatable:n};return s.CreateBox(e,o,i)};var s=function(){function e(){}return e.CreateBox=function(e,t,i){void 0===i&&(i=null);var n=new o.a(e,i);return t.sideOrientation=o.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,a.a.CreateBox(t).applyToMesh(n,t.updatable),n},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r}));var n=i(0),r=function(){function e(e,t,i,r){this.normal=new n.e(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return\"Plane\"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(0|this.d)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=e._TmpMatrix;t.invertToRef(i);var n=i.m,r=this.normal.x,o=this.normal.y,a=this.normal.z,s=this.d;return new e(r*n[0]+o*n[1]+a*n[2]+s*n[3],r*n[4]+o*n[5]+a*n[6]+s*n[7],r*n[8]+o*n[9]+a*n[10]+s*n[11],r*n[12]+o*n[13]+a*n[14]+s*n[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var n,r=t.x-e.x,o=t.y-e.y,a=t.z-e.z,s=i.x-e.x,c=i.y-e.y,l=i.z-e.z,u=o*l-a*c,h=a*s-r*l,d=r*c-o*s,f=Math.sqrt(u*u+h*h+d*d);return n=0!==f?1/f:0,this.normal.x=u*n,this.normal.y=h*n,this.normal.z=d*n,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return n.e.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return n.e.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,n){var r=new e(0,0,0,0);return r.copyFromPoints(t,i,n),r},e.FromPositionAndNormal=function(t,i){var n=new e(0,0,0,0);return i.normalize(),n.normal=i,n.d=-(i.x*t.x+i.y*t.y+i.z*t.z),n},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return n.e.Dot(i,t)+r},e._TmpMatrix=n.a.Identity(),e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return u}));var n=i(7),r=i(20),o=i(6),a=i(0),s=i(18),c=i(39),l=i(60),u=(i(84),function(){function e(e){this._useAlternatePickedPointAboveMaxDragAngleDragSpeed=-1.1,this.maxDragAngle=0,this._useAlternatePickedPointAboveMaxDragAngle=!1,this.currentDraggingPointerID=-1,this.dragging=!1,this.dragDeltaRatio=.2,this.updateDragPlane=!0,this._debugMode=!1,this._moving=!1,this.onDragObservable=new o.c,this.onDragStartObservable=new o.c,this.onDragEndObservable=new o.c,this.moveAttached=!0,this.enabled=!0,this.startAndReleaseDragOnPointerEvents=!0,this.detachCameraControls=!0,this.useObjectOrientationForDragging=!0,this.validateDrag=function(e){return!0},this._tmpVector=new a.e(0,0,0),this._alternatePickedPoint=new a.e(0,0,0),this._worldDragAxis=new a.e(0,0,0),this._targetPosition=new a.e(0,0,0),this._attachedToElement=!1,this._startDragRay=new c.a(new a.e,new a.e),this._lastPointerRay={},this._dragDelta=new a.e,this._pointA=new a.e(0,0,0),this._pointC=new a.e(0,0,0),this._localAxis=new a.e(0,0,0),this._lookAt=new a.e(0,0,0),this._options=e||{};var t=0;if(this._options.dragAxis&&t++,this._options.dragPlaneNormal&&t++,t>1)throw\"Multiple drag modes specified in dragBehavior options. Only one expected\"}return Object.defineProperty(e.prototype,\"options\",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"name\",{get:function(){return\"PointerDrag\"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t,i){var o=this;this._scene=t.getScene(),this.attachedNode=t,e._planeScene||(this._debugMode?e._planeScene=this._scene:(e._planeScene=new r.a(this._scene.getEngine(),{virtual:!0}),e._planeScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._planeScene.dispose(),e._planeScene=null})))),this._dragPlane=n.a.CreatePlane(\"pointerDragPlane\",this._debugMode?1:1e4,e._planeScene,!1,n.a.DOUBLESIDE),this.lastDragPosition=new a.e(0,0,0);var u=i||function(e){return o.attachedNode==e||e.isDescendantOf(o.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add((function(t,i){if(o.enabled)if(t.type==s.a.POINTERDOWN)o.startAndReleaseDragOnPointerEvents&&!o.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&u(t.pickInfo.pickedMesh)&&o._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint);else if(t.type==s.a.POINTERUP)o.startAndReleaseDragOnPointerEvents&&o.currentDraggingPointerID==t.event.pointerId&&o.releaseDrag();else if(t.type==s.a.POINTERMOVE){var n=t.event.pointerId;if(o.currentDraggingPointerID===e._AnyMouseID&&n!==e._AnyMouseID){var r=t.event;(\"mouse\"===r.pointerType||!o._scene.getEngine().hostInformation.isMobile&&r instanceof MouseEvent)&&(o._lastPointerRay[o.currentDraggingPointerID]&&(o._lastPointerRay[n]=o._lastPointerRay[o.currentDraggingPointerID],delete o._lastPointerRay[o.currentDraggingPointerID]),o.currentDraggingPointerID=n)}o._lastPointerRay[n]||(o._lastPointerRay[n]=new c.a(new a.e,new a.e)),t.pickInfo&&t.pickInfo.ray&&(o._lastPointerRay[n].origin.copyFrom(t.pickInfo.ray.origin),o._lastPointerRay[n].direction.copyFrom(t.pickInfo.ray.direction),o.currentDraggingPointerID==n&&o.dragging&&o._moveDrag(t.pickInfo.ray))}})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){o._moving&&o.moveAttached&&(l.a._RemoveAndStorePivotPoint(o.attachedNode),o._targetPosition.subtractToRef(o.attachedNode.absolutePosition,o._tmpVector),o._tmpVector.scaleInPlace(o.dragDeltaRatio),o.attachedNode.getAbsolutePosition().addToRef(o._tmpVector,o._tmpVector),o.validateDrag(o._tmpVector)&&o.attachedNode.setAbsolutePosition(o._tmpVector),l.a._RestorePivotPoint(o.attachedNode))}))},e.prototype.releaseDrag=function(){if(this.dragging&&(this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID})),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedToElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera){if(\"ArcRotateCamera\"===this._scene.activeCamera.getClassName()){var e=this._scene.activeCamera;e.attachControl(!e.inputs||e.inputs.noPreventDefault,e._useCtrlForPanning,e._panningMouseButton)}else this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault);this._attachedToElement=!1}},e.prototype.startDrag=function(t,i,n){void 0===t&&(t=e._AnyMouseID),this._startDrag(t,i,n);var r=this._lastPointerRay[t];t===e._AnyMouseID&&(r=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),r&&this._moveDrag(r)},e.prototype._startDrag=function(e,t,i){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){l.a._RemoveAndStorePivotPoint(this.attachedNode),t?(this._startDragRay.direction.copyFrom(t.direction),this._startDragRay.origin.copyFrom(t.origin)):(this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),this._tmpVector.subtractToRef(this._scene.activeCamera.position,this._startDragRay.direction)),this._updateDragPlanePosition(this._startDragRay,i||this._tmpVector);var n=this._pickWithRayOnDragPlane(this._startDragRay);n&&(this.dragging=!0,this.currentDraggingPointerID=e,this.lastDragPosition.copyFrom(n),this.onDragStartObservable.notifyObservers({dragPlanePoint:n,pointerId:this.currentDraggingPointerID}),this._targetPosition.copyFrom(this.attachedNode.absolutePosition),this.detachCameraControls&&this._scene.activeCamera&&this._scene.activeCamera.inputs&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedToElement?(this._scene.activeCamera.detachControl(),this._attachedToElement=!0):this._attachedToElement=!1)),l.a._RestorePivotPoint(this.attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){this.updateDragPlane&&this._updateDragPlanePosition(e,t);var i=0;this._options.dragAxis?(this.useObjectOrientationForDragging?a.e.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),i=a.e.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(i,this._dragDelta)):(i=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:i,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerID}),this.lastDragPosition.copyFrom(t)}},e.prototype._pickWithRayOnDragPlane=function(t){var i=this;if(!t)return null;var n=Math.acos(a.e.Dot(this._dragPlane.forward,t.direction));if(n>Math.PI/2&&(n=Math.PI-n),this.maxDragAngle>0&&n>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(t.direction),this.attachedNode.absolutePosition.subtractToRef(t.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed*a.e.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var r=a.e.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-r,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),this._alternatePickedPoint}return null}var o=e._planeScene.pickWithRay(t,(function(e){return e==i._dragPlane}));return o&&o.hit&&o.pickedMesh&&o.pickedPoint?o.pickedPoint:null},e.prototype._updateDragPlanePosition=function(e,t){this._pointA.copyFrom(t),this._options.dragAxis?(this.useObjectOrientationForDragging?a.e.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),e.origin.subtractToRef(this._pointA,this._pointC),this._pointC.normalize(),Math.abs(a.e.Dot(this._localAxis,this._pointC))>.999?Math.abs(a.e.Dot(a.e.UpReadOnly,this._pointC))>.999?this._lookAt.copyFrom(a.e.Right()):this._lookAt.copyFrom(a.e.UpReadOnly):(a.e.CrossToRef(this._localAxis,this._pointC,this._lookAt),a.e.CrossToRef(this._localAxis,this._lookAt,this._lookAt),this._lookAt.normalize()),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrientationForDragging?a.e.TransformCoordinatesToRef(this._options.dragPlaneNormal,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(e.origin)),this._dragPlane.position.copyFrom(this.attachedNode.absolutePosition),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this.releaseDrag()},e._AnyMouseID=-2,e}())},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r})),i.d(t,\"b\",(function(){return o})),i.d(t,\"c\",(function(){return a}));var n=i(1),r=function(){function e(){}return e.KEYDOWN=1,e.KEYUP=2,e}(),o=function(e,t){this.type=e,this.event=t},a=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.type=t,n.event=i,n.skipOnPointerObservable=!1,n}return Object(n.d)(t,e),t}(o)},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}return e.prototype.unBindMesh=function(){this._mesh=null},e.prototype.addFallback=function(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,\"hasMoreFallbacks\",{get:function(){return this._currentRank<=this._maxRank},enumerable:!1,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace(\"#define NUM_BONE_INFLUENCERS \"+this._mesh.numBoneInfluencers,\"#define NUM_BONE_INFLUENCERS 0\"),t._bonesComputationForcedToCPU=!0;for(var i=this._mesh.getScene(),n=0;n0&&(r.computeBonesUsingShaders=!1)}}else{var s=this._defines[this._currentRank];if(s)for(n=0;n=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},t.prototype.getActiveTextures=function(){var t;return(t=e.prototype.getActiveTextures.call(this)).concat.apply(t,this.subMaterials.map((function(e){return e?e.getActiveTextures():[]})))},t.prototype.hasTexture=function(t){var i;if(e.prototype.hasTexture.call(this,t))return!0;for(var n=0;n=0&&r.multiMaterials.splice(o,1),e.prototype.dispose.call(this,t,i)}},t.ParseMultiMaterial=function(e,i){var n=new t(e.name,i);n.id=e.id,o.a&&o.a.AddTagsTo(n,e.tags);for(var r=0;r0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=t),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()},e.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t0){for(var t=0;t0){for(t=0;t0){for(t=0;t0){var u=new Float32Array(t,l.positionsAttrDesc.offset,l.positionsAttrDesc.count);i.setVerticesData(a.b.PositionKind,u,!1)}if(l.normalsAttrDesc&&l.normalsAttrDesc.count>0){var h=new Float32Array(t,l.normalsAttrDesc.offset,l.normalsAttrDesc.count);i.setVerticesData(a.b.NormalKind,h,!1)}if(l.tangetsAttrDesc&&l.tangetsAttrDesc.count>0){var d=new Float32Array(t,l.tangetsAttrDesc.offset,l.tangetsAttrDesc.count);i.setVerticesData(a.b.TangentKind,d,!1)}if(l.uvsAttrDesc&&l.uvsAttrDesc.count>0){var f=new Float32Array(t,l.uvsAttrDesc.offset,l.uvsAttrDesc.count);i.setVerticesData(a.b.UVKind,f,!1)}if(l.uvs2AttrDesc&&l.uvs2AttrDesc.count>0){var p=new Float32Array(t,l.uvs2AttrDesc.offset,l.uvs2AttrDesc.count);i.setVerticesData(a.b.UV2Kind,p,!1)}if(l.uvs3AttrDesc&&l.uvs3AttrDesc.count>0){var _=new Float32Array(t,l.uvs3AttrDesc.offset,l.uvs3AttrDesc.count);i.setVerticesData(a.b.UV3Kind,_,!1)}if(l.uvs4AttrDesc&&l.uvs4AttrDesc.count>0){var m=new Float32Array(t,l.uvs4AttrDesc.offset,l.uvs4AttrDesc.count);i.setVerticesData(a.b.UV4Kind,m,!1)}if(l.uvs5AttrDesc&&l.uvs5AttrDesc.count>0){var g=new Float32Array(t,l.uvs5AttrDesc.offset,l.uvs5AttrDesc.count);i.setVerticesData(a.b.UV5Kind,g,!1)}if(l.uvs6AttrDesc&&l.uvs6AttrDesc.count>0){var v=new Float32Array(t,l.uvs6AttrDesc.offset,l.uvs6AttrDesc.count);i.setVerticesData(a.b.UV6Kind,v,!1)}if(l.colorsAttrDesc&&l.colorsAttrDesc.count>0){var b=new Float32Array(t,l.colorsAttrDesc.offset,l.colorsAttrDesc.count);i.setVerticesData(a.b.ColorKind,b,!1,l.colorsAttrDesc.stride)}if(l.matricesIndicesAttrDesc&&l.matricesIndicesAttrDesc.count>0){for(var y=new Int32Array(t,l.matricesIndicesAttrDesc.offset,l.matricesIndicesAttrDesc.count),T=[],E=0;E>8),T.push((16711680&S)>>16),T.push(S>>24&255)}i.setVerticesData(a.b.MatricesIndicesKind,T,!1)}if(l.matricesIndicesExtraAttrDesc&&l.matricesIndicesExtraAttrDesc.count>0){for(y=new Int32Array(t,l.matricesIndicesExtraAttrDesc.offset,l.matricesIndicesExtraAttrDesc.count),T=[],E=0;E>8),T.push((16711680&S)>>16),T.push(S>>24&255)}i.setVerticesData(a.b.MatricesIndicesExtraKind,T,!1)}if(l.matricesWeightsAttrDesc&&l.matricesWeightsAttrDesc.count>0){var A=new Float32Array(t,l.matricesWeightsAttrDesc.offset,l.matricesWeightsAttrDesc.count);i.setVerticesData(a.b.MatricesWeightsKind,A,!1)}if(l.indicesAttrDesc&&l.indicesAttrDesc.count>0){var P=new Int32Array(t,l.indicesAttrDesc.offset,l.indicesAttrDesc.count);i.setIndices(P,null)}if(l.subMeshesAttrDesc&&l.subMeshesAttrDesc.count>0){var C=new Int32Array(t,l.subMeshesAttrDesc.offset,5*l.subMeshesAttrDesc.count);i.subMeshes=[];for(E=0;E>8),T.push((16711680&D)>>16),T.push(D>>24&255)}i.setVerticesData(a.b.MatricesIndicesKind,T,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(a.b.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(T=[],E=0;E>8),T.push((16711680&D)>>16),T.push(D>>24&255)}i.setVerticesData(a.b.MatricesIndicesExtraKind,T,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,i),i.setVerticesData(a.b.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&i.setVerticesData(a.b.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),i.setIndices(t.indices,null)}if(t.subMeshes){i.subMeshes=[];for(var N=0;N-1){var n=t.getScene().getLastSkeletonByID(e.skeletonId);if(n){i=n.bones.length;for(var r=t.getVerticesData(a.b.MatricesIndicesKind),o=t.getVerticesData(a.b.MatricesIndicesExtraKind),s=e.matricesWeights,l=e.matricesWeightsExtra,u=e.numBoneInfluencer,h=s.length,d=0;du-1)&&(p=u-1),f>.001){var g=1/f;for(_=0;_<4;_++)s[d+_]*=g;if(l)for(_=0;_<4;_++)l[d+_]*=g}else p>=4?(l[d+p-4]=1-f,o[d+p-4]=i):(s[d+p]=1-f,r[d+p]=i)}t.setVerticesData(a.b.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(a.b.MatricesIndicesExtraKind,o)}}}},e.Parse=function(t,i,r){if(i.getGeometryByID(t.id))return null;var s=new e(t.id,i,void 0,t.updatable);return d.a&&d.a.AddTagsTo(s,t.tags),t.delayLoadingFile?(s.delayLoadState=u.a.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=r+t.delayLoadingFile,s._boundingInfo=new l.a(n.e.FromArray(t.boundingBoxMinimum),n.e.FromArray(t.boundingBoxMaximum)),s._delayInfo=[],t.hasUVs&&s._delayInfo.push(a.b.UVKind),t.hasUVs2&&s._delayInfo.push(a.b.UV2Kind),t.hasUVs3&&s._delayInfo.push(a.b.UV3Kind),t.hasUVs4&&s._delayInfo.push(a.b.UV4Kind),t.hasUVs5&&s._delayInfo.push(a.b.UV5Kind),t.hasUVs6&&s._delayInfo.push(a.b.UV6Kind),t.hasColors&&s._delayInfo.push(a.b.ColorKind),t.hasMatricesIndices&&s._delayInfo.push(a.b.MatricesIndicesKind),t.hasMatricesWeights&&s._delayInfo.push(a.b.MatricesWeightsKind),s._delayLoadingFunction=o.a.ImportVertexData):o.a.ImportVertexData(t,s),i.pushGeometry(s,!0),s},e}()},function(e,t,i){\"use strict\";i.d(t,\"e\",(function(){return n})),i.d(t,\"c\",(function(){return s})),i.d(t,\"a\",(function(){return c})),i.d(t,\"b\",(function(){return l})),i.d(t,\"f\",(function(){return u})),i.d(t,\"g\",(function(){return h})),i.d(t,\"d\",(function(){return d}));var n,r=i(14),o=i(0),a=i(28);!function(e){e[e.CW=0]=\"CW\",e[e.CCW=1]=\"CCW\"}(n||(n={}));var s=function(){function e(){}return e.Interpolate=function(e,t,i,n,r){for(var o=1-3*n+3*t,a=3*n-6*t,s=3*t,c=e,l=0;l<5;l++){var u=c*c;c-=(o*(u*c)+a*u+s*c-e)*(1/(3*o*u+2*a*c+s)),c=Math.min(1,Math.max(0,c))}return 3*Math.pow(1-c,2)*c*i+3*(1-c)*Math.pow(c,2)*r+Math.pow(c,3)},e}(),c=function(){function e(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.prototype.degrees=function(){return 180*this._radians/Math.PI},e.prototype.radians=function(){return this._radians},e.BetweenTwoPoints=function(t,i){var n=i.subtract(t);return new e(Math.atan2(n.y,n.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}(),l=function(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var r=Math.pow(t.x,2)+Math.pow(t.y,2),a=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,s=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,l=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new o.d((a*(t.y-i.y)-s*(e.y-t.y))/l,((e.x-t.x)*s-(t.x-i.x)*a)/l),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=c.BetweenTwoPoints(this.centerPoint,this.startPoint);var u=this.startAngle.degrees(),h=c.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),d=c.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-u>180&&(h-=360),h-u<-180&&(h+=360),d-h>180&&(d-=360),d-h<-180&&(d+=360),this.orientation=h-u<0?n.CW:n.CCW,this.angle=c.FromDegrees(this.orientation===n.CW?u-d:d-u)},u=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new o.d(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new o.d(e,t),n=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(n).length(),this},e.prototype.addArcTo=function(e,t,i,r,a){if(void 0===a&&(a=36),this.closed)return this;var s=this._points[this._points.length-1],c=new o.d(e,t),u=new o.d(i,r),h=new l(s,c,u),d=h.angle.radians()/a;h.orientation===n.CW&&(d*=-1);for(var f=h.startAngle.radians()+d,p=0;p1)return o.d.Zero();for(var t=e*this.length(),i=0,n=0;n=i&&t<=c){var l=s.normalize(),u=t-i;return new o.d(a.x+l.x*u,a.y+l.y*u)}i=c}return o.d.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}(),h=function(){function e(e,t,i,n){void 0===t&&(t=null),void 0===n&&(n=!1),this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array,this._pointAtData={id:0,point:o.e.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:o.a.Identity()};for(var r=0;ri){var n=t;t=i,i=n}var r=this.getCurve(),o=this.getPointAt(t),a=this.getPreviousPointIndexAt(t),s=this.getPointAt(i),c=this.getPreviousPointIndexAt(i)+1,l=[];return 0!==t&&(a++,l.push(o)),l.push.apply(l,r.slice(a,c)),1===i&&1!==t||l.push(s),new e(l,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)},e.prototype.update=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1);for(var n=0;nt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},e.prototype._normalVector=function(e,t){var i,n,s=e.length();(0===s&&(s=1),null==t)?(n=r.a.WithinEpsilon(Math.abs(e.y)/s,1,a.a)?r.a.WithinEpsilon(Math.abs(e.x)/s,1,a.a)?r.a.WithinEpsilon(Math.abs(e.z)/s,1,a.a)?o.e.Zero():new o.e(0,0,1):new o.e(1,0,0):new o.e(0,-1,0),i=o.e.Cross(e,n)):(i=o.e.Cross(e,t),o.e.CrossToRef(i,e,i));return i.normalize(),i},e.prototype._updatePointAtData=function(e,t){if(void 0===t&&(t=!1),this._pointAtData.id===e)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=e;var i=this.getPoints();if(e<=0)return this._setPointAtData(0,0,i[0],0,t);if(e>=1)return this._setPointAtData(1,1,i[i.length-1],i.length-1,t);for(var n,r=i[0],a=0,s=e*this.length(),c=1;cs){var u=(a-s)/l,h=r.subtract(n),d=n.add(h.scaleInPlace(u));return this._setPointAtData(e,1-u,d,c-1,t)}r=n}return this._pointAtData},e.prototype._setPointAtData=function(e,t,i,n,r){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=n,this._pointAtData.interpolateReady=r,r&&this._updateInterpolationMatrix(),this._pointAtData},e.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=o.a.Identity();var e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){var t=e+1,i=this._tangents[e].clone(),n=this._normals[e].clone(),r=this._binormals[e].clone(),a=this._tangents[t].clone(),s=this._normals[t].clone(),c=this._binormals[t].clone(),l=o.b.RotationQuaternionFromAxis(n,r,i),u=o.b.RotationQuaternionFromAxis(s,c,a);o.b.Slerp(l,u,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},e}(),d=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,n,r){r=r>2?r:3;for(var a=new Array,s=function(e,t,i,n){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*n},c=0;c<=r;c++)a.push(new o.e(s(c/r,t.x,i.x,n.x),s(c/r,t.y,i.y,n.y),s(c/r,t.z,i.z,n.z)));return new e(a)},e.CreateCubicBezier=function(t,i,n,r,a){a=a>3?a:4;for(var s=new Array,c=function(e,t,i,n,r){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*n+e*e*e*r},l=0;l<=a;l++)s.push(new o.e(c(l/a,t.x,i.x,n.x,r.x),c(l/a,t.y,i.y,n.y,r.y),c(l/a,t.z,i.z,n.z,r.z)));return new e(s)},e.CreateHermiteSpline=function(t,i,n,r,a){for(var s=new Array,c=1/a,l=0;l<=a;l++)s.push(o.e.Hermite(t,i,n,r,l*c));return new e(s)},e.CreateCatmullRomSpline=function(t,i,n){var r=new Array,a=1/i,s=0;if(n){for(var c=t.length,l=0;l1&&(this._multiview=!0,s.push(\"#define MULTIVIEW\"),-1!==this._options.uniforms.indexOf(\"viewProjection\")&&-1===this._options.uniforms.push(\"viewProjectionR\")&&this._options.uniforms.push(\"viewProjectionR\"));for(var h=0;h4&&(l.push(a.b.MatricesIndicesExtraKind),l.push(a.b.MatricesWeightsExtraKind));var p=e.skeleton;f=e.numBoneInfluencers,s.push(\"#define NUM_BONE_INFLUENCERS \"+f),u.addCPUSkinningFallback(0,e),p.isUsingTextureForMatrices?(s.push(\"#define BONETEXTURE\"),-1===this._options.uniforms.indexOf(\"boneTextureWidth\")&&this._options.uniforms.push(\"boneTextureWidth\"),-1===this._options.samplers.indexOf(\"boneSampler\")&&this._options.samplers.push(\"boneSampler\")):(s.push(\"#define BonesPerMesh \"+(p.bones.length+1)),-1===this._options.uniforms.indexOf(\"mBones\")&&this._options.uniforms.push(\"mBones\"))}else s.push(\"#define NUM_BONE_INFLUENCERS 0\");for(var m in this._textures)if(!this._textures[m].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&s.push(\"#define ALPHATEST\");var g=this._shaderPath,v=this._options.uniforms,b=this._options.uniformBuffers,y=this._options.samplers;this.customShaderNameResolve&&(v=v.slice(),b=b.slice(),y=y.slice(),g=this.customShaderNameResolve(g,v,b,y,s,l));var T=this._effect,E=s.join(\"\\n\");return this._cachedDefines!==E&&(this._cachedDefines=E,this._effect=o.createEffect(g,{attributes:l,uniformsNames:v,uniformBuffersNames:b,samplers:y,defines:E,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:f}},o),this._onEffectCreatedObservable&&(_.effect=this._effect,this._onEffectCreatedObservable.notifyObservers(_))),null!==(n=!(null===(i=this._effect)||void 0===i?void 0:i.isReady()))&&void 0!==n&&!n&&(T!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),this._effect._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e,t){var i=this.getScene(),n=null!=t?t:this._effect;n&&(-1!==this._options.uniforms.indexOf(\"world\")&&n.setMatrix(\"world\",e),-1!==this._options.uniforms.indexOf(\"worldView\")&&(e.multiplyToRef(i.getViewMatrix(),this._cachedWorldViewMatrix),n.setMatrix(\"worldView\",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf(\"worldViewProjection\")&&(e.multiplyToRef(i.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),n.setMatrix(\"worldViewProjection\",this._cachedWorldViewProjectionMatrix)))},t.prototype.bindForSubMesh=function(e,t,i){this.bind(e,t,i._effectOverride)},t.prototype.bind=function(e,t,i){this.bindOnlyWorldMatrix(e,i);var n=null!=i?i:this._effect;if(n&&this.getScene().getCachedMaterial()!==this){var r;for(r in-1!==this._options.uniforms.indexOf(\"view\")&&n.setMatrix(\"view\",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf(\"projection\")&&n.setMatrix(\"projection\",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf(\"viewProjection\")&&(n.setMatrix(\"viewProjection\",this.getScene().getTransformMatrix()),this._multiview&&n.setMatrix(\"viewProjectionR\",this.getScene()._transformMatrixR)),this.getScene().activeCamera&&-1!==this._options.uniforms.indexOf(\"cameraPosition\")&&n.setVector3(\"cameraPosition\",this.getScene().activeCamera.globalPosition),c.a.BindBonesParameters(t,n),this._textures)n.setTexture(r,this._textures[r]);for(r in this._textureArrays)n.setTextureArray(r,this._textureArrays[r]);for(r in this._ints)n.setInt(r,this._ints[r]);for(r in this._floats)n.setFloat(r,this._floats[r]);for(r in this._floatsArrays)n.setArray(r,this._floatsArrays[r]);for(r in this._colors3)n.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)n.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var o=this._colors4[r];n.setFloat4(r,o.r,o.g,o.b,o.a)}for(r in this._colors4Arrays)n.setArray4(r,this._colors4Arrays[r]);for(r in this._vectors2)n.setVector2(r,this._vectors2[r]);for(r in this._vectors3)n.setVector3(r,this._vectors3[r]);for(r in this._vectors4)n.setVector4(r,this._vectors4[r]);for(r in this._matrices)n.setMatrix(r,this._matrices[r]);for(r in this._matrixArrays)n.setMatrices(r,this._matrixArrays[r]);for(r in this._matrices3x3)n.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)n.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors2Arrays)n.setArray2(r,this._vectors2Arrays[r]);for(r in this._vectors3Arrays)n.setArray3(r,this._vectors3Arrays[r]);for(r in this._vectors4Arrays)n.setArray4(r,this._vectors4Arrays[r])}var a=this._effect;this._effect=n,this._afterBind(t),this._effect=a},t.prototype._afterBind=function(t){e.prototype._afterBind.call(this,t),this.getScene()._cachedEffect=this._effect},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var i in this._textures)t.push(this._textures[i]);for(var i in this._textureArrays)for(var n=this._textureArrays[i],r=0;r_.snapDistance){var t=Math.floor(Math.abs(v)/_.snapDistance);v%=_.snapDistance,e.delta.normalizeToRef(b),b.scaleInPlace(_.snapDistance*t),_.attachedNode.getWorldMatrix().addTranslationFromFloats(b.x,b.y,b.z),_.attachedNode.updateCache(),y.snapDistance=_.snapDistance*t,_.onSnapObservable.notifyObservers(y)}_._matrixChanged()}})),_.dragBehavior.onDragStartObservable.add((function(){_._dragging=!0})),_.dragBehavior.onDragEndObservable.add((function(){_._dragging=!1}));var T=a._getSharedGizmoLight();T.includedOnlyMeshes=T.includedOnlyMeshes.concat(_._rootMesh.getChildMeshes(!1));var E={gizmoMeshes:m.getChildMeshes(),colliderMeshes:g.getChildMeshes(),material:_._coloredMaterial,hoverMaterial:_._hoverMaterial,disableMaterial:_._disableMaterial,active:!1};return null===(p=_._parent)||void 0===p||p.addToAxisCache(g,E),_._pointerObserver=a.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!_._customMeshSet&&(_._isHovered=!(-1==E.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!_._parent)){var i=_._isHovered||_._dragging?_._hoverMaterial:_._coloredMaterial;E.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}})),_}return Object(n.d)(t,e),t._CreateArrow=function(e,t,i,n){void 0===i&&(i=1),void 0===n&&(n=!1);var r=new a.a(\"arrow\",e),o=c.a.CreateCylinder(\"cylinder\",{diameterTop:0,height:.075,diameterBottom:.0375*(1+(i-1)/4),tessellation:96},e),s=c.a.CreateCylinder(\"cylinder\",{diameterTop:.005*i,height:.275,diameterBottom:.005*i,tessellation:96},e);return o.parent=r,o.material=t,o.rotation.x=Math.PI/2,o.position.z+=.3,s.parent=r,s.material=t,s.position.z+=.1375,s.rotation.x=Math.PI/2,n&&(s.visibility=0,o.visibility=0),r},t._CreateArrowInstance=function(e,t){for(var i=new a.a(\"arrow\",e),n=0,r=t.getChildMeshes();n0\\n#ifdef BONETEXTURE\\nuniform sampler2D boneSampler;\\nuniform float boneTextureWidth;\\n#else\\nuniform mat4 mBones[BonesPerMesh];\\n#ifdef BONES_VELOCITY_ENABLED\\nuniform mat4 mPreviousBones[BonesPerMesh];\\n#endif\\n#endif\\nattribute vec4 matricesIndices;\\nattribute vec4 matricesWeights;\\n#if NUM_BONE_INFLUENCERS>4\\nattribute vec4 matricesIndicesExtra;\\nattribute vec4 matricesWeightsExtra;\\n#endif\\n#ifdef BONETEXTURE\\n#define inline\\nmat4 readMatrixFromRawSampler(sampler2D smp,float index)\\n{\\nfloat offset=index*4.0;\\nfloat dx=1.0/boneTextureWidth;\\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));\\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));\\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));\\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));\\nreturn mat4(m0,m1,m2,m3);\\n}\\n#endif\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"instancesDeclaration\",r=\"#ifdef INSTANCES\\nattribute vec4 world0;\\nattribute vec4 world1;\\nattribute vec4 world2;\\nattribute vec4 world3;\\n#ifdef THIN_INSTANCES\\nuniform mat4 world;\\n#endif\\n#else\\nuniform mat4 world;\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"instancesVertex\",r=\"#ifdef INSTANCES\\nmat4 finalWorld=mat4(world0,world1,world2,world3);\\n#ifdef THIN_INSTANCES\\nfinalWorld=world*finalWorld;\\n#endif\\n#else\\nmat4 finalWorld=world;\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"#if NUM_BONE_INFLUENCERS>0\\nmat4 influence;\\n#ifdef BONETEXTURE\\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\\n#if NUM_BONE_INFLUENCERS>1\\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\\n#endif\\n#if NUM_BONE_INFLUENCERS>2\\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\\n#endif\\n#if NUM_BONE_INFLUENCERS>3\\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\\n#endif\\n#if NUM_BONE_INFLUENCERS>4\\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\\n#endif\\n#if NUM_BONE_INFLUENCERS>5\\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\\n#endif\\n#if NUM_BONE_INFLUENCERS>6\\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\\n#endif\\n#if NUM_BONE_INFLUENCERS>7\\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\\n#endif\\n#else\\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\\n#if NUM_BONE_INFLUENCERS>1\\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\\n#endif\\n#if NUM_BONE_INFLUENCERS>2\\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\\n#endif\\n#if NUM_BONE_INFLUENCERS>3\\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\\n#endif\\n#if NUM_BONE_INFLUENCERS>4\\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\\n#endif\\n#if NUM_BONE_INFLUENCERS>5\\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\\n#endif\\n#if NUM_BONE_INFLUENCERS>6\\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\\n#endif\\n#if NUM_BONE_INFLUENCERS>7\\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\\n#endif\\n#endif\\nfinalWorld=finalWorld*influence;\\n#endif\";i(5).a.IncludesShadersStore.bonesVertex=n},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return c}));var n=i(0),r=i(7),o=i(4),a=i(16),s=i(43);a.a.CreateRibbon=function(e){var t=e.pathArray,i=e.closeArray||!1,n=e.closePath||!1,r=e.invertUV||!1,s=Math.floor(t[0].length/2),c=e.offset||s;c=c>s?s:Math.floor(c);var l,u,h,d,f=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,p=e.uvs,_=e.colors,m=[],g=[],v=[],b=[],y=[],T=[],E=[],S=[],A=[],P=[];if(t.length<2){var C=[],R=[];for(h=0;h0&&(M=x[d].subtract(x[d-1]).length()+E[u],y[u].push(M),E[u]=M),d++;n&&(d--,m.push(x[0].x,x[0].y,x[0].z),M=x[d].subtract(x[0]).length()+E[u],y[u].push(M),E[u]=M),A[u]=O+L,P[u]=N,N+=O+L}var w,F,B=null,U=null;for(h=0;h=n.a.ACTION_OnPickTrigger&&i<=n.a.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),e.HasSpecificTrigger=function(t){for(var i in e.Triggers){if(e.Triggers.hasOwnProperty(i))if(parseInt(i)===t)return!0}return!1},e.Triggers={},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return c}));var n=i(1),r=i(25),o=i(3),a=i(19),s=i(15),c=function(){function e(e){this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=r.a.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){var i=t.getEngine();return!(e._areTexturesDirty&&t.texturesEnabled&&i.getCaps().standardDerivatives&&this._texture&&a.a.DetailTextureEnabled&&!this._texture.isReady())},e.prototype.prepareDefines=function(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;var i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&a.a.DetailTextureEnabled&&this._isEnabled?(s.a.PrepareDefinesForMergedUV(this._texture,e,\"DETAIL\"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1},e.prototype.bindForSubMesh=function(e,t,i){this._isEnabled&&(e.useUbo&&i&&e.isSync||this._texture&&a.a.DetailTextureEnabled&&(e.updateFloat4(\"vDetailInfos\",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),s.a.BindTextureMatrix(this._texture,e,\"detail\")),t.texturesEnabled&&this._texture&&a.a.DetailTextureEnabled&&e.setTexture(\"detailSampler\",this._texture))},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){var t;e&&(null===(t=this._texture)||void 0===t||t.dispose())},e.prototype.getClassName=function(){return\"DetailMap\"},e.AddUniforms=function(e){e.push(\"vDetailInfos\")},e.AddSamplers=function(e){e.push(\"detailSampler\")},e.PrepareUniformBuffer=function(e){e.addUniform(\"vDetailInfos\",4),e.addUniform(\"detailMatrix\",16)},e.prototype.copyTo=function(e){o.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return o.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;o.a.Parse((function(){return n}),e,t,i)},Object(n.c)([Object(o.m)(\"detailTexture\"),Object(o.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"texture\",void 0),Object(n.c)([Object(o.c)()],e.prototype,\"diffuseBlendLevel\",void 0),Object(n.c)([Object(o.c)()],e.prototype,\"roughnessBlendLevel\",void 0),Object(n.c)([Object(o.c)()],e.prototype,\"bumpLevel\",void 0),Object(n.c)([Object(o.c)(),Object(o.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"normalBlendMethod\",void 0),Object(n.c)([Object(o.c)(),Object(o.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"isEnabled\",void 0),e}()},function(e,t,i){\"use strict\";var n=\"morphTargetsVertexGlobalDeclaration\",r=\"#ifdef MORPHTARGETS\\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"morphTargetsVertexDeclaration\",r=\"#ifdef MORPHTARGETS\\nattribute vec3 position{X};\\n#ifdef MORPHTARGETS_NORMAL\\nattribute vec3 normal{X};\\n#endif\\n#ifdef MORPHTARGETS_TANGENT\\nattribute vec3 tangent{X};\\n#endif\\n#ifdef MORPHTARGETS_UV\\nattribute vec2 uv_{X};\\n#endif\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return a}));var n=i(25),r=i(4),o=i(2),a=function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[r.b.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[r.b.PositionKind]=new r.b(this._scene.getEngine(),e,r.b.PositionKind,!1,!1,2),this._buildIndexBuffer()}},e.prototype._buildIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},e.prototype._rebuild=function(){var e=this._vertexBuffers[r.b.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())},e.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this._scene.activeCamera;return!!i&&(!(!(t=t||i._postProcesses.filter((function(e){return null!=e})))||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!=t),!0))},e.prototype.directRender=function(e,t,i,r,o,a){void 0===t&&(t=null),void 0===i&&(i=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1);for(var s=this._scene.getEngine(),c=0;c3?0:f,p);var C=o.a.CreateRibbon(e,{pathArray:S,closeArray:h,closePath:d,updatable:m,sideOrientation:g,invertUV:b,frontUVs:y||void 0,backUVs:T||void 0},_);return C._creationDataStorage.pathArray=S,C._creationDataStorage.path3D=E,C._creationDataStorage.cap=f,C},e}()},function(e,t,i){\"use strict\";i.d(t,\"b\",(function(){return h})),i.d(t,\"a\",(function(){return d}));var n=i(1),r=i(9),o=i(4),a=i(7),s=i(151),c=i(25),l=i(73),u=i(15),h=(i(166),i(167),function(e){function t(t,i,n,a,s,c,u){void 0===i&&(i=null),void 0===n&&(n=null),void 0===a&&(a=null);var h=e.call(this,t,i,n,a,s)||this;h.useVertexColor=c,h.useVertexAlpha=u,h.color=new r.a(1,1,1),h.alpha=1,a&&(h.color=a.color.clone(),h.alpha=a.alpha,h.useVertexColor=a.useVertexColor,h.useVertexAlpha=a.useVertexAlpha),h.intersectionThreshold=.1;var d={attributes:[o.b.PositionKind,\"world0\",\"world1\",\"world2\",\"world3\"],uniforms:[\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"world\",\"viewProjection\"],needAlphaBlending:!0,defines:[]};return!1===u&&(d.needAlphaBlending=!1),c?(d.defines.push(\"#define VERTEXCOLOR\"),d.attributes.push(o.b.ColorKind)):(d.uniforms.push(\"color\"),h.color4=new r.b),h._colorShader=new l.a(\"colorShader\",h.getScene(),\"color\",d),h}return Object(n.d)(t,e),t.prototype._addClipPlaneDefine=function(e){var t=\"#define \"+e;-1===this._colorShader.options.defines.indexOf(t)&&this._colorShader.options.defines.push(t)},t.prototype._removeClipPlaneDefine=function(e){var t=\"#define \"+e,i=this._colorShader.options.defines.indexOf(t);-1!==i&&this._colorShader.options.defines.splice(i,1)},t.prototype.isReady=function(){var t=this.getScene();return t.clipPlane?this._addClipPlaneDefine(\"CLIPPLANE\"):this._removeClipPlaneDefine(\"CLIPPLANE\"),t.clipPlane2?this._addClipPlaneDefine(\"CLIPPLANE2\"):this._removeClipPlaneDefine(\"CLIPPLANE2\"),t.clipPlane3?this._addClipPlaneDefine(\"CLIPPLANE3\"):this._removeClipPlaneDefine(\"CLIPPLANE3\"),t.clipPlane4?this._addClipPlaneDefine(\"CLIPPLANE4\"):this._removeClipPlaneDefine(\"CLIPPLANE4\"),t.clipPlane5?this._addClipPlaneDefine(\"CLIPPLANE5\"):this._removeClipPlaneDefine(\"CLIPPLANE5\"),t.clipPlane6?this._addClipPlaneDefine(\"CLIPPLANE6\"):this._removeClipPlaneDefine(\"CLIPPLANE6\"),!!this._colorShader.isReady(this)&&e.prototype.isReady.call(this)},t.prototype.getClassName=function(){return\"LinesMesh\"},Object.defineProperty(t.prototype,\"material\",{get:function(){return this._colorShader},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"checkCollisions\",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype._bind=function(e,t,i){if(!this._geometry)return this;var n=this._colorShader.getEffect(),r=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(this._geometry._bind(n,r),!this.useVertexColor){var o=this.color,a=o.r,s=o.g,c=o.b;this.color4.set(a,s,c,this.alpha),this._colorShader.setColor4(\"color\",this.color4)}return u.a.BindClipPlane(n,this.getScene()),this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var n=this.getScene().getEngine();return this._unIndexed?n.drawArraysType(c.a.LineListDrawMode,e.verticesStart,e.verticesCount,i):n.drawElementsType(c.a.LineListDrawMode,e.indexStart,e.indexCount,i),this},t.prototype.dispose=function(t){this._colorShader.dispose(!1,!1,!0),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e,i,n){return void 0===i&&(i=null),new t(e,this.getScene(),i,this,n)},t.prototype.createInstance=function(e){return new d(e,this)},t}(a.a)),d=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.intersectionThreshold=i.intersectionThreshold,n}return Object(n.d)(t,e),t.prototype.getClassName=function(){return\"InstancedLinesMesh\"},t}(s.a)},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"AxesViewer\",(function(){return c})),i.d(t,\"BoneAxesViewer\",(function(){return h})),i.d(t,\"DebugLayerTab\",(function(){return n})),i.d(t,\"DebugLayer\",(function(){return m})),i.d(t,\"PhysicsViewer\",(function(){return A})),i.d(t,\"RayHelper\",(function(){return C})),i.d(t,\"SkeletonViewer\",(function(){return N}));var n,r=i(0),o=i(30),a=i(75),s=i(9),c=function(){function e(t,i,n,c,l,u){if(void 0===i&&(i=1),void 0===n&&(n=2),this._scaleLinesFactor=4,this._instanced=!1,this.scene=null,this.scaleLines=1,this.scaleLines=i,!c){var h=new o.a(\"\",t);h.disableLighting=!0,h.emissiveColor=s.a.Red().scale(.5),c=a.a._CreateArrow(t,h)}if(!l){var d=new o.a(\"\",t);d.disableLighting=!0,d.emissiveColor=s.a.Green().scale(.5),l=a.a._CreateArrow(t,d)}if(!u){var f=new o.a(\"\",t);f.disableLighting=!0,f.emissiveColor=s.a.Blue().scale(.5),u=a.a._CreateArrow(t,f)}this._xAxis=c,this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis=l,this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis=u,this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),null!=n&&(e._SetRenderingGroupId(this._xAxis,n),e._SetRenderingGroupId(this._yAxis,n),e._SetRenderingGroupId(this._zAxis,n)),this.scene=t,this.update(new r.e,r.e.Right(),r.e.Up(),r.e.Forward())}return Object.defineProperty(e.prototype,\"xAxis\",{get:function(){return this._xAxis},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"yAxis\",{get:function(){return this._yAxis},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"zAxis\",{get:function(){return this._zAxis},enumerable:!1,configurable:!0}),e.prototype.update=function(e,t,i,n){this._xAxis.position.copyFrom(e),this._xAxis.setDirection(t),this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis.position.copyFrom(e),this._yAxis.setDirection(i),this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis.position.copyFrom(e),this._zAxis.setDirection(n),this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor)},e.prototype.createInstance=function(){var t=a.a._CreateArrowInstance(this.scene,this._xAxis),i=a.a._CreateArrowInstance(this.scene,this._yAxis),n=a.a._CreateArrowInstance(this.scene,this._zAxis),r=new e(this.scene,this.scaleLines,null,t,i,n);return r._instanced=!0,r},e.prototype.dispose=function(){this._xAxis&&this._xAxis.dispose(!1,!this._instanced),this._yAxis&&this._yAxis.dispose(!1,!this._instanced),this._zAxis&&this._zAxis.dispose(!1,!this._instanced),this.scene=null},e._SetRenderingGroupId=function(e,t){e.getChildMeshes().forEach((function(e){e.renderingGroupId=t}))},e}(),l=i(1),u=i(23),h=function(e){function t(t,i,n,o){void 0===o&&(o=1);var a=e.call(this,t,o)||this;return a.pos=r.e.Zero(),a.xaxis=r.e.Zero(),a.yaxis=r.e.Zero(),a.zaxis=r.e.Zero(),a.mesh=n,a.bone=i,a}return Object(l.d)(t,e),t.prototype.update=function(){if(this.mesh&&this.bone){var t=this.bone;t._markAsDirtyAndCompose(),t.getAbsolutePositionToRef(this.mesh,this.pos),t.getDirectionToRef(u.a.X,this.mesh,this.xaxis),t.getDirectionToRef(u.a.Y,this.mesh,this.yaxis),t.getDirectionToRef(u.a.Z,this.mesh,this.zaxis),e.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)}},t.prototype.dispose=function(){this.mesh&&(this.mesh=null,this.bone=null,e.prototype.dispose.call(this))},t}(c),d=i(12),f=i(6),p=i(20),_=i(13);Object.defineProperty(p.a.prototype,\"debugLayer\",{get:function(){return this._debugLayer||(this._debugLayer=new m(this)),this._debugLayer},enumerable:!0,configurable:!0}),function(e){e[e.Properties=0]=\"Properties\",e[e.Debug=1]=\"Debug\",e[e.Statistics=2]=\"Statistics\",e[e.Tools=3]=\"Tools\",e[e.Settings=4]=\"Settings\"}(n||(n={}));var m=function(){function e(e){var t=this;this.BJSINSPECTOR=this._getGlobalInspector(),this._scene=e,this._scene.onDisposeObservable.add((function(){t._scene._debugLayer&&t._scene._debugLayer.hide()}))}return Object.defineProperty(e.prototype,\"onPropertyChangedObservable\",{get:function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector?this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable:(this._onPropertyChangedObservable||(this._onPropertyChangedObservable=new f.c),this._onPropertyChangedObservable)},enumerable:!1,configurable:!0}),e.prototype._createInspector=function(e){if(!this.isVisible()){if(this._onPropertyChangedObservable){for(var t=0,i=this._onPropertyChangedObservable.observers;t-1&&this._debugMeshMeshes.splice(o,1),this._numMeshes--,this._numMeshes>0?(this._meshes[n]=this._meshes[this._numMeshes],this._impostors[n]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)}},e.prototype._getDebugMaterial=function(e){return this._debugMaterial||(this._debugMaterial=new o.a(\"\",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=s.a.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=v.a.CreateBox(\"physicsBodyBoxViewMesh\",{size:1},e),this._debugBoxMesh.rotationQuaternion=r.b.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(e),this._debugBoxMesh.setEnabled(!1)),this._debugBoxMesh.createInstance(\"physicsBodyBoxViewInstance\")},e.prototype._getDebugSphereMesh=function(e){return this._debugSphereMesh||(this._debugSphereMesh=b.a.CreateSphere(\"physicsBodySphereViewMesh\",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=r.b.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance(\"physicsBodyBoxViewInstance\")},e.prototype._getDebugCylinderMesh=function(e){return this._debugCylinderMesh||(this._debugCylinderMesh=S.a.CreateCylinder(\"physicsBodyCylinderViewMesh\",{diameterTop:1,diameterBottom:1,height:1},e),this._debugCylinderMesh.rotationQuaternion=r.b.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(e),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance(\"physicsBodyBoxViewInstance\")},e.prototype._getDebugMeshMesh=function(e,t){var i=new g.a(e.name,t,null,e);return i.position=r.e.Zero(),i.setParent(e),i.material=this._getDebugMaterial(t),this._debugMeshMeshes.push(i),i},e.prototype._getDebugMesh=function(e,t){var i=this;if(!this._utilityLayer)return null;if(t&&t.parent&&t.parent.physicsImpostor)return null;var n=null,r=this._utilityLayer.utilityLayerScene;switch(e.type){case T.a.BoxImpostor:n=this._getDebugBoxMesh(r),e.getBoxSizeToRef(n.scaling);break;case T.a.SphereImpostor:n=this._getDebugSphereMesh(r);var o=e.getRadius();n.scaling.x=2*o,n.scaling.y=2*o,n.scaling.z=2*o;break;case T.a.MeshImpostor:t&&(n=this._getDebugMeshMesh(t,r));break;case T.a.NoImpostor:if(t)t.getChildMeshes().filter((function(e){return e.physicsImpostor?1:0})).forEach((function(e){i._getDebugBoxMesh(r).parent=e}));break;case T.a.CylinderImpostor:n=this._getDebugCylinderMesh(r);var a=e.object.getBoundingInfo();n.scaling.x=a.boundingBox.maximum.x-a.boundingBox.minimum.x,n.scaling.y=a.boundingBox.maximum.y-a.boundingBox.minimum.y,n.scaling.z=a.boundingBox.maximum.z-a.boundingBox.minimum.z}return n},e.prototype.dispose=function(){for(var e=this._numMeshes,t=0;te.DISPLAY_SPHERE_AND_SPURS&&(R=e.DISPLAY_LINES),this.displayMode=R,this.update(),this._bindObs()}return e.CreateBoneWeightShader=function(e,t){var i,n,r,o,a,c,l=e.skeleton,u=null!==(i=e.colorBase)&&void 0!==i?i:s.a.Black(),h=null!==(n=e.colorZero)&&void 0!==n?n:s.a.Blue(),d=null!==(r=e.colorQuarter)&&void 0!==r?r:s.a.Green(),f=null!==(o=e.colorHalf)&&void 0!==o?o:s.a.Yellow(),p=null!==(a=e.colorFull)&&void 0!==a?a:s.a.Red(),_=null!==(c=e.targetBoneIndex)&&void 0!==c?c:0;I.a.ShadersStore[\"boneWeights:\"+l.name+\"VertexShader\"]=\"precision highp float;\\n\\n attribute vec3 position;\\n attribute vec2 uv;\\n\\n uniform mat4 view;\\n uniform mat4 projection;\\n uniform mat4 worldViewProjection;\\n\\n #include\\n #if NUM_BONE_INFLUENCERS == 0\\n attribute vec4 matricesIndices;\\n attribute vec4 matricesWeights;\\n #endif\\n\\n #include\\n\\n varying vec3 vColor;\\n\\n uniform vec3 colorBase;\\n uniform vec3 colorZero;\\n uniform vec3 colorQuarter;\\n uniform vec3 colorHalf;\\n uniform vec3 colorFull;\\n\\n uniform float targetBoneIndex;\\n\\n void main() {\\n vec3 positionUpdated = position;\\n\\n #include\\n #include\\n\\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\\n\\n vec3 color = colorBase;\\n float totalWeight = 0.;\\n if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){\\n totalWeight += matricesWeights[0];\\n }\\n if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){\\n totalWeight += matricesWeights[1];\\n }\\n if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){\\n totalWeight += matricesWeights[2];\\n }\\n if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){\\n totalWeight += matricesWeights[3];\\n }\\n\\n color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));\\n color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));\\n color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));\\n color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));\\n vColor = color;\\n\\n gl_Position = projection * view * worldPos;\\n }\",I.a.ShadersStore[\"boneWeights:\"+l.name+\"FragmentShader\"]=\"\\n precision highp float;\\n varying vec3 vPosition;\\n\\n varying vec3 vColor;\\n\\n void main() {\\n vec4 color = vec4(vColor, 1.0);\\n gl_FragColor = color;\\n }\\n \";var m=new x.a(\"boneWeight:\"+l.name,t,{vertex:\"boneWeights:\"+l.name,fragment:\"boneWeights:\"+l.name},{attributes:[\"position\",\"normal\",\"matricesIndices\",\"matricesWeights\"],uniforms:[\"world\",\"worldView\",\"worldViewProjection\",\"view\",\"projection\",\"viewProjection\",\"colorBase\",\"colorZero\",\"colorQuarter\",\"colorHalf\",\"colorFull\",\"targetBoneIndex\"]});return m.setColor3(\"colorBase\",u),m.setColor3(\"colorZero\",h),m.setColor3(\"colorQuarter\",d),m.setColor3(\"colorHalf\",f),m.setColor3(\"colorFull\",p),m.setFloat(\"targetBoneIndex\",_),m.getClassName=function(){return\"BoneWeightShader\"},m.transparencyMode=R.a.MATERIAL_OPAQUE,m},e.CreateSkeletonMapShader=function(t,i){var n,r=t.skeleton,o=null!==(n=t.colorMap)&&void 0!==n?n:[{color:new s.a(1,.38,.18),location:0},{color:new s.a(.59,.18,1),location:.2},{color:new s.a(.59,1,.18),location:.4},{color:new s.a(1,.87,.17),location:.6},{color:new s.a(1,.17,.42),location:.8},{color:new s.a(.17,.68,1),location:1}],a=r.bones.length+1,c=e._CreateBoneMapColorBuffer(a,o,i),l=new x.a(\"boneWeights:\"+r.name,i,{vertexSource:\"precision highp float;\\n\\n attribute vec3 position;\\n attribute vec2 uv;\\n\\n uniform mat4 view;\\n uniform mat4 projection;\\n uniform mat4 worldViewProjection;\\n uniform float colorMap[\"+4*r.bones.length+\"];\\n\\n #include\\n #if NUM_BONE_INFLUENCERS == 0\\n attribute vec4 matricesIndices;\\n attribute vec4 matricesWeights;\\n #endif\\n #include\\n\\n varying vec3 vColor;\\n\\n void main() {\\n vec3 positionUpdated = position;\\n\\n #include\\n #include\\n\\n vec3 color = vec3(0.);\\n bool first = true;\\n\\n for (int i = 0; i < 4; i++) {\\n int boneIdx = int(matricesIndices[i]);\\n float boneWgt = matricesWeights[i];\\n\\n vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);\\n\\n if (boneWgt > 0.) {\\n if (first) {\\n first = false;\\n color = c;\\n } else {\\n color = mix(color, c, boneWgt);\\n }\\n }\\n }\\n\\n vColor = color;\\n\\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\\n\\n gl_Position = projection * view * worldPos;\\n }\",fragmentSource:\"\\n precision highp float;\\n varying vec3 vColor;\\n\\n void main() {\\n vec4 color = vec4( vColor, 1.0 );\\n gl_FragColor = color;\\n }\\n \"},{attributes:[\"position\",\"normal\",\"matricesIndices\",\"matricesWeights\"],uniforms:[\"world\",\"worldView\",\"worldViewProjection\",\"view\",\"projection\",\"viewProjection\",\"colorMap\"]});return l.setFloats(\"colorMap\",c),l.getClassName=function(){return\"SkeletonMapShader\"},l.transparencyMode=R.a.MATERIAL_OPAQUE,l},e._CreateBoneMapColorBuffer=function(e,t,i){var n=new O.a(\"temp\",{width:e,height:1},i,!1),r=n.getContext(),o=r.createLinearGradient(0,0,e,0);t.forEach((function(e){o.addColorStop(e.location,e.color.toHexString())})),r.fillStyle=o,r.fillRect(0,0,e,1),n.update();for(var a=[],s=r.getImageData(0,0,e,1).data,c=0;ce.DISPLAY_SPHERE_AND_SPURS&&(t=e.DISPLAY_LINES),this.options.displayMode=t},enumerable:!1,configurable:!0}),e.prototype._bindObs=function(){var t=this;switch(this.displayMode){case e.DISPLAY_LINES:this._obs=this.scene.onBeforeRenderObservable.add((function(){t._displayLinesUpdate()}))}},e.prototype.update=function(){switch(this.displayMode){case e.DISPLAY_LINES:this._displayLinesUpdate();break;case e.DISPLAY_SPHERES:this._buildSpheresAndSpurs(!0);break;case e.DISPLAY_SPHERE_AND_SPURS:this._buildSpheresAndSpurs(!1)}this._buildLocalAxes()},Object.defineProperty(e.prototype,\"isEnabled\",{get:function(){return this._isEnabled},set:function(e){this.isEnabled!==e&&(this._isEnabled=e,this.debugMesh&&this.debugMesh.setEnabled(e),e&&!this._obs?this._bindObs():!e&&this._obs&&(this.scene.onBeforeRenderObservable.remove(this._obs),this._obs=null))},enumerable:!1,configurable:!0}),e.prototype._getBonePosition=function(e,t,i,n,o,a){void 0===n&&(n=0),void 0===o&&(o=0),void 0===a&&(a=0);var s=r.c.Matrix[0],c=t.getParent();if(s.copyFrom(t.getLocalMatrix()),0!==n||0!==o||0!==a){var l=r.c.Matrix[1];r.a.IdentityToRef(l),l.setTranslationFromFloats(n,o,a),l.multiplyToRef(s,s)}c&&s.multiplyToRef(c.getAbsoluteTransform(),s),s.multiplyToRef(i,s),e.x=s.m[12],e.y=s.m[13],e.z=s.m[14]},e.prototype._getLinesForBonesWithLength=function(e,t){for(var i=e.length,n=this.mesh._effectiveMesh.position,o=0,a=0;a=0;a--){var s=e[a],c=s.getParent();if(c&&(this._boneIndices.has(s.getIndex())||this.options.useAllBones)){var l=this._debugLines[i];l||(l=[r.e.Zero(),r.e.Zero()],this._debugLines[i]=l),s.getAbsolutePositionToRef(n,l[0]),c.getAbsolutePositionToRef(n,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),i++}}},e.prototype._revert=function(e){this.options.pauseAnimations&&(this.scene.animationsEnabled=e,this.utilityLayer.utilityLayerScene.animationsEnabled=e)},e.prototype._getAbsoluteBindPoseToRef=function(e,t){null!==e&&-1!==e._index?(this._getAbsoluteBindPoseToRef(e.getParent(),t),e.getBindPose().multiplyToRef(t,t)):t.copyFrom(r.a.Identity())},e.prototype._buildSpheresAndSpurs=function(e){var t,i;void 0===e&&(e=!0),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this._ready=!1;var n=null===(t=this.utilityLayer)||void 0===t?void 0:t.utilityLayerScene,o=this.skeleton.bones,a=[],s=[],c=this.scene.animationsEnabled;try{this.options.pauseAnimations&&(this.scene.animationsEnabled=!1,n.animationsEnabled=!1),this.options.returnToRest&&this.skeleton.returnToRest(),this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();for(var l=Number.NEGATIVE_INFINITY,u=this.options.displayOptions||{},h=function(t){var i=o[t];if(-1===i._index||!d._boneIndices.has(i.getIndex())&&!d.options.useAllBones)return\"continue\";var c=new r.a;d._getAbsoluteBindPoseToRef(i,c);var h=new r.e;c.decompose(void 0,void 0,h),i.children.forEach((function(t,o){var a=new r.a;t.getBindPose().multiplyToRef(c,a);var d=new r.e;a.decompose(void 0,void 0,d);var f=r.e.Distance(h,d);if(f>l&&(l=f),!e){for(var p=d.clone().subtract(h.clone()),_=p.length(),m=p.normalize().scale(_),v=u.midStep||.165,b=u.midStepFactor||.215,y=m.scale(v),T=D.a.ExtrudeShapeCustom(\"skeletonViewer\",{shape:[new r.e(1,-1,0),new r.e(1,1,0),new r.e(-1,1,0),new r.e(-1,-1,0),new r.e(1,-1,0)],path:[r.e.Zero(),y,m],scaleFunction:function(e){switch(e){case 0:case 2:return 0;case 1:return _*b}return 0},sideOrientation:g.a.DEFAULTSIDE,updatable:!1},n),E=T.getTotalVertices(),S=[],A=[],P=0;P9?A.push(t.getIndex(),0,0,0):A.push(i.getIndex(),0,0,0);T.position=h.clone(),T.setVerticesData(M.b.MatricesWeightsKind,S,!1),T.setVerticesData(M.b.MatricesIndicesKind,A,!1),T.convertToFlatShadedMesh(),s.push(T)}}));for(var f=u.sphereBaseSize||.2,p=b.a.CreateSphere(\"skeletonViewer\",{segments:6,diameter:f,updatable:!0},n),_=p.getTotalVertices(),m=[],v=[],y=0;y<_;y++)m.push(1,0,0,0),v.push(i.getIndex(),0,0,0);p.setVerticesData(M.b.MatricesWeightsKind,m,!1),p.setVerticesData(M.b.MatricesIndicesKind,v,!1),p.position=h.clone(),a.push([p,i])},d=this,f=0;fu-n)&&(!(c-hh-r)&&!(l-dd-a))},e.prototype.intersectsSphere=function(t){return e.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},e.prototype.intersectsMinMax=function(e,t){var i=this.minimumWorld,n=this.maximumWorld,r=i.x,o=i.y,a=i.z,s=n.x,c=n.y,l=n.z,u=e.x,h=e.y,d=e.z,f=t.x,p=t.y,_=t.z;return!(sf)&&(!(cp)&&!(l_))},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,i,n,o){var a=e.TmpVector3[0];return r.e.ClampToRef(n,t,i,a),r.e.DistanceSquared(n,a)<=o*o},e.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;++i)for(var n=t[i],r=0;r<8;++r)if(n.dotCoordinate(e[r])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var i=0;i<6;++i){for(var n=!0,r=t[i],o=0;o<8;++o)if(r.dotCoordinate(e[o])>=0){n=!1;break}if(n)return!1}return!0},e.TmpVector3=n.a.BuildArray(3,r.e.Zero),e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r}));var n=i(38),r=function(){function e(){}return e.SetImmediate=function(e){n.a.IsWindowObjectExist()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return o}));var n=i(0),r=i(2),o=function(){function e(){this.previousWorldMatrices={},this.previousBones={}}return e.AddUniforms=function(e){e.push(\"previousWorld\",\"previousViewProjection\")},e.AddSamplers=function(e){},e.prototype.bindForSubMesh=function(e,t,i,o,a){t.prePassRenderer&&t.prePassRenderer.enabled&&-1!==t.prePassRenderer.getIndex(r.a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(this.previousWorldMatrices[i.uniqueId]||(this.previousWorldMatrices[i.uniqueId]=n.a.Identity()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix()),e.setMatrix(\"previousWorld\",this.previousWorldMatrices[i.uniqueId]),e.setMatrix(\"previousViewProjection\",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=o.clone(),this.previousViewProjection=t.getTransformMatrix().clone())},e}()},function(e,t,i){\"use strict\";var n=\"lightFragmentDeclaration\",r=\"#ifdef LIGHT{X}\\nuniform vec4 vLightData{X};\\nuniform vec4 vLightDiffuse{X};\\n#ifdef SPECULARTERM\\nuniform vec4 vLightSpecular{X};\\n#else\\nvec4 vLightSpecular{X}=vec4(0.);\\n#endif\\n#ifdef SHADOW{X}\\n#ifdef SHADOWCSM{X}\\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float cascadeBlendFactor{X};\\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\\nvarying vec4 vPositionFromCamera{X};\\n#if defined(SHADOWPCSS{X})\\nuniform highp sampler2DArrayShadow shadowSampler{X};\\nuniform highp sampler2DArray depthSampler{X};\\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float penumbraDarkness{X};\\n#elif defined(SHADOWPCF{X})\\nuniform highp sampler2DArrayShadow shadowSampler{X};\\n#else\\nuniform highp sampler2DArray shadowSampler{X};\\n#endif\\n#ifdef SHADOWCSMDEBUG{X}\\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\\n(\\nvec3 ( 1.5,0.0,0.0 ),\\nvec3 ( 0.0,1.5,0.0 ),\\nvec3 ( 0.0,0.0,5.5 ),\\nvec3 ( 1.5,0.0,5.5 ),\\nvec3 ( 1.5,1.5,0.0 ),\\nvec3 ( 1.0,1.0,1.0 ),\\nvec3 ( 0.0,1.0,5.5 ),\\nvec3 ( 0.5,3.5,0.75 )\\n);\\nvec3 shadowDebug{X};\\n#endif\\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\\nint index{X}=-1;\\n#else\\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\\n#endif\\nfloat diff{X}=0.;\\n#elif defined(SHADOWCUBE{X})\\nuniform samplerCube shadowSampler{X};\\n#else\\nvarying vec4 vPositionFromLight{X};\\nvarying float vDepthMetric{X};\\n#if defined(SHADOWPCSS{X})\\nuniform highp sampler2DShadow shadowSampler{X};\\nuniform highp sampler2D depthSampler{X};\\n#elif defined(SHADOWPCF{X})\\nuniform highp sampler2DShadow shadowSampler{X};\\n#else\\nuniform sampler2D shadowSampler{X};\\n#endif\\nuniform mat4 lightMatrix{X};\\n#endif\\nuniform vec4 shadowsInfo{X};\\nuniform vec2 depthValues{X};\\n#endif\\n#ifdef SPOTLIGHT{X}\\nuniform vec4 vLightDirection{X};\\nuniform vec4 vLightFalloff{X};\\n#elif defined(POINTLIGHT{X})\\nuniform vec4 vLightFalloff{X};\\n#elif defined(HEMILIGHT{X})\\nuniform vec3 vLightGround{X};\\n#endif\\n#ifdef PROJECTEDLIGHTTEXTURE{X}\\nuniform mat4 textureProjectionMatrix{X};\\nuniform sampler2D projectionLightSampler{X};\\n#endif\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"lightUboDeclaration\",r=\"#ifdef LIGHT{X}\\nuniform Light{X}\\n{\\nvec4 vLightData;\\nvec4 vLightDiffuse;\\nvec4 vLightSpecular;\\n#ifdef SPOTLIGHT{X}\\nvec4 vLightDirection;\\nvec4 vLightFalloff;\\n#elif defined(POINTLIGHT{X})\\nvec4 vLightFalloff;\\n#elif defined(HEMILIGHT{X})\\nvec3 vLightGround;\\n#endif\\nvec4 shadowsInfo;\\nvec2 depthValues;\\n} light{X};\\n#ifdef PROJECTEDLIGHTTEXTURE{X}\\nuniform mat4 textureProjectionMatrix{X};\\nuniform sampler2D projectionLightSampler{X};\\n#endif\\n#ifdef SHADOW{X}\\n#ifdef SHADOWCSM{X}\\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float cascadeBlendFactor{X};\\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\\nvarying vec4 vPositionFromCamera{X};\\n#if defined(SHADOWPCSS{X})\\nuniform highp sampler2DArrayShadow shadowSampler{X};\\nuniform highp sampler2DArray depthSampler{X};\\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\\nuniform float penumbraDarkness{X};\\n#elif defined(SHADOWPCF{X})\\nuniform highp sampler2DArrayShadow shadowSampler{X};\\n#else\\nuniform highp sampler2DArray shadowSampler{X};\\n#endif\\n#ifdef SHADOWCSMDEBUG{X}\\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\\n(\\nvec3 ( 1.5,0.0,0.0 ),\\nvec3 ( 0.0,1.5,0.0 ),\\nvec3 ( 0.0,0.0,5.5 ),\\nvec3 ( 1.5,0.0,5.5 ),\\nvec3 ( 1.5,1.5,0.0 ),\\nvec3 ( 1.0,1.0,1.0 ),\\nvec3 ( 0.0,1.0,5.5 ),\\nvec3 ( 0.5,3.5,0.75 )\\n);\\nvec3 shadowDebug{X};\\n#endif\\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\\nint index{X}=-1;\\n#else\\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\\n#endif\\nfloat diff{X}=0.;\\n#elif defined(SHADOWCUBE{X})\\nuniform samplerCube shadowSampler{X};\\n#else\\nvarying vec4 vPositionFromLight{X};\\nvarying float vDepthMetric{X};\\n#if defined(SHADOWPCSS{X})\\nuniform highp sampler2DShadow shadowSampler{X};\\nuniform highp sampler2D depthSampler{X};\\n#elif defined(SHADOWPCF{X})\\nuniform highp sampler2DShadow shadowSampler{X};\\n#else\\nuniform sampler2D shadowSampler{X};\\n#endif\\nuniform mat4 lightMatrix{X};\\n#endif\\n#endif\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"imageProcessingDeclaration\",r=\"#ifdef EXPOSURE\\nuniform float exposureLinear;\\n#endif\\n#ifdef CONTRAST\\nuniform float contrast;\\n#endif\\n#ifdef VIGNETTE\\nuniform vec2 vInverseScreenSize;\\nuniform vec4 vignetteSettings1;\\nuniform vec4 vignetteSettings2;\\n#endif\\n#ifdef COLORCURVES\\nuniform vec4 vCameraColorCurveNegative;\\nuniform vec4 vCameraColorCurveNeutral;\\nuniform vec4 vCameraColorCurvePositive;\\n#endif\\n#ifdef COLORGRADING\\n#ifdef COLORGRADING3D\\nuniform highp sampler3D txColorTransform;\\n#else\\nuniform sampler2D txColorTransform;\\n#endif\\nuniform vec4 colorTransformSettings;\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"imageProcessingFunctions\",r=\"#if defined(COLORGRADING) && !defined(COLORGRADING3D)\\n\\n#define inline\\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\\n{\\nfloat sliceSize=2.0*sampler3dSetting.x;\\n#ifdef SAMPLER3DGREENDEPTH\\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\\n#else\\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\\n#endif\\nfloat sliceInteger=floor(sliceContinuous);\\n\\n\\nfloat sliceFraction=sliceContinuous-sliceInteger;\\n#ifdef SAMPLER3DGREENDEPTH\\nvec2 sliceUV=color.rb;\\n#else\\nvec2 sliceUV=color.rg;\\n#endif\\nsliceUV.x*=sliceSize;\\nsliceUV.x+=sliceInteger*sliceSize;\\nsliceUV=saturate(sliceUV);\\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\\nsliceUV.x+=sliceSize;\\nsliceUV=saturate(sliceUV);\\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\\n#ifdef SAMPLER3DBGRMAP\\ncolor.rgb=result.rgb;\\n#else\\ncolor.rgb=result.bgr;\\n#endif\\nreturn color;\\n}\\n#endif\\n#ifdef TONEMAPPING_ACES\\n\\n\\n\\n\\n\\nconst mat3 ACESInputMat=mat3(\\nvec3(0.59719,0.07600,0.02840),\\nvec3(0.35458,0.90834,0.13383),\\nvec3(0.04823,0.01566,0.83777)\\n);\\n\\nconst mat3 ACESOutputMat=mat3(\\nvec3( 1.60475,-0.10208,-0.00327),\\nvec3(-0.53108,1.10813,-0.07276),\\nvec3(-0.07367,-0.00605,1.07602)\\n);\\nvec3 RRTAndODTFit(vec3 v)\\n{\\nvec3 a=v*(v+0.0245786)-0.000090537;\\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\\nreturn a/b;\\n}\\nvec3 ACESFitted(vec3 color)\\n{\\ncolor=ACESInputMat*color;\\n\\ncolor=RRTAndODTFit(color);\\ncolor=ACESOutputMat*color;\\n\\ncolor=saturate(color);\\nreturn color;\\n}\\n#endif\\nvec4 applyImageProcessing(vec4 result) {\\n#ifdef EXPOSURE\\nresult.rgb*=exposureLinear;\\n#endif\\n#ifdef VIGNETTE\\n\\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\\nviewportXY=viewportXY*2.0-1.0;\\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\\n\\nvec3 vignetteColor=vignetteSettings2.rgb;\\n#ifdef VIGNETTEBLENDMODEMULTIPLY\\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\\nresult.rgb*=vignetteColorMultiplier;\\n#endif\\n#ifdef VIGNETTEBLENDMODEOPAQUE\\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\\n#endif\\n#endif\\n#ifdef TONEMAPPING\\n#ifdef TONEMAPPING_ACES\\nresult.rgb=ACESFitted(result.rgb);\\n#else\\nconst float tonemappingCalibration=1.590579;\\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\\n#endif\\n#endif\\n\\nresult.rgb=toGammaSpace(result.rgb);\\nresult.rgb=saturate(result.rgb);\\n#ifdef CONTRAST\\n\\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\\nif (contrast<1.0) {\\n\\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\\n} else {\\n\\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\\n}\\n#endif\\n\\n#ifdef COLORGRADING\\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\\n#ifdef COLORGRADING3D\\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\\n#else\\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\\n#endif\\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\\n#endif\\n#ifdef COLORCURVES\\n\\nfloat luma=getLuminance(result.rgb);\\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\\nresult.rgb*=colorCurve.rgb;\\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\\n#endif\\nreturn result;\\n}\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"clipPlaneFragment\",r=\"#ifdef CLIPPLANE\\nif (fClipDistance>0.0)\\n{\\ndiscard;\\n}\\n#endif\\n#ifdef CLIPPLANE2\\nif (fClipDistance2>0.0)\\n{\\ndiscard;\\n}\\n#endif\\n#ifdef CLIPPLANE3\\nif (fClipDistance3>0.0)\\n{\\ndiscard;\\n}\\n#endif\\n#ifdef CLIPPLANE4\\nif (fClipDistance4>0.0)\\n{\\ndiscard;\\n}\\n#endif\\n#ifdef CLIPPLANE5\\nif (fClipDistance5>0.0)\\n{\\ndiscard;\\n}\\n#endif\\n#ifdef CLIPPLANE6\\nif (fClipDistance6>0.0)\\n{\\ndiscard;\\n}\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"clipPlaneVertex\",r=\"#ifdef CLIPPLANE\\nfClipDistance=dot(worldPos,vClipPlane);\\n#endif\\n#ifdef CLIPPLANE2\\nfClipDistance2=dot(worldPos,vClipPlane2);\\n#endif\\n#ifdef CLIPPLANE3\\nfClipDistance3=dot(worldPos,vClipPlane3);\\n#endif\\n#ifdef CLIPPLANE4\\nfClipDistance4=dot(worldPos,vClipPlane4);\\n#endif\\n#ifdef CLIPPLANE5\\nfClipDistance5=dot(worldPos,vClipPlane5);\\n#endif\\n#ifdef CLIPPLANE6\\nfClipDistance6=dot(worldPos,vClipPlane6);\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i||(i=t(e))&&this.add(e,i),i},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,\"count\",{get:function(){return this._count},enumerable:!1,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=e(t,this._data[t]);if(i)return i}return null},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return o}));var n=i(44),r=i(0),o=function(){function e(e,t,i){this.center=r.e.Zero(),this.centerWorld=r.e.Zero(),this.minimum=r.e.Zero(),this.maximum=r.e.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var n=r.e.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*n,this._update(i||r.a.IdentityReadOnly)},e.prototype.scale=function(t){var i=this.radius*t,n=e.TmpVector3,r=n[0].setAll(i),o=this.center.subtractToRef(r,n[1]),a=this.center.addToRef(r,n[2]);return this.reConstruct(o,a,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(t){if(t.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{r.e.TransformCoordinatesToRef(this.center,t,this.centerWorld);var i=e.TmpVector3[0];r.e.TransformNormalFromFloatsToRef(1,1,1,t,i),this.radiusWorld=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(i.z))*this.radius}},e.prototype.isInFrustum=function(e){for(var t=this.centerWorld,i=this.radiusWorld,n=0;n<6;n++)if(e[n].dotCoordinate(t)<=-i)return!1;return!0},e.prototype.isCenterInFrustum=function(e){for(var t=this.centerWorld,i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0},e.prototype.intersectsPoint=function(e){var t=r.e.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld=r&&0===i?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+n)):(t=t instanceof ArrayBuffer?new Uint8Array(t,i,n):new Uint8Array(t.buffer,t.byteOffset+i,n),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()}},function(e,t,i){\"use strict\";var n=\"fogFragmentDeclaration\",r=\"#ifdef FOG\\n#define FOGMODE_NONE 0.\\n#define FOGMODE_EXP 1.\\n#define FOGMODE_EXP2 2.\\n#define FOGMODE_LINEAR 3.\\n#define E 2.71828\\nuniform vec4 vFogInfos;\\nuniform vec3 vFogColor;\\nvarying vec3 vFogDistance;\\nfloat CalcFogFactor()\\n{\\nfloat fogCoeff=1.0;\\nfloat fogStart=vFogInfos.y;\\nfloat fogEnd=vFogInfos.z;\\nfloat fogDensity=vFogInfos.w;\\nfloat fogDistance=length(vFogDistance);\\nif (FOGMODE_LINEAR == vFogInfos.x)\\n{\\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\\n}\\nelse if (FOGMODE_EXP == vFogInfos.x)\\n{\\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\\n}\\nelse if (FOGMODE_EXP2 == vFogInfos.x)\\n{\\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\\n}\\nreturn clamp(fogCoeff,0.0,1.0);\\n}\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=i(26),r=i(27);n.a.prototype.createDynamicTexture=function(e,t,i,o){var a=new r.a(this,r.b.Dynamic);return a.baseWidth=e,a.baseHeight=t,i&&(e=this.needPOTTextures?n.a.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?n.a.GetExponentOfTwo(t,this._caps.maxTextureSize):t),a.width=e,a.height=t,a.isReady=!1,a.generateMipMaps=i,a.samplingMode=o,this.updateTextureSamplingMode(o,a),this._internalTexturesCache.push(a),a},n.a.prototype.updateDynamicTexture=function(e,t,i,n,r,o){if(void 0===n&&(n=!1),void 0===o&&(o=!1),e){var a=this._gl,s=a.TEXTURE_2D,c=this._bindTextureDirectly(s,e,!0,o);this._unpackFlipY(void 0===i?e.invertY:i),n&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var l=this._getWebGLTextureType(e.type),u=this._getInternalFormat(r||e.format),h=this._getRGBABufferInternalSizedFormat(e.type,u);a.texImage2D(s,0,h,u,l,t),e.generateMipMaps&&a.generateMipmap(s),c||this._bindTextureDirectly(s,null),n&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}}},function(e,t,i){\"use strict\";i.r(t),i.d(t,\"AbstractScene\",(function(){return n.a})),i.d(t,\"AbstractActionManager\",(function(){return r.a})),i.d(t,\"Action\",(function(){return l})),i.d(t,\"ActionEvent\",(function(){return u.a})),i.d(t,\"ActionManager\",(function(){return M})),i.d(t,\"Condition\",(function(){return d})),i.d(t,\"ValueCondition\",(function(){return f})),i.d(t,\"PredicateCondition\",(function(){return p})),i.d(t,\"StateCondition\",(function(){return _})),i.d(t,\"SwitchBooleanAction\",(function(){return v})),i.d(t,\"SetStateAction\",(function(){return b})),i.d(t,\"SetValueAction\",(function(){return y})),i.d(t,\"IncrementValueAction\",(function(){return T})),i.d(t,\"PlayAnimationAction\",(function(){return E})),i.d(t,\"StopAnimationAction\",(function(){return S})),i.d(t,\"DoNothingAction\",(function(){return A})),i.d(t,\"CombineAction\",(function(){return P})),i.d(t,\"ExecuteCodeAction\",(function(){return C})),i.d(t,\"SetParentAction\",(function(){return R})),i.d(t,\"PlaySoundAction\",(function(){return I})),i.d(t,\"StopSoundAction\",(function(){return D})),i.d(t,\"InterpolateValueAction\",(function(){return G})),i.d(t,\"Animatable\",(function(){return ee})),i.d(t,\"_IAnimationState\",(function(){return k})),i.d(t,\"Animation\",(function(){return z})),i.d(t,\"TargetedAnimation\",(function(){return te})),i.d(t,\"AnimationGroup\",(function(){return ie})),i.d(t,\"AnimationPropertiesOverride\",(function(){return ne})),i.d(t,\"EasingFunction\",(function(){return oe})),i.d(t,\"CircleEase\",(function(){return ae})),i.d(t,\"BackEase\",(function(){return se})),i.d(t,\"BounceEase\",(function(){return ce})),i.d(t,\"CubicEase\",(function(){return le})),i.d(t,\"ElasticEase\",(function(){return ue})),i.d(t,\"ExponentialEase\",(function(){return he})),i.d(t,\"PowerEase\",(function(){return de})),i.d(t,\"QuadraticEase\",(function(){return fe})),i.d(t,\"QuarticEase\",(function(){return pe})),i.d(t,\"QuinticEase\",(function(){return _e})),i.d(t,\"SineEase\",(function(){return me})),i.d(t,\"BezierCurveEase\",(function(){return ge})),i.d(t,\"RuntimeAnimation\",(function(){return K})),i.d(t,\"AnimationEvent\",(function(){return ve})),i.d(t,\"AnimationKeyInterpolation\",(function(){return N})),i.d(t,\"AnimationRange\",(function(){return F})),i.d(t,\"KeepAssets\",(function(){return ye})),i.d(t,\"InstantiatedEntries\",(function(){return Te})),i.d(t,\"AssetContainer\",(function(){return Ee})),i.d(t,\"Analyser\",(function(){return Ae})),i.d(t,\"AudioEngine\",(function(){return Pe})),i.d(t,\"AudioSceneComponent\",(function(){return Ie})),i.d(t,\"Sound\",(function(){return xe})),i.d(t,\"SoundTrack\",(function(){return Oe})),i.d(t,\"WeightedSound\",(function(){return De})),i.d(t,\"AutoRotationBehavior\",(function(){return Le})),i.d(t,\"BouncingBehavior\",(function(){return we})),i.d(t,\"FramingBehavior\",(function(){return Fe})),i.d(t,\"AttachToBoxBehavior\",(function(){return Ue})),i.d(t,\"FadeInOutBehavior\",(function(){return Ve})),i.d(t,\"MultiPointerScaleBehavior\",(function(){return ze})),i.d(t,\"PointerDragBehavior\",(function(){return ke.a})),i.d(t,\"SixDofDragBehavior\",(function(){return He})),i.d(t,\"Bone\",(function(){return $})),i.d(t,\"BoneIKController\",(function(){return Xe})),i.d(t,\"BoneLookController\",(function(){return Ye})),i.d(t,\"Skeleton\",(function(){return tt})),i.d(t,\"ArcRotateCameraGamepadInput\",(function(){return st})),i.d(t,\"ArcRotateCameraKeyboardMoveInput\",(function(){return lt})),i.d(t,\"ArcRotateCameraMouseWheelInput\",(function(){return ut})),i.d(t,\"ArcRotateCameraPointersInput\",(function(){return dt})),i.d(t,\"ArcRotateCameraVRDeviceOrientationInput\",(function(){return pt})),i.d(t,\"FlyCameraKeyboardInput\",(function(){return _t})),i.d(t,\"FlyCameraMouseInput\",(function(){return mt})),i.d(t,\"FollowCameraKeyboardMoveInput\",(function(){return gt})),i.d(t,\"FollowCameraMouseWheelInput\",(function(){return vt})),i.d(t,\"FollowCameraPointersInput\",(function(){return bt})),i.d(t,\"FreeCameraDeviceOrientationInput\",(function(){return Rt})),i.d(t,\"FreeCameraGamepadInput\",(function(){return xt})),i.d(t,\"FreeCameraKeyboardMoveInput\",(function(){return yt})),i.d(t,\"FreeCameraMouseInput\",(function(){return Tt})),i.d(t,\"FreeCameraMouseWheelInput\",(function(){return At})),i.d(t,\"FreeCameraTouchInput\",(function(){return Pt})),i.d(t,\"FreeCameraVirtualJoystickInput\",(function(){return Dt})),i.d(t,\"CameraInputTypes\",(function(){return it})),i.d(t,\"CameraInputsManager\",(function(){return nt})),i.d(t,\"Camera\",(function(){return je.a})),i.d(t,\"TargetCamera\",(function(){return Lt})),i.d(t,\"FreeCamera\",(function(){return wt})),i.d(t,\"FreeCameraInputsManager\",(function(){return Ct})),i.d(t,\"TouchCamera\",(function(){return Ft})),i.d(t,\"ArcRotateCamera\",(function(){return Bt})),i.d(t,\"ArcRotateCameraInputsManager\",(function(){return ft})),i.d(t,\"DeviceOrientationCamera\",(function(){return Ut})),i.d(t,\"FlyCamera\",(function(){return kt})),i.d(t,\"FlyCameraInputsManager\",(function(){return Vt})),i.d(t,\"FollowCamera\",(function(){return jt})),i.d(t,\"ArcFollowCamera\",(function(){return Wt})),i.d(t,\"FollowCameraInputsManager\",(function(){return zt})),i.d(t,\"GamepadCamera\",(function(){return ri})),i.d(t,\"AnaglyphArcRotateCamera\",(function(){return mi})),i.d(t,\"AnaglyphFreeCamera\",(function(){return gi})),i.d(t,\"AnaglyphGamepadCamera\",(function(){return vi})),i.d(t,\"AnaglyphUniversalCamera\",(function(){return bi})),i.d(t,\"StereoscopicArcRotateCamera\",(function(){return Ti})),i.d(t,\"StereoscopicFreeCamera\",(function(){return Ei})),i.d(t,\"StereoscopicGamepadCamera\",(function(){return Si})),i.d(t,\"StereoscopicUniversalCamera\",(function(){return Ai})),i.d(t,\"UniversalCamera\",(function(){return ni})),i.d(t,\"VirtualJoysticksCamera\",(function(){return Pi})),i.d(t,\"VRCameraMetrics\",(function(){return Ci})),i.d(t,\"VRDeviceOrientationArcRotateCamera\",(function(){return Bi})),i.d(t,\"VRDeviceOrientationFreeCamera\",(function(){return Ui})),i.d(t,\"VRDeviceOrientationGamepadCamera\",(function(){return Vi})),i.d(t,\"OnAfterEnteringVRObservableEvent\",(function(){return hn})),i.d(t,\"VRExperienceHelper\",(function(){return dn})),i.d(t,\"WebVRFreeCamera\",(function(){return zi})),i.d(t,\"Collider\",(function(){return _n})),i.d(t,\"DefaultCollisionCoordinator\",(function(){return mn})),i.d(t,\"PickingInfo\",(function(){return gn.a})),i.d(t,\"IntersectionInfo\",(function(){return vn.a})),i.d(t,\"_MeshCollisionData\",(function(){return bn.a})),i.d(t,\"BoundingBox\",(function(){return yn.a})),i.d(t,\"BoundingInfo\",(function(){return Tn.a})),i.d(t,\"BoundingSphere\",(function(){return En.a})),i.d(t,\"Octree\",(function(){return An})),i.d(t,\"OctreeBlock\",(function(){return Sn})),i.d(t,\"OctreeSceneComponent\",(function(){return Mn})),i.d(t,\"Ray\",(function(){return Xt.a})),i.d(t,\"AxesViewer\",(function(){return In.AxesViewer})),i.d(t,\"BoneAxesViewer\",(function(){return In.BoneAxesViewer})),i.d(t,\"DebugLayerTab\",(function(){return In.DebugLayerTab})),i.d(t,\"DebugLayer\",(function(){return In.DebugLayer})),i.d(t,\"PhysicsViewer\",(function(){return In.PhysicsViewer})),i.d(t,\"RayHelper\",(function(){return In.RayHelper})),i.d(t,\"SkeletonViewer\",(function(){return In.SkeletonViewer})),i.d(t,\"DeviceInputSystem\",(function(){return Dn})),i.d(t,\"DeviceType\",(function(){return Pn})),i.d(t,\"PointerInput\",(function(){return Cn})),i.d(t,\"DualShockInput\",(function(){return Rn})),i.d(t,\"XboxInput\",(function(){return xn})),i.d(t,\"SwitchInput\",(function(){return On})),i.d(t,\"DeviceSource\",(function(){return Nn})),i.d(t,\"DeviceSourceManager\",(function(){return Ln})),i.d(t,\"Constants\",(function(){return g.a})),i.d(t,\"ThinEngine\",(function(){return qe.a})),i.d(t,\"Engine\",(function(){return Se.a})),i.d(t,\"EngineStore\",(function(){return x.a})),i.d(t,\"NullEngineOptions\",(function(){return wn.b})),i.d(t,\"NullEngine\",(function(){return wn.a})),i.d(t,\"_OcclusionDataStorage\",(function(){return Bn})),i.d(t,\"_forceTransformFeedbackToBundle\",(function(){return Un})),i.d(t,\"EngineView\",(function(){return kn})),i.d(t,\"WebGLPipelineContext\",(function(){return Gn.a})),i.d(t,\"WebGL2ShaderProcessor\",(function(){return jn.a})),i.d(t,\"NativeEngine\",(function(){return cr})),i.d(t,\"ShaderCodeInliner\",(function(){return rr})),i.d(t,\"PerformanceConfigurator\",(function(){return lr.a})),i.d(t,\"KeyboardEventTypes\",(function(){return ct.a})),i.d(t,\"KeyboardInfo\",(function(){return ct.b})),i.d(t,\"KeyboardInfoPre\",(function(){return ct.c})),i.d(t,\"PointerEventTypes\",(function(){return Ne.a})),i.d(t,\"PointerInfoBase\",(function(){return Ne.c})),i.d(t,\"PointerInfoPre\",(function(){return Ne.d})),i.d(t,\"PointerInfo\",(function(){return Ne.b})),i.d(t,\"ClipboardEventTypes\",(function(){return ur})),i.d(t,\"ClipboardInfo\",(function(){return hr})),i.d(t,\"DaydreamController\",(function(){return _r})),i.d(t,\"GearVRController\",(function(){return mr})),i.d(t,\"GenericController\",(function(){return gr})),i.d(t,\"OculusTouchController\",(function(){return vr})),i.d(t,\"PoseEnabledControllerType\",(function(){return Gt})),i.d(t,\"PoseEnabledControllerHelper\",(function(){return Qt})),i.d(t,\"PoseEnabledController\",(function(){return qt})),i.d(t,\"ViveController\",(function(){return br})),i.d(t,\"WebVRController\",(function(){return Gi})),i.d(t,\"WindowsMotionController\",(function(){return Tr})),i.d(t,\"XRWindowsMotionController\",(function(){return Er})),i.d(t,\"StickValues\",(function(){return rt})),i.d(t,\"Gamepad\",(function(){return ot})),i.d(t,\"GenericPad\",(function(){return at})),i.d(t,\"GamepadManager\",(function(){return ti})),i.d(t,\"GamepadSystemSceneComponent\",(function(){return ii})),i.d(t,\"Xbox360Button\",(function(){return Yt})),i.d(t,\"Xbox360Dpad\",(function(){return Kt})),i.d(t,\"Xbox360Pad\",(function(){return $t})),i.d(t,\"DualShockButton\",(function(){return Zt})),i.d(t,\"DualShockDpad\",(function(){return Jt})),i.d(t,\"DualShockPad\",(function(){return ei})),i.d(t,\"AxisDragGizmo\",(function(){return Sr.a})),i.d(t,\"AxisScaleGizmo\",(function(){return Rr})),i.d(t,\"BoundingBoxGizmo\",(function(){return Mr})),i.d(t,\"Gizmo\",(function(){return Pr.a})),i.d(t,\"GizmoManager\",(function(){return Vr})),i.d(t,\"PlaneRotationGizmo\",(function(){return Ir})),i.d(t,\"PositionGizmo\",(function(){return Fr})),i.d(t,\"RotationGizmo\",(function(){return Dr})),i.d(t,\"ScaleGizmo\",(function(){return Ur})),i.d(t,\"LightGizmo\",(function(){return Hr})),i.d(t,\"CameraGizmo\",(function(){return Kr})),i.d(t,\"PlaneDragGizmo\",(function(){return wr})),i.d(t,\"EnvironmentHelper\",(function(){return go})),i.d(t,\"PhotoDome\",(function(){return bo})),i.d(t,\"_forceSceneHelpersToBundle\",(function(){return es})),i.d(t,\"VideoDome\",(function(){return is})),i.d(t,\"EngineInstrumentation\",(function(){return rs})),i.d(t,\"SceneInstrumentation\",(function(){return os})),i.d(t,\"_TimeToken\",(function(){return Fn})),i.d(t,\"EffectLayer\",(function(){return cs})),i.d(t,\"EffectLayerSceneComponent\",(function(){return ls})),i.d(t,\"GlowLayer\",(function(){return ds})),i.d(t,\"HighlightLayer\",(function(){return _s})),i.d(t,\"Layer\",(function(){return bs})),i.d(t,\"LayerSceneComponent\",(function(){return ms})),i.d(t,\"LensFlare\",(function(){return ys})),i.d(t,\"LensFlareSystem\",(function(){return Ss})),i.d(t,\"LensFlareSystemSceneComponent\",(function(){return As})),i.d(t,\"Light\",(function(){return kr.a})),i.d(t,\"ShadowLight\",(function(){return zr})),i.d(t,\"ShadowGenerator\",(function(){return Bs})),i.d(t,\"CascadedShadowGenerator\",(function(){return qs})),i.d(t,\"ShadowGeneratorSceneComponent\",(function(){return Zs})),i.d(t,\"DirectionalLight\",(function(){return Gr})),i.d(t,\"HemisphericLight\",(function(){return ki.a})),i.d(t,\"PointLight\",(function(){return Js})),i.d(t,\"SpotLight\",(function(){return Wr})),i.d(t,\"DefaultLoadingScreen\",(function(){return $s})),i.d(t,\"_BabylonLoaderRegistered\",(function(){return Tc})),i.d(t,\"BabylonFileLoaderConfiguration\",(function(){return Ec})),i.d(t,\"SceneLoaderAnimationGroupLoadingMode\",(function(){return nr})),i.d(t,\"SceneLoader\",(function(){return pr})),i.d(t,\"SceneLoaderFlags\",(function(){return fr.a})),i.d(t,\"BackgroundMaterial\",(function(){return mo})),i.d(t,\"ColorCurves\",(function(){return xc.a})),i.d(t,\"EffectFallbacks\",(function(){return po.a})),i.d(t,\"Effect\",(function(){return ai.a})),i.d(t,\"FresnelParameters\",(function(){return Oc})),i.d(t,\"ImageProcessingConfigurationDefines\",(function(){return ji.b})),i.d(t,\"ImageProcessingConfiguration\",(function(){return ji.a})),i.d(t,\"Material\",(function(){return xo.a})),i.d(t,\"MaterialDefines\",(function(){return oo.a})),i.d(t,\"ThinMaterialHelper\",(function(){return Mc.a})),i.d(t,\"MaterialHelper\",(function(){return ro.a})),i.d(t,\"MultiMaterial\",(function(){return tc.a})),i.d(t,\"PBRMaterialDefines\",(function(){return pa})),i.d(t,\"PBRBaseMaterial\",(function(){return _a})),i.d(t,\"PBRBaseSimpleMaterial\",(function(){return Ic})),i.d(t,\"PBRMaterial\",(function(){return ma})),i.d(t,\"PBRMetallicRoughnessMaterial\",(function(){return Dc})),i.d(t,\"PBRSpecularGlossinessMaterial\",(function(){return Nc})),i.d(t,\"PushMaterial\",(function(){return ao.a})),i.d(t,\"ShaderMaterial\",(function(){return Lc.a})),i.d(t,\"StandardMaterialDefines\",(function(){return Wi.b})),i.d(t,\"StandardMaterial\",(function(){return Wi.a})),i.d(t,\"BaseTexture\",(function(){return Zn.a})),i.d(t,\"ColorGradingTexture\",(function(){return wc})),i.d(t,\"CubeTexture\",(function(){return no})),i.d(t,\"DynamicTexture\",(function(){return Hi.a})),i.d(t,\"EquiRectangularCubeTexture\",(function(){return Fc})),i.d(t,\"HDRFiltering\",(function(){return cc})),i.d(t,\"HDRCubeTexture\",(function(){return lc})),i.d(t,\"HtmlElementTexture\",(function(){return Bc})),i.d(t,\"InternalTextureSource\",(function(){return Qe.b})),i.d(t,\"InternalTexture\",(function(){return Qe.a})),i.d(t,\"_DDSTextureLoader\",(function(){return Sa})),i.d(t,\"_ENVTextureLoader\",(function(){return Aa})),i.d(t,\"_KTXTextureLoader\",(function(){return Oa})),i.d(t,\"_TGATextureLoader\",(function(){return Vc})),i.d(t,\"_BasisTextureLoader\",(function(){return Wc})),i.d(t,\"MirrorTexture\",(function(){return to})),i.d(t,\"MultiRenderTarget\",(function(){return Hc})),i.d(t,\"TexturePacker\",(function(){return Yc})),i.d(t,\"TexturePackerFrame\",(function(){return Xc})),i.d(t,\"CustomProceduralTexture\",(function(){return Zc})),i.d(t,\"NoiseProceduralTexture\",(function(){return $c})),i.d(t,\"ProceduralTexture\",(function(){return qc})),i.d(t,\"ProceduralTextureSceneComponent\",(function(){return Kc})),i.d(t,\"RawCubeTexture\",(function(){return sl})),i.d(t,\"RawTexture\",(function(){return et})),i.d(t,\"RawTexture2DArray\",(function(){return cl})),i.d(t,\"RawTexture3D\",(function(){return ll})),i.d(t,\"RefractionTexture\",(function(){return ul})),i.d(t,\"RenderTargetTexture\",(function(){return Ni})),i.d(t,\"Texture\",(function(){return Ke.a})),i.d(t,\"VideoTexture\",(function(){return ts})),i.d(t,\"UniformBuffer\",(function(){return Mi.a})),i.d(t,\"MaterialFlags\",(function(){return so.a})),i.d(t,\"NodeMaterialBlockTargets\",(function(){return el})),i.d(t,\"NodeMaterialBlockConnectionPointTypes\",(function(){return tl})),i.d(t,\"NodeMaterialBlockConnectionPointMode\",(function(){return il})),i.d(t,\"NodeMaterialSystemValues\",(function(){return nl})),i.d(t,\"NodeMaterialModes\",(function(){return rl})),i.d(t,\"NodeMaterialConnectionPointCompatibilityStates\",(function(){return ol})),i.d(t,\"NodeMaterialConnectionPointDirection\",(function(){return al})),i.d(t,\"NodeMaterialConnectionPoint\",(function(){return hl})),i.d(t,\"NodeMaterialBlock\",(function(){return fl})),i.d(t,\"NodeMaterialDefines\",(function(){return Ql})),i.d(t,\"NodeMaterial\",(function(){return ql})),i.d(t,\"VertexOutputBlock\",(function(){return gl})),i.d(t,\"BonesBlock\",(function(){return Zl})),i.d(t,\"InstancesBlock\",(function(){return Jl})),i.d(t,\"MorphTargetsBlock\",(function(){return $l})),i.d(t,\"LightInformationBlock\",(function(){return eu})),i.d(t,\"FragmentOutputBlock\",(function(){return bl})),i.d(t,\"ImageProcessingBlock\",(function(){return tu})),i.d(t,\"PerturbNormalBlock\",(function(){return iu})),i.d(t,\"DiscardBlock\",(function(){return nu})),i.d(t,\"FrontFacingBlock\",(function(){return ru})),i.d(t,\"DerivativeBlock\",(function(){return ou})),i.d(t,\"FragCoordBlock\",(function(){return au})),i.d(t,\"ScreenSizeBlock\",(function(){return su})),i.d(t,\"FogBlock\",(function(){return cu})),i.d(t,\"LightBlock\",(function(){return lu})),i.d(t,\"TextureBlock\",(function(){return uu})),i.d(t,\"ReflectionTextureBlock\",(function(){return du})),i.d(t,\"CurrentScreenBlock\",(function(){return Al})),i.d(t,\"InputBlock\",(function(){return Sl})),i.d(t,\"AnimatedInputBlockTypes\",(function(){return vl})),i.d(t,\"MultiplyBlock\",(function(){return Dl})),i.d(t,\"AddBlock\",(function(){return fu})),i.d(t,\"ScaleBlock\",(function(){return pu})),i.d(t,\"ClampBlock\",(function(){return _u})),i.d(t,\"CrossBlock\",(function(){return mu})),i.d(t,\"DotBlock\",(function(){return gu})),i.d(t,\"TransformBlock\",(function(){return ml})),i.d(t,\"RemapBlock\",(function(){return Il})),i.d(t,\"NormalizeBlock\",(function(){return vu})),i.d(t,\"TrigonometryBlockOperations\",(function(){return Hl})),i.d(t,\"TrigonometryBlock\",(function(){return Yl})),i.d(t,\"ColorMergerBlock\",(function(){return bu})),i.d(t,\"VectorMergerBlock\",(function(){return Ol})),i.d(t,\"ColorSplitterBlock\",(function(){return Wl})),i.d(t,\"VectorSplitterBlock\",(function(){return yu})),i.d(t,\"LerpBlock\",(function(){return Tu})),i.d(t,\"DivideBlock\",(function(){return Eu})),i.d(t,\"SubtractBlock\",(function(){return Su})),i.d(t,\"StepBlock\",(function(){return Au})),i.d(t,\"OneMinusBlock\",(function(){return Pu})),i.d(t,\"ViewDirectionBlock\",(function(){return Cu})),i.d(t,\"FresnelBlock\",(function(){return Ru})),i.d(t,\"MaxBlock\",(function(){return xu})),i.d(t,\"MinBlock\",(function(){return Ou})),i.d(t,\"DistanceBlock\",(function(){return Mu})),i.d(t,\"LengthBlock\",(function(){return Iu})),i.d(t,\"NegateBlock\",(function(){return Du})),i.d(t,\"PowBlock\",(function(){return Nu})),i.d(t,\"RandomNumberBlock\",(function(){return Lu})),i.d(t,\"ArcTan2Block\",(function(){return wu})),i.d(t,\"SmoothStepBlock\",(function(){return Fu})),i.d(t,\"ReciprocalBlock\",(function(){return Bu})),i.d(t,\"ReplaceColorBlock\",(function(){return Uu})),i.d(t,\"PosterizeBlock\",(function(){return ku})),i.d(t,\"WaveBlockKind\",(function(){return Vu})),i.d(t,\"WaveBlock\",(function(){return zu})),i.d(t,\"GradientBlockColorStep\",(function(){return Gu})),i.d(t,\"GradientBlock\",(function(){return ju})),i.d(t,\"NLerpBlock\",(function(){return Wu})),i.d(t,\"WorleyNoise3DBlock\",(function(){return Hu})),i.d(t,\"SimplexPerlin3DBlock\",(function(){return Xu})),i.d(t,\"NormalBlendBlock\",(function(){return Yu})),i.d(t,\"Rotate2dBlock\",(function(){return Ku})),i.d(t,\"ReflectBlock\",(function(){return Qu})),i.d(t,\"RefractBlock\",(function(){return qu})),i.d(t,\"DesaturateBlock\",(function(){return Zu})),i.d(t,\"PBRMetallicRoughnessBlock\",(function(){return ah})),i.d(t,\"SheenBlock\",(function(){return $u})),i.d(t,\"AnisotropyBlock\",(function(){return eh})),i.d(t,\"ReflectionBlock\",(function(){return th})),i.d(t,\"ClearCoatBlock\",(function(){return ih})),i.d(t,\"RefractionBlock\",(function(){return nh})),i.d(t,\"SubSurfaceBlock\",(function(){return rh})),i.d(t,\"ParticleTextureBlock\",(function(){return Pl})),i.d(t,\"ParticleRampGradientBlock\",(function(){return Cl})),i.d(t,\"ParticleBlendMultiplyBlock\",(function(){return Rl})),i.d(t,\"ModBlock\",(function(){return sh})),i.d(t,\"NodeMaterialOptimizer\",(function(){return ch})),i.d(t,\"PropertyTypeForEdition\",(function(){return xl})),i.d(t,\"editableInPropertyPage\",(function(){return Ml})),i.d(t,\"EffectRenderer\",(function(){return rc})),i.d(t,\"EffectWrapper\",(function(){return oc})),i.d(t,\"ShadowDepthWrapper\",(function(){return hh})),i.d(t,\"Scalar\",(function(){return L.a})),i.d(t,\"extractMinAndMaxIndexed\",(function(){return dh.b})),i.d(t,\"extractMinAndMax\",(function(){return dh.a})),i.d(t,\"Space\",(function(){return J.c})),i.d(t,\"Axis\",(function(){return J.a})),i.d(t,\"Coordinate\",(function(){return J.b})),i.d(t,\"Color3\",(function(){return s.a})),i.d(t,\"Color4\",(function(){return s.b})),i.d(t,\"TmpColors\",(function(){return s.c})),i.d(t,\"ToGammaSpace\",(function(){return Nt.b})),i.d(t,\"ToLinearSpace\",(function(){return Nt.c})),i.d(t,\"Epsilon\",(function(){return Nt.a})),i.d(t,\"Frustum\",(function(){return wi.a})),i.d(t,\"Orientation\",(function(){return re.e})),i.d(t,\"BezierCurve\",(function(){return re.c})),i.d(t,\"Angle\",(function(){return re.a})),i.d(t,\"Arc2\",(function(){return re.b})),i.d(t,\"Path2\",(function(){return re.f})),i.d(t,\"Path3D\",(function(){return re.g})),i.d(t,\"Curve3\",(function(){return re.d})),i.d(t,\"Plane\",(function(){return fn.a})),i.d(t,\"Size\",(function(){return U.a})),i.d(t,\"Vector2\",(function(){return a.d})),i.d(t,\"Vector3\",(function(){return a.e})),i.d(t,\"Vector4\",(function(){return a.f})),i.d(t,\"Quaternion\",(function(){return a.b})),i.d(t,\"Matrix\",(function(){return a.a})),i.d(t,\"TmpVectors\",(function(){return a.c})),i.d(t,\"PositionNormalVertex\",(function(){return Xr})),i.d(t,\"PositionNormalTextureVertex\",(function(){return Yr})),i.d(t,\"Viewport\",(function(){return yi.a})),i.d(t,\"SphericalHarmonics\",(function(){return Qn})),i.d(t,\"SphericalPolynomial\",(function(){return qn})),i.d(t,\"AbstractMesh\",(function(){return Ge.a})),i.d(t,\"Buffer\",(function(){return Qi.a})),i.d(t,\"VertexBuffer\",(function(){return Qi.b})),i.d(t,\"DracoCompression\",(function(){return mh})),i.d(t,\"CSG\",(function(){return Sh})),i.d(t,\"Geometry\",(function(){return ec.a})),i.d(t,\"GroundMesh\",(function(){return qi})),i.d(t,\"TrailMesh\",(function(){return Ah})),i.d(t,\"InstancedMesh\",(function(){return Ph.a})),i.d(t,\"LinesMesh\",(function(){return Ch.b})),i.d(t,\"InstancedLinesMesh\",(function(){return Ch.a})),i.d(t,\"_CreationDataStorage\",(function(){return be.b})),i.d(t,\"_InstancesBatch\",(function(){return be.c})),i.d(t,\"Mesh\",(function(){return be.a})),i.d(t,\"VertexData\",(function(){return Ki.a})),i.d(t,\"MeshBuilder\",(function(){return jh})),i.d(t,\"SimplificationSettings\",(function(){return Wh})),i.d(t,\"SimplificationQueue\",(function(){return Hh})),i.d(t,\"SimplificationType\",(function(){return zh})),i.d(t,\"QuadraticErrorSimplification\",(function(){return qh})),i.d(t,\"SimplicationQueueSceneComponent\",(function(){return Zh})),i.d(t,\"Polygon\",(function(){return Nh})),i.d(t,\"PolygonMeshBuilder\",(function(){return Lh})),i.d(t,\"SubMesh\",(function(){return gh.a})),i.d(t,\"MeshLODLevel\",(function(){return Jh.a})),i.d(t,\"TransformNode\",(function(){return Nr.a})),i.d(t,\"BoxBuilder\",(function(){return Ar.a})),i.d(t,\"TiledBoxBuilder\",(function(){return Oh})),i.d(t,\"DiscBuilder\",(function(){return xh})),i.d(t,\"RibbonBuilder\",(function(){return Rh.a})),i.d(t,\"SphereBuilder\",(function(){return xr.a})),i.d(t,\"HemisphereBuilder\",(function(){return jr})),i.d(t,\"CylinderBuilder\",(function(){return nn.a})),i.d(t,\"TorusBuilder\",(function(){return tn})),i.d(t,\"TorusKnotBuilder\",(function(){return Mh})),i.d(t,\"LinesBuilder\",(function(){return Or.a})),i.d(t,\"PolygonBuilder\",(function(){return wh})),i.d(t,\"ShapeBuilder\",(function(){return vc.a})),i.d(t,\"LatheBuilder\",(function(){return Fh})),i.d(t,\"PlaneBuilder\",(function(){return Lr.a})),i.d(t,\"TiledPlaneBuilder\",(function(){return Bh})),i.d(t,\"GroundBuilder\",(function(){return Ji})),i.d(t,\"TubeBuilder\",(function(){return Uh})),i.d(t,\"PolyhedronBuilder\",(function(){return Br})),i.d(t,\"IcoSphereBuilder\",(function(){return Vh})),i.d(t,\"DecalBuilder\",(function(){return kh})),i.d(t,\"CapsuleBuilder\",(function(){return Gh})),i.d(t,\"DataBuffer\",(function(){return Wn.a})),i.d(t,\"WebGLDataBuffer\",(function(){return $h.a})),i.d(t,\"MorphTarget\",(function(){return uc})),i.d(t,\"MorphTargetManager\",(function(){return hc})),i.d(t,\"RecastJSPlugin\",(function(){return ed})),i.d(t,\"RecastJSCrowd\",(function(){return td})),i.d(t,\"Node\",(function(){return B.a})),i.d(t,\"Database\",(function(){return nd})),i.d(t,\"BaseParticleSystem\",(function(){return jl})),i.d(t,\"BoxParticleEmitter\",(function(){return Nl})),i.d(t,\"ConeParticleEmitter\",(function(){return Ll})),i.d(t,\"CylinderParticleEmitter\",(function(){return wl})),i.d(t,\"CylinderDirectedParticleEmitter\",(function(){return Fl})),i.d(t,\"HemisphericParticleEmitter\",(function(){return Bl})),i.d(t,\"PointParticleEmitter\",(function(){return Ul})),i.d(t,\"SphereParticleEmitter\",(function(){return Vl})),i.d(t,\"SphereDirectedParticleEmitter\",(function(){return kl})),i.d(t,\"CustomParticleEmitter\",(function(){return zl})),i.d(t,\"MeshParticleEmitter\",(function(){return Gl})),i.d(t,\"GPUParticleSystem\",(function(){return vd})),i.d(t,\"Particle\",(function(){return cd})),i.d(t,\"ParticleHelper\",(function(){return yd})),i.d(t,\"ParticleSystem\",(function(){return dd})),i.d(t,\"ParticleSystemSet\",(function(){return bd})),i.d(t,\"SolidParticle\",(function(){return Ed})),i.d(t,\"ModelShape\",(function(){return Sd})),i.d(t,\"DepthSortedParticle\",(function(){return Ad})),i.d(t,\"SolidParticleVertex\",(function(){return Pd})),i.d(t,\"SolidParticleSystem\",(function(){return Cd})),i.d(t,\"CloudPoint\",(function(){return Rd})),i.d(t,\"PointsGroup\",(function(){return xd})),i.d(t,\"PointColor\",(function(){return Td})),i.d(t,\"PointsCloudSystem\",(function(){return Od})),i.d(t,\"SubEmitterType\",(function(){return id})),i.d(t,\"SubEmitter\",(function(){return ld})),i.d(t,\"PhysicsEngine\",(function(){return pc})),i.d(t,\"PhysicsEngineSceneComponent\",(function(){return Dd})),i.d(t,\"PhysicsHelper\",(function(){return Nd})),i.d(t,\"PhysicsRadialExplosionEventOptions\",(function(){return Ud})),i.d(t,\"PhysicsUpdraftEventOptions\",(function(){return Vd})),i.d(t,\"PhysicsVortexEventOptions\",(function(){return kd})),i.d(t,\"PhysicsRadialImpulseFalloff\",(function(){return Md})),i.d(t,\"PhysicsUpdraftMode\",(function(){return Id})),i.d(t,\"PhysicsImpostor\",(function(){return dc.a})),i.d(t,\"PhysicsJoint\",(function(){return fc.e})),i.d(t,\"DistanceJoint\",(function(){return fc.a})),i.d(t,\"MotorEnabledJoint\",(function(){return fc.d})),i.d(t,\"HingeJoint\",(function(){return fc.c})),i.d(t,\"Hinge2Joint\",(function(){return fc.b})),i.d(t,\"CannonJSPlugin\",(function(){return mc})),i.d(t,\"AmmoJSPlugin\",(function(){return bc})),i.d(t,\"OimoJSPlugin\",(function(){return gc})),i.d(t,\"AnaglyphPostProcess\",(function(){return _i})),i.d(t,\"BlackAndWhitePostProcess\",(function(){return Gd})),i.d(t,\"BloomEffect\",(function(){return Kd})),i.d(t,\"BloomMergePostProcess\",(function(){return Yd})),i.d(t,\"BlurPostProcess\",(function(){return eo})),i.d(t,\"ChromaticAberrationPostProcess\",(function(){return qd})),i.d(t,\"CircleOfConfusionPostProcess\",(function(){return Jd})),i.d(t,\"ColorCorrectionPostProcess\",(function(){return ef})),i.d(t,\"ConvolutionPostProcess\",(function(){return nf})),i.d(t,\"DepthOfFieldBlurPostProcess\",(function(){return rf})),i.d(t,\"DepthOfFieldEffectBlurLevel\",(function(){return af})),i.d(t,\"DepthOfFieldEffect\",(function(){return lf})),i.d(t,\"DepthOfFieldMergePostProcessOptions\",(function(){return sf})),i.d(t,\"DepthOfFieldMergePostProcess\",(function(){return cf})),i.d(t,\"DisplayPassPostProcess\",(function(){return hf})),i.d(t,\"ExtractHighlightsPostProcess\",(function(){return Hd})),i.d(t,\"FilterPostProcess\",(function(){return ff})),i.d(t,\"FxaaPostProcess\",(function(){return mf})),i.d(t,\"GrainPostProcess\",(function(){return vf})),i.d(t,\"HighlightsPostProcess\",(function(){return yf})),i.d(t,\"ImageProcessingPostProcess\",(function(){return Yi})),i.d(t,\"MotionBlurPostProcess\",(function(){return Rf})),i.d(t,\"PassPostProcess\",(function(){return di})),i.d(t,\"PassCubePostProcess\",(function(){return fi})),i.d(t,\"PostProcess\",(function(){return li})),i.d(t,\"PostProcessManager\",(function(){return Ii.a})),i.d(t,\"RefractionPostProcess\",(function(){return Of})),i.d(t,\"DefaultRenderingPipeline\",(function(){return wf})),i.d(t,\"LensRenderingPipeline\",(function(){return Uf})),i.d(t,\"SSAO2RenderingPipeline\",(function(){return Gf})),i.d(t,\"SSAORenderingPipeline\",(function(){return Wf})),i.d(t,\"StandardRenderingPipeline\",(function(){return Qf})),i.d(t,\"PostProcessRenderEffect\",(function(){return jd})),i.d(t,\"PostProcessRenderPipeline\",(function(){return Df})),i.d(t,\"PostProcessRenderPipelineManager\",(function(){return Nf})),i.d(t,\"PostProcessRenderPipelineManagerSceneComponent\",(function(){return Lf})),i.d(t,\"SharpenPostProcess\",(function(){return If})),i.d(t,\"StereoscopicInterlacePostProcessI\",(function(){return Zf})),i.d(t,\"StereoscopicInterlacePostProcess\",(function(){return Jf})),i.d(t,\"TonemappingOperator\",(function(){return ep})),i.d(t,\"TonemapPostProcess\",(function(){return tp})),i.d(t,\"VolumetricLightScatteringPostProcess\",(function(){return op})),i.d(t,\"VRDistortionCorrectionPostProcess\",(function(){return xi})),i.d(t,\"VRMultiviewToSingleviewPostProcess\",(function(){return Fi})),i.d(t,\"ScreenSpaceReflectionPostProcess\",(function(){return Yf})),i.d(t,\"ScreenSpaceCurvaturePostProcess\",(function(){return sp})),i.d(t,\"ReflectionProbe\",(function(){return yc})),i.d(t,\"BoundingBoxRenderer\",(function(){return cp})),i.d(t,\"DepthRenderer\",(function(){return ks})),i.d(t,\"DepthRendererSceneComponent\",(function(){return lp})),i.d(t,\"EdgesRenderer\",(function(){return dp})),i.d(t,\"LineEdgesRenderer\",(function(){return fp})),i.d(t,\"GeometryBufferRenderer\",(function(){return Sf})),i.d(t,\"GeometryBufferRendererSceneComponent\",(function(){return Pf})),i.d(t,\"PrePassRenderer\",(function(){return pp})),i.d(t,\"PrePassRendererSceneComponent\",(function(){return _p})),i.d(t,\"SubSurfaceSceneComponent\",(function(){return Tp})),i.d(t,\"OutlineRenderer\",(function(){return Ap})),i.d(t,\"RenderingGroup\",(function(){return Pp.a})),i.d(t,\"RenderingGroupInfo\",(function(){return Di.a})),i.d(t,\"RenderingManager\",(function(){return Di.b})),i.d(t,\"UtilityLayerRenderer\",(function(){return Cr.a})),i.d(t,\"Scene\",(function(){return Q.a})),i.d(t,\"SceneComponentConstants\",(function(){return Me.a})),i.d(t,\"Stage\",(function(){return Me.b})),i.d(t,\"Sprite\",(function(){return Cp})),i.d(t,\"SpriteManager\",(function(){return Ip})),i.d(t,\"SpriteMap\",(function(){return wp})),i.d(t,\"SpritePackedManager\",(function(){return Fp})),i.d(t,\"SpriteSceneComponent\",(function(){return Rp})),i.d(t,\"AlphaState\",(function(){return Bp.a})),i.d(t,\"DepthCullingState\",(function(){return Up.a})),i.d(t,\"StencilState\",(function(){return Vp.a})),i.d(t,\"AndOrNotEvaluator\",(function(){return kp.a})),i.d(t,\"AssetTaskState\",(function(){return Lp})),i.d(t,\"AbstractAssetTask\",(function(){return Gp})),i.d(t,\"AssetsProgressEvent\",(function(){return jp})),i.d(t,\"ContainerAssetTask\",(function(){return Wp})),i.d(t,\"MeshAssetTask\",(function(){return Hp})),i.d(t,\"TextFileAssetTask\",(function(){return Xp})),i.d(t,\"BinaryFileAssetTask\",(function(){return Yp})),i.d(t,\"ImageAssetTask\",(function(){return Kp})),i.d(t,\"TextureAssetTask\",(function(){return Qp})),i.d(t,\"CubeTextureAssetTask\",(function(){return qp})),i.d(t,\"HDRCubeTextureAssetTask\",(function(){return Zp})),i.d(t,\"EquiRectangularCubeTextureAssetTask\",(function(){return Jp})),i.d(t,\"AssetsManager\",(function(){return $p})),i.d(t,\"BasisTranscodeConfiguration\",(function(){return zc})),i.d(t,\"BasisTools\",(function(){return Gc})),i.d(t,\"DDSTools\",(function(){return Ea})),i.d(t,\"expandToProperty\",(function(){return w.b})),i.d(t,\"serialize\",(function(){return w.c})),i.d(t,\"serializeAsTexture\",(function(){return w.m})),i.d(t,\"serializeAsColor3\",(function(){return w.e})),i.d(t,\"serializeAsFresnelParameters\",(function(){return w.h})),i.d(t,\"serializeAsVector2\",(function(){return w.n})),i.d(t,\"serializeAsVector3\",(function(){return w.o})),i.d(t,\"serializeAsMeshReference\",(function(){return w.k})),i.d(t,\"serializeAsColorCurves\",(function(){return w.g})),i.d(t,\"serializeAsColor4\",(function(){return w.f})),i.d(t,\"serializeAsImageProcessingConfiguration\",(function(){return w.i})),i.d(t,\"serializeAsQuaternion\",(function(){return w.l})),i.d(t,\"serializeAsMatrix\",(function(){return w.j})),i.d(t,\"serializeAsCameraReference\",(function(){return w.d})),i.d(t,\"SerializationHelper\",(function(){return w.a})),i.d(t,\"Deferred\",(function(){return e_})),i.d(t,\"EnvironmentTextureTools\",(function(){return ir})),i.d(t,\"MeshExploder\",(function(){return t_})),i.d(t,\"FilesInput\",(function(){return i_})),i.d(t,\"CubeMapToSphericalPolynomialTools\",(function(){return $n})),i.d(t,\"HDRTools\",(function(){return nc})),i.d(t,\"PanoramaToCubeMapTools\",(function(){return ic})),i.d(t,\"KhronosTextureContainer\",(function(){return Pa})),i.d(t,\"EventState\",(function(){return o.a})),i.d(t,\"Observer\",(function(){return o.d})),i.d(t,\"MultiObserver\",(function(){return o.b})),i.d(t,\"Observable\",(function(){return o.c})),i.d(t,\"PerformanceMonitor\",(function(){return n_.a})),i.d(t,\"RollingAverage\",(function(){return n_.b})),i.d(t,\"PromisePolyfill\",(function(){return r_.a})),i.d(t,\"SceneOptimization\",(function(){return o_})),i.d(t,\"TextureOptimization\",(function(){return a_})),i.d(t,\"HardwareScalingOptimization\",(function(){return s_})),i.d(t,\"ShadowsOptimization\",(function(){return c_})),i.d(t,\"PostProcessesOptimization\",(function(){return l_})),i.d(t,\"LensFlaresOptimization\",(function(){return u_})),i.d(t,\"CustomOptimization\",(function(){return h_})),i.d(t,\"ParticlesOptimization\",(function(){return d_})),i.d(t,\"RenderTargetsOptimization\",(function(){return f_})),i.d(t,\"MergeMeshesOptimization\",(function(){return p_})),i.d(t,\"SceneOptimizerOptions\",(function(){return __})),i.d(t,\"SceneOptimizer\",(function(){return m_})),i.d(t,\"SceneSerializer\",(function(){return y_})),i.d(t,\"SmartArray\",(function(){return oi.a})),i.d(t,\"SmartArrayNoDuplicate\",(function(){return oi.b})),i.d(t,\"StringDictionary\",(function(){return Mt.a})),i.d(t,\"Tags\",(function(){return T_.a})),i.d(t,\"TextureTools\",(function(){return E_})),i.d(t,\"TGATools\",(function(){return Uc})),i.d(t,\"Tools\",(function(){return Ce.b})),i.d(t,\"className\",(function(){return Ce.c})),i.d(t,\"AsyncLoop\",(function(){return Ce.a})),i.d(t,\"VideoRecorder\",(function(){return S_})),i.d(t,\"JoystickAxis\",(function(){return Ot})),i.d(t,\"VirtualJoystick\",(function(){return It})),i.d(t,\"WorkerPool\",(function(){return Ca})),i.d(t,\"Logger\",(function(){return m.a})),i.d(t,\"_TypeStore\",(function(){return c.a})),i.d(t,\"FilesInputStore\",(function(){return dr.a})),i.d(t,\"DeepCopier\",(function(){return O.a})),i.d(t,\"PivotTools\",(function(){return We.a})),i.d(t,\"PrecisionDate\",(function(){return q.a})),i.d(t,\"ScreenshotTools\",(function(){return A_})),i.d(t,\"WebRequest\",(function(){return V.a})),i.d(t,\"InspectableType\",(function(){return zp})),i.d(t,\"BRDFTextureTools\",(function(){return To})),i.d(t,\"RGBDTextureTools\",(function(){return yo})),i.d(t,\"ColorGradient\",(function(){return rd})),i.d(t,\"Color3Gradient\",(function(){return od})),i.d(t,\"FactorGradient\",(function(){return ad})),i.d(t,\"GradientHelper\",(function(){return sd})),i.d(t,\"PerfCounter\",(function(){return ns.a})),i.d(t,\"RetryStrategy\",(function(){return C_.a})),i.d(t,\"CanvasGenerator\",(function(){return Zi.a})),i.d(t,\"LoadFileError\",(function(){return Vn.b})),i.d(t,\"RequestFileError\",(function(){return Vn.d})),i.d(t,\"ReadFileError\",(function(){return Vn.c})),i.d(t,\"FileTools\",(function(){return Vn.a})),i.d(t,\"StringTools\",(function(){return io.a})),i.d(t,\"DataReader\",(function(){return R_})),i.d(t,\"MinMaxReducer\",(function(){return Gs})),i.d(t,\"DepthReducer\",(function(){return js})),i.d(t,\"DataStorage\",(function(){return x_})),i.d(t,\"SceneRecorder\",(function(){return O_})),i.d(t,\"KhronosTextureContainer2\",(function(){return Ra})),i.d(t,\"Trajectory\",(function(){return M_})),i.d(t,\"TrajectoryClassifier\",(function(){return L_})),i.d(t,\"TimerState\",(function(){return Ha})),i.d(t,\"setAndStartTimer\",(function(){return Qa})),i.d(t,\"AdvancedTimer\",(function(){return qa})),i.d(t,\"CopyTools\",(function(){return w_.a})),i.d(t,\"WebXRCamera\",(function(){return Ma})),i.d(t,\"WebXREnterExitUIButton\",(function(){return Xa})),i.d(t,\"WebXREnterExitUIOptions\",(function(){return Ya})),i.d(t,\"WebXREnterExitUI\",(function(){return Ka})),i.d(t,\"WebXRExperienceHelper\",(function(){return Na})),i.d(t,\"WebXRInput\",(function(){return Ga})),i.d(t,\"WebXRInputSource\",(function(){return za})),i.d(t,\"WebXRManagedOutputCanvasOptions\",(function(){return rn})),i.d(t,\"WebXRManagedOutputCanvas\",(function(){return on})),i.d(t,\"WebXRState\",(function(){return $i})),i.d(t,\"WebXRTrackingState\",(function(){return en})),i.d(t,\"WebXRSessionManager\",(function(){return an})),i.d(t,\"WebXRDefaultExperienceOptions\",(function(){return Ja})),i.d(t,\"WebXRDefaultExperience\",(function(){return $a})),i.d(t,\"WebXRFeatureName\",(function(){return Ia})),i.d(t,\"WebXRFeaturesManager\",(function(){return Da})),i.d(t,\"WebXRAbstractFeature\",(function(){return ja})),i.d(t,\"WebXRHitTestLegacy\",(function(){return F_})),i.d(t,\"WebXRAnchorSystem\",(function(){return U_})),i.d(t,\"WebXRPlaneDetector\",(function(){return k_})),i.d(t,\"WebXRBackgroundRemover\",(function(){return z_})),i.d(t,\"WebXRMotionControllerTeleportation\",(function(){return Za})),i.d(t,\"WebXRControllerPointerSelection\",(function(){return Wa})),i.d(t,\"IWebXRControllerPhysicsOptions\",(function(){return G_})),i.d(t,\"WebXRControllerPhysics\",(function(){return j_})),i.d(t,\"WebXRHitTest\",(function(){return W_})),i.d(t,\"WebXRFeaturePointSystem\",(function(){return H_})),i.d(t,\"WebXRHand\",(function(){return X_})),i.d(t,\"WebXRHandTracking\",(function(){return Y_})),i.d(t,\"WebXRAbstractMotionController\",(function(){return wa})),i.d(t,\"WebXRControllerComponent\",(function(){return La})),i.d(t,\"WebXRGenericTriggerMotionController\",(function(){return Fa})),i.d(t,\"WebXRMicrosoftMixedRealityController\",(function(){return K_})),i.d(t,\"WebXRMotionControllerManager\",(function(){return Va})),i.d(t,\"WebXROculusTouchMotionController\",(function(){return q_})),i.d(t,\"WebXRHTCViveMotionController\",(function(){return J_})),i.d(t,\"WebXRProfiledMotionController\",(function(){return Ua}));var n=i(35),r=i(91),o=i(6),a=i(0),s=i(9),c=i(11),l=function(){function e(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new o.c,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):e.trigger?this.trigger=e.trigger:this.trigger=e,this._nextActiveAction=this,this._condition=t}return e.prototype._prepare=function(){},e.prototype.getTriggerParameter=function(){return this._triggerParameter},e.prototype._executeCurrent=function(e){if(this._nextActiveAction._condition){var t=this._nextActiveAction._condition,i=this._actionManager.getScene().getRenderId();if(t._evaluationId===i){if(!t._currentResult)return}else{if(t._evaluationId=i,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this.onBeforeExecuteObservable.notifyObservers(this),this._nextActiveAction.execute(e),this.skipToNextActiveAction()},e.prototype.execute=function(e){},e.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},e.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(e){},e.prototype._serialize=function(e,t){var i={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(i),this._condition){var n=this._condition.serialize();return n.children.push(i),t&&t.children.push(n),n}return t&&t.children.push(i),i},e._SerializeValueAsString=function(e){return\"number\"==typeof e?e.toString():\"boolean\"==typeof e?e?\"true\":\"false\":e instanceof a.d?e.x+\", \"+e.y:e instanceof a.e?e.x+\", \"+e.y+\", \"+e.z:e instanceof s.a?e.r+\", \"+e.g+\", \"+e.b:e instanceof s.b?e.r+\", \"+e.g+\", \"+e.b+\", \"+e.a:e},e._GetTargetProperty=function(e){return{name:\"target\",targetType:e._isMesh?\"MeshProperties\":e._isLight?\"LightProperties\":e._isCamera?\"CameraProperties\":\"SceneProperties\",value:e._isScene?\"Scene\":e.name}},e}();c.a.RegisteredTypes[\"BABYLON.Action\"]=l;var u=i(47),h=i(1),d=function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e}(),f=function(e){function t(i,n,r,o,a){void 0===a&&(a=t.IsEqual);var s=e.call(this,i)||this;return s.propertyPath=r,s.value=o,s.operator=a,s._target=n,s._effectiveTarget=s._getEffectiveTarget(n,s.propertyPath),s._property=s._getProperty(s.propertyPath),s}return Object(h.d)(t,e),Object.defineProperty(t,\"IsEqual\",{get:function(){return t._IsEqual},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"IsDifferent\",{get:function(){return t._IsDifferent},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"IsGreater\",{get:function(){return t._IsGreater},enumerable:!1,configurable:!0}),Object.defineProperty(t,\"IsLesser\",{get:function(){return t._IsLesser},enumerable:!1,configurable:!0}),t.prototype.isValid=function(){switch(this.operator){case t.IsGreater:return this._effectiveTarget[this._property]>this.value;case t.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene.actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,t){for(var i=0;i=t.OnPickTrigger&&i.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"hasPickTriggers\",{get:function(){for(var e=0;e=t.OnPickTrigger&&i.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(m.a.Warn(\"OnEveryFrameTrigger can only be used with scene.actionManager\"),null):(this.actions.push(e),t.Triggers[e.trigger]?t.Triggers[e.trigger]++:t.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)},t.prototype.unregisterAction=function(e){var i=this.actions.indexOf(e);return-1!==i&&(this.actions.splice(i,1),t.Triggers[e.trigger]-=1,0===t.Triggers[e.trigger]&&delete t.Triggers[e.trigger],e._actionManager=null,!0)},t.prototype.processTrigger=function(e,i){for(var n=0;n0;if(2===e.type?h.push(r):h.push(i),m){for(var g=new Array,v=0;v0){var _=p.properties[0].value,m=null===p.properties[0].targetType?_:n.getMeshByName(_);m._meshId&&(m.mesh=n.getMeshByID(m._meshId)),h={trigger:t[p.name],parameter:m}}else h=t[p.name];for(var g=0;g=0?i:0;var c=0,l=s._keys[0],u=s._keys.length-1,h=s._keys[u],d={referenceValue:l.value,referencePosition:a.c.Vector3[0],referenceQuaternion:a.c.Quaternion[0],referenceScaling:a.c.Vector3[1],keyPosition:a.c.Vector3[2],keyQuaternion:a.c.Quaternion[1],keyScaling:a.c.Vector3[3]},f=!1,p=l.frame,_=h.frame;if(n){var m=s.getRange(n);m&&(p=m.from,_=m.to)}var g=l.frame===p,v=h.frame===_;if(1===s._keys.length){var b=s._getKeyValue(s._keys[0]);d.referenceValue=b.clone?b.clone():b,f=!0}else if(i<=l.frame){b=s._getKeyValue(l.value);d.referenceValue=b.clone?b.clone():b,f=!0}else if(i>=h.frame){b=s._getKeyValue(h.value);d.referenceValue=b.clone?b.clone():b,f=!0}for(var y=0;!f||!g||!v&&y=T.frame&&i<=E.frame){b=void 0;if(i===T.frame)b=s._getKeyValue(T.value);else if(i===E.frame)b=s._getKeyValue(E.value);else{var S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};b=s._interpolate(i,S)}d.referenceValue=b.clone?b.clone():b,f=!0}if(!g&&p>=T.frame&&p<=E.frame){if(p===T.frame)c=y;else if(p===E.frame)c=y+1;else{S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};var A={frame:p,value:(b=s._interpolate(p,S)).clone?b.clone():b};s._keys.splice(y+1,0,A),c=y+1}g=!0}if(!v&&_>=T.frame&&_<=E.frame){if(_===T.frame)u=y;else if(_===E.frame)u=y+1;else{S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT},A={frame:_,value:(b=s._interpolate(_,S)).clone?b.clone():b};s._keys.splice(y+1,0,A),u=y+1}v=!0}y++}s.dataType===e.ANIMATIONTYPE_QUATERNION?d.referenceValue.normalize().conjugateInPlace():s.dataType===e.ANIMATIONTYPE_MATRIX&&(d.referenceValue.decompose(d.referenceScaling,d.referenceQuaternion,d.referencePosition),d.referenceQuaternion.normalize().conjugateInPlace());for(y=c;y<=u;y++){A=s._keys[y];if(!y||s.dataType===e.ANIMATIONTYPE_FLOAT||A.value!==l.value)switch(s.dataType){case e.ANIMATIONTYPE_MATRIX:A.value.decompose(d.keyScaling,d.keyQuaternion,d.keyPosition),d.keyPosition.subtractInPlace(d.referencePosition),d.keyScaling.divideInPlace(d.referenceScaling),d.referenceQuaternion.multiplyToRef(d.keyQuaternion,d.keyQuaternion),a.a.ComposeToRef(d.keyScaling,d.keyQuaternion,d.keyPosition,A.value);break;case e.ANIMATIONTYPE_QUATERNION:d.referenceValue.multiplyToRef(A.value,A.value);break;case e.ANIMATIONTYPE_VECTOR2:case e.ANIMATIONTYPE_VECTOR3:case e.ANIMATIONTYPE_COLOR3:case e.ANIMATIONTYPE_COLOR4:A.value.subtractToRef(d.referenceValue,A.value);break;case e.ANIMATIONTYPE_SIZE:A.value.width-=d.referenceValue.width,A.value.height-=d.referenceValue.height;break;default:A.value-=d.referenceValue}}return s},e.TransitionTo=function(e,t,i,n,r,o,a,s){if(void 0===s&&(s=null),a<=0)return i[e]=t,s&&s(),null;var c=r*(a/1e3);o.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:c,value:t}]),i.animations||(i.animations=[]),i.animations.push(o);var l=n.beginAnimation(i,0,c,!1);return l.onAnimationEnd=s,l},Object.defineProperty(e.prototype,\"runtimeAnimations\",{get:function(){return this._runtimeAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"hasRunningRuntimeAnimations\",{get:function(){for(var e=0,t=this._runtimeAnimations;e=0;o--)this._keys[o].frame>=n&&this._keys[o].frame<=r&&this._keys.splice(o,1);this._ranges[e]=null}},e.prototype.getRange=function(e){return this._ranges[e]},e.prototype.getKeys=function(){return this._keys},e.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t0)return i.highLimitValue.clone?i.highLimitValue.clone():i.highLimitValue;var n=this._keys;if(1===n.length)return this._getKeyValue(n[0].value);var r=i.key;if(n[r].frame>=t)for(;r-1>=0&&n[r].frame>=t;)r--;for(var o=r;o=t){i.key=o;var s=n[o],c=this._getKeyValue(s.value);if(s.interpolation===N.STEP)return c;var l=this._getKeyValue(a.value),u=void 0!==s.outTangent&&void 0!==a.inTangent,h=a.frame-s.frame,d=(t-s.frame)/h,f=this.getEasingFunction();switch(null!=f&&(d=f.ease(d)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var p=u?this.floatInterpolateFunctionWithTangents(c,s.outTangent*h,l,a.inTangent*h,d):this.floatInterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return p;case e.ANIMATIONLOOPMODE_RELATIVE:return i.offsetValue*i.repeatCount+p}break;case e.ANIMATIONTYPE_QUATERNION:var _=u?this.quaternionInterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.quaternionInterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return _;case e.ANIMATIONLOOPMODE_RELATIVE:return _.addInPlace(i.offsetValue.scale(i.repeatCount))}return _;case e.ANIMATIONTYPE_VECTOR3:var m=u?this.vector3InterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.vector3InterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return m.add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_VECTOR2:var g=u?this.vector2InterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.vector2InterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_SIZE:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_COLOR3:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_COLOR4:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color4InterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color4InterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_MATRIX:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:if(e.AllowMatricesInterpolation)return this.matrixInterpolateFunction(c,l,d,i.workValue);case e.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(n[n.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,i,n,r){return e.AllowMatrixDecomposeForInterpolation?r?(a.a.DecomposeLerpToRef(t,i,n,r),r):a.a.DecomposeLerp(t,i,n):r?(a.a.LerpToRef(t,i,n,r),r):a.a.Lerp(t,i,n)},e.prototype.clone=function(){var t=new e(this.name,this.targetPropertyPath.join(\".\"),this.framePerSecond,this.dataType,this.loopMode);if(t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,this._keys&&t.setKeys(this._keys),this._ranges)for(var i in t._ranges={},this._ranges){var n=this._ranges[i];n&&(t._ranges[i]=n.clone())}return t},e.prototype.setKeys=function(e){this._keys=e.slice(0)},e.prototype.serialize=function(){var t={};t.name=this.name,t.property=this.targetProperty,t.framePerSecond=this.framePerSecond,t.dataType=this.dataType,t.loopBehavior=this.loopMode,t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed;var i=this.dataType;t.keys=[];for(var n=this.getKeys(),r=0;r=1&&(l=h.values[1]),h.values.length>=2&&(u=h.values[2]);break;case e.ANIMATIONTYPE_QUATERNION:if(i=a.b.FromArray(h.values),h.values.length>=8){var d=a.b.FromArray(h.values.slice(4,8));d.equals(a.b.Zero())||(l=d)}if(h.values.length>=12){var f=a.b.FromArray(h.values.slice(8,12));f.equals(a.b.Zero())||(u=f)}break;case e.ANIMATIONTYPE_MATRIX:i=a.a.FromArray(h.values);break;case e.ANIMATIONTYPE_COLOR3:i=s.a.FromArray(h.values);break;case e.ANIMATIONTYPE_COLOR4:i=s.b.FromArray(h.values);break;case e.ANIMATIONTYPE_VECTOR3:default:i=a.e.FromArray(h.values)}var p={};p.frame=h.frame,p.value=i,null!=l&&(p.inTangent=l),null!=u&&(p.outTangent=u),c.push(p)}if(r.setKeys(c),t.ranges)for(n=0;n0&&h.forEach((function(e){r._events.push(e._clone())})),this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}return Object.defineProperty(e.prototype,\"currentFrame\",{get:function(){return this._currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"weight\",{get:function(){return this._weight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"currentValue\",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"targetPath\",{get:function(){return this._targetPath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"target\",{get:function(){return this._currentActiveTarget},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isAdditive\",{get:function(){return this._host&&this._host.isAdditive},enumerable:!1,configurable:!0}),e.prototype._preparePath=function(e,t){void 0===t&&(t=0);var i=this._animation.targetPropertyPath;if(i.length>1){for(var n=e[i[0]],r=1;r-1&&this._animation.runtimeAnimations.splice(e,1)},e.prototype.setValue=function(e,t){if(this._targetIsArray)for(var i=0;it[t.length-1].frame&&(e=t[t.length-1].frame);var i=this._events;if(i.length)for(var n=0;nthis._maxFrame)&&(t=this._minFrame),(ithis._maxFrame)&&(i=this._maxFrame);var l,u,h=i-t,d=e*(a.framePerSecond*r)/1e3+this._ratioOffset,f=0;if(this._previousDelay=e,this._previousRatio=d,!n&&i>=t&&d>=h)c=!1,f=a._getKeyValue(this._maxValue);else if(!n&&t>=i&&d<=h)c=!1,f=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==z.ANIMATIONLOOPMODE_CYCLE){var p=i.toString()+t.toString();if(!this._offsetsCache[p]){this._animationState.repeatCount=0,this._animationState.loopMode=z.ANIMATIONLOOPMODE_CYCLE;var _=a._interpolate(t,this._animationState),m=a._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case z.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=m-_;break;case z.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=m.subtract(_);break;case z.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=m.subtract(_)}this._highLimitsCache[p]=m}f=this._highLimitsCache[p],l=this._offsetsCache[p]}if(void 0===l)switch(a.dataType){case z.ANIMATIONTYPE_FLOAT:l=0;break;case z.ANIMATIONTYPE_QUATERNION:l=j;break;case z.ANIMATIONTYPE_VECTOR3:l=W;break;case z.ANIMATIONTYPE_VECTOR2:l=H;break;case z.ANIMATIONTYPE_SIZE:l=X;break;case z.ANIMATIONTYPE_COLOR3:l=Y}if(this._host&&this._host.syncRoot){var g=this._host.syncRoot;u=t+(i-t)*((g.masterFrame-g.fromFrame)/(g.toFrame-g.fromFrame))}else u=c&&0!==h?t+d%h:i;var v=this._events;if((h>0&&this.currentFrame>u||h<0&&this.currentFrame>0,this._animationState.highLimitValue=f,this._animationState.offsetValue=l;var y=a._interpolate(u,this._animationState);if(this.setValue(y,o),v.length)for(b=0;b0&&u>=v[b].frame&&v[b].frame>=t||h<0&&u<=v[b].frame&&v[b].frame<=t){var T=v[b];T.isDone||(T.onlyOnce&&(v.splice(b,1),b--),T.isDone=!0,T.action(u))}return c||(this._stopped=!0),c},e}(),Q=i(20),q=i(57),Z=i(44),J=i(23),$=function(e){function t(t,i,n,r,o,s,c){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=null);var l=e.call(this,t,i.getScene())||this;return l.name=t,l.children=new Array,l.animations=new Array,l._index=null,l._absoluteTransform=new a.a,l._invertedAbsoluteTransform=new a.a,l._scalingDeterminant=1,l._worldTransform=new a.a,l._needToDecompose=!0,l._needToCompose=!1,l._linkedTransformNode=null,l._waitingTransformNodeId=null,l._skeleton=i,l._localMatrix=r?r.clone():a.a.Identity(),l._restPose=o||l._localMatrix.clone(),l._bindPose=l._localMatrix.clone(),l._baseMatrix=s||l._localMatrix.clone(),l._index=c,i.bones.push(l),l.setParent(n,!1),(s||r)&&l._updateDifferenceMatrix(),l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"_matrix\",{get:function(){return this._compose(),this._localMatrix},set:function(e){this._localMatrix.copyFrom(e),this._needToDecompose=!0},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"Bone\"},t.prototype.getSkeleton=function(){return this._skeleton},t.prototype.getParent=function(){return this._parent},t.prototype.getChildren=function(){return this.children},t.prototype.getIndex=function(){return null===this._index?this.getSkeleton().bones.indexOf(this):this._index},t.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i,1)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix(),this.markAsDirty()}},t.prototype.getLocalMatrix=function(){return this._compose(),this._localMatrix},t.prototype.getBaseMatrix=function(){return this._baseMatrix},t.prototype.getRestPose=function(){return this._restPose},t.prototype.setRestPose=function(e){this._restPose.copyFrom(e)},t.prototype.getBindPose=function(){return this._bindPose},t.prototype.setBindPose=function(e){this._bindPose.copyFrom(e)},t.prototype.getWorldMatrix=function(){return this._worldTransform},t.prototype.returnToRest=function(){this._skeleton._numBonesWithLinkedTransformNode>0?this.updateMatrix(this._restPose,!1,!1):this.updateMatrix(this._restPose,!1,!0)},t.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},t.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},t.prototype.linkTransformNode=function(e){this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++},t.prototype.getTransformNode=function(){return this._linkedTransformNode},Object.defineProperty(t.prototype,\"position\",{get:function(){return this._decompose(),this._localPosition},set:function(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"rotation\",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"rotationQuaternion\",{get:function(){return this._decompose(),this._localRotation},set:function(e){this.setRotationQuaternion(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"scaling\",{get:function(){return this.getScale()},set:function(e){this.setScale(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"animationPropertiesOverride\",{get:function(){return this._skeleton.animationPropertiesOverride},enumerable:!1,configurable:!0}),t.prototype._decompose=function(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=a.e.Zero(),this._localRotation=a.b.Zero(),this._localPosition=a.e.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))},t.prototype._compose=function(){this._needToCompose&&(this._localScaling?(this._needToCompose=!1,a.a.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix)):this._needToCompose=!1)},t.prototype.updateMatrix=function(e,t,i){void 0===t&&(t=!0),void 0===i&&(i=!0),this._baseMatrix.copyFrom(e),t&&this._updateDifferenceMatrix(),i?(this._needToCompose=!1,this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose()):this.markAsDirty()},t.prototype._updateDifferenceMatrix=function(e,t){if(void 0===t&&(t=!0),e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),t)for(var i=0;i-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this},e.prototype.getAnimations=function(){return this._runtimeAnimations},e.prototype.appendAnimations=function(e,t){for(var i=this,n=0;n-1){for(var n=(o=this._runtimeAnimations).length-1;n>=0;n--){var r=o[n];e&&r.animation.name!=e||(t&&!t(r.target)||(r.dispose(),o.splice(n,1)))}0==o.length&&(this._scene._activeAnimatables.splice(i,1),this._raiseOnAnimationEnd())}}else{if((n=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(n,1);var o=this._runtimeAnimations;for(n=0;n0)return;this._animationTimeLast=e}this.deltaTime=this.useConstantAnimationDeltaTime?16:(e-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=e;var t=this._activeAnimatables;if(0!==t.length){this._animationTime+=this.deltaTime;for(var i=this._animationTime,n=0;ni&&r>0&&(r*=-1),s&&this.stopAnimation(e,void 0,c),a||(a=new ee(this,e,t,i,n,r,o,void 0,l,u));var h=!c||c(e);if(e.animations&&h&&a.appendAnimations(e,e.animations),e.getAnimatables)for(var d=e.getAnimatables(),f=0;fn&&o>0&&(o*=-1),new ee(this,e,i,n,r,o,a,t,s,c)},Q.a.prototype.beginDirectHierarchyAnimation=function(e,t,i,n,r,o,a,s,c,l){void 0===l&&(l=!1);var u=e.getDescendants(t),h=[];h.push(this.beginDirectAnimation(e,i,n,r,o,a,s,c,l));for(var d=0,f=u;d0)r.copyFrom(n);else if(1===e.animations.length){if(a.b.SlerpToRef(n,i.currentValue,Math.min(1,e.totalWeight),r),0===e.totalAdditiveWeight)return r}else if(e.animations.length>1){var o=1,s=void 0,c=void 0;if(e.totalWeight<1){var l=1-e.totalWeight;c=[],(s=[]).push(n),c.push(l)}else{if(2===e.animations.length&&(a.b.SlerpToRef(e.animations[0].currentValue,e.animations[1].currentValue,e.animations[1].weight/e.totalWeight,t),0===e.totalAdditiveWeight))return t;s=[],c=[],o=e.totalWeight}for(var u=0;u=l&&a.frame<=u&&(n?(c=a.value.clone(),_?(s=c.getTranslation(),c.setTranslation(s.scaleInPlace(m))):g&&r?(s=c.getTranslation(),c.setTranslation(s.multiplyInPlace(r))):c=a.value):c=a.value,v.push({frame:a.frame+i,value:c}));return this.animations[0].createRange(t,l+i,u+i),!0};var te=function(){function e(){}return e.prototype.getClassName=function(){return\"TargetedAnimation\"},e.prototype.serialize=function(){var e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e},e}(),ie=function(){function e(e,t){void 0===t&&(t=null),this.name=e,this._targetedAnimations=new Array,this._animatables=new Array,this._from=Number.MAX_VALUE,this._to=-Number.MAX_VALUE,this._speedRatio=1,this._loopAnimation=!1,this._isAdditive=!1,this.onAnimationEndObservable=new o.c,this.onAnimationLoopObservable=new o.c,this.onAnimationGroupLoopObservable=new o.c,this.onAnimationGroupEndObservable=new o.c,this.onAnimationGroupPauseObservable=new o.c,this.onAnimationGroupPlayObservable=new o.c,this._scene=t||x.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}return Object.defineProperty(e.prototype,\"from\",{get:function(){return this._from},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"to\",{get:function(){return this._to},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isStarted\",{get:function(){return this._isStarted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isPlaying\",{get:function(){return this._isStarted&&!this._isPaused},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"speedRatio\",{get:function(){return this._speedRatio},set:function(e){if(this._speedRatio!==e){this._speedRatio=e;for(var t=0;tn[0].frame&&(this._from=n[0].frame),this._toe){var a={frame:e,value:r.value,inTangent:r.inTangent,outTangent:r.outTangent,interpolation:r.interpolation};n.splice(0,0,a)}if(o.framen&&this._speedRatio>0&&(this._speedRatio=-t);return this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this},e.prototype.pause=function(){if(!this._isStarted)return this;this._isPaused=!0;for(var e=0;e-1&&this._scene.animationGroups.splice(e,1),this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear(),this.onAnimationGroupLoopObservable.clear()},e.prototype._checkAnimationGroupEnded=function(e){var t=this._animatables.indexOf(e);t>-1&&this._animatables.splice(t,1),0===this._animatables.length&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},e.prototype.clone=function(t,i){for(var n=new e(t||this.name,this._scene),r=0,o=this._targetedAnimations;r=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e.EASINGMODE_EASEIN=0,e.EASINGMODE_EASEOUT=1,e.EASINGMODE_EASEINOUT=2,e}(),ae=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(oe),se=function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t}(oe),ce=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var n=e.call(this)||this;return n.bounces=t,n.bounciness=i,n}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var n=Math.pow(i,t),r=1-i,o=(1-n)/r+.5*n,a=e*o,s=Math.log(-a*(1-i)+1)/Math.log(i),c=Math.floor(s),l=c+1,u=(1-Math.pow(i,c))/(r*o),h=.5*(u+(1-Math.pow(i,l))/(r*o)),d=e-h,f=h-u;return-Math.pow(1/i,t-c)/(f*f)*(d-f)*(d+f)},t}(oe),le=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(oe),ue=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var n=e.call(this)||this;return n.oscillations=t,n.springiness=i,n}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t}(oe),he=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(oe),de=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(oe),fe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e},t}(oe),pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(oe),_e=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(oe),me=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(oe),ge=function(e){function t(t,i,n,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=1);var o=e.call(this)||this;return o.x1=t,o.y1=i,o.x2=n,o.y2=r,o}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return re.c.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(oe),ve=function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)},e}(),be=i(7),ye=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t}(n.a),Te=function(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]},Ee=function(e){function t(t){var i=e.call(this)||this;return i._wasAddedToScene=!1,i.scene=t,i.sounds=[],i.effectLayers=[],i.layers=[],i.lensFlareSystems=[],i.proceduralTextures=[],i.reflectionProbes=[],t.onDisposeObservable.add((function(){i._wasAddedToScene||i.dispose()})),i}return Object(h.d)(t,e),t.prototype.instantiateModelsToScene=function(e,t){var i=this;void 0===t&&(t=!1);var n={},r={},o=new Te,a=[],s=[],c={doNotInstantiate:!0},l=function(t,i){if(n[t.uniqueId]=i.uniqueId,r[i.uniqueId]=i,e&&(i.name=e(t.name)),i instanceof be.a){var o=i;if(o.morphTargetManager){var a=t.morphTargetManager;o.morphTargetManager=a.clone();for(var s=0;s-1&&t.animations.splice(o,1)}},r=0,o=e.animations;r0&&(_=!0,this._soundLoaded(i));break;case\"String\":p.push(i);case\"Array\":0===p.length&&(p=i);for(var g=0;g0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if(Se.a.audioEngine.audioContext&&this._soundSource){var i=e?Se.a.audioEngine.audioContext.currentTime+e:Se.a.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=function(){t.isPlaying=!1},this.isPaused||(this._startOffset=0)}},e.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():Se.a.audioEngine.audioContext&&(this.stop(0),this._startOffset+=Se.a.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){Se.a.audioEngine.canUseWebAudio&&this._soundGain&&(t&&Se.a.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(Se.a.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,Se.a.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,Se.a.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e},e.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},e.prototype.getVolume=function(){return this._volume},e.prototype.attachToMesh=function(e){var t=this;this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play(0,this._offset,this._length))),this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)},e.prototype.detachFromMesh=function(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)},e.prototype._onRegisterAfterWorldMatrixUpdate=function(e){if(this._positionInEmitterSpace)e.worldMatrixFromCache.invertToRef(a.c.Matrix[0]),this.setPosition(a.c.Matrix[0].getTranslation());else if(e.getBoundingInfo){var t=e.getBoundingInfo();this.setPosition(t.boundingSphere.centerWorld)}else this.setPosition(e.absolutePosition);Se.a.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},e.prototype.clone=function(){var t=this;if(this._streaming)return null;var i=function(){t._isReadyToPlay?(r._audioBuffer=t.getAudioBuffer(),r._isReadyToPlay=!0,r.autoplay&&r.play(0,t._offset,t._length)):window.setTimeout(i,300)},n={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},r=new e(this.name+\"_cloned\",new ArrayBuffer(0),this._scene,null,n);return this.useCustomAttenuation&&r.setAttenuationFunction(this._customAttenuationFunction),r.setPosition(this._position),r.setPlaybackRate(this._playbackRate),i(),r},e.prototype.getAudioBuffer=function(){return this._audioBuffer},e.prototype.getSoundSource=function(){return this._soundSource},e.prototype.getSoundGain=function(){return this._soundGain},e.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId,metadata:this.metadata};return this.spatialSound&&(this._connectedTransformNode&&(e.connectedMeshId=this._connectedTransformNode.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},e.Parse=function(t,i,n,r){var o,s=t.name;o=t.url?n+t.url:n+s;var c,l={autoplay:t.autoplay,loop:t.loop,volume:t.volume,spatialSound:t.spatialSound,maxDistance:t.maxDistance,rolloffFactor:t.rolloffFactor,refDistance:t.refDistance,distanceModel:t.distanceModel,playbackRate:t.playbackRate};if(r){var u=function(){r._isReadyToPlay?(c._audioBuffer=r.getAudioBuffer(),c._isReadyToPlay=!0,c.autoplay&&c.play(0,c._offset,c._length)):window.setTimeout(u,300)};c=new e(s,new ArrayBuffer(0),i,null,l),u()}else c=new e(s,o,i,(function(){i._removePendingData(c)}),l),i._addPendingData(c);if(t.position){var h=a.e.FromArray(t.position);c.setPosition(h)}if(t.isDirectional&&(c.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var d=a.e.FromArray(t.localDirectionToMesh);c.setLocalDirectionToMesh(d)}if(t.connectedMeshId){var f=i.getMeshByID(t.connectedMeshId);f&&c.attachToMesh(f)}return t.metadata&&(c.metadata=t.metadata),c},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport(\"AudioSceneComponent\")},e}(),Oe=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,!this._options.mainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return e.prototype._initializeSoundTrackAudioGraph=function(){Se.a.audioEngine.canUseWebAudio&&Se.a.audioEngine.audioContext&&(this._outputAudioNode=Se.a.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(Se.a.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(Se.a.audioEngine&&Se.a.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},e.prototype.addSound=function(e){this._isInitialized||this._initializeSoundTrackAudioGraph(),Se.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&e.connectToSoundTrackAudioNode(this._outputAudioNode),e.soundTrackId&&(-1===e.soundTrackId?this._scene.mainSoundTrack.removeSound(e):this._scene.soundTracks&&this._scene.soundTracks[e.soundTrackId].removeSound(e)),this.soundCollection.push(e),e.soundTrackId=this.id},e.prototype.removeSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},e.prototype.setVolume=function(e){Se.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){if(Se.a.audioEngine.canUseWebAudio)for(var e=0;e0?i.activeCameras[0]:i.activeCamera){this._cachedCameraPosition.equals(o.globalPosition)||(this._cachedCameraPosition.copyFrom(o.globalPosition),n.audioContext.listener.setPosition(o.globalPosition.x,o.globalPosition.y,o.globalPosition.z)),o.rigCameras&&o.rigCameras.length>0&&(o=o.rigCameras[0]);var s=a.a.Invert(o.getViewMatrix()),c=a.e.TransformNormal(i.useRightHandedSystem?e._CameraDirectionRH:e._CameraDirectionLH,s);c.normalize(),isNaN(c.x)||isNaN(c.y)||isNaN(c.z)||this._cachedCameraDirection.equals(c)||(this._cachedCameraDirection.copyFrom(c),n.audioContext.listener.setOrientation(c.x,c.y,c.z,0,1,0))}else n.audioContext.listener.setPosition(0,0,0)}var l;for(l=0;l0?1/r:0,c=0;c0},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var i=this._attachedCamera.getScene();this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(e){e.type!==Ne.a.POINTERDOWN?e.type===Ne.a.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=q.a.Now,i=0;null!=t._lastFrameTime&&(i=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var n=e-t._lastInteractionTime-t._idleRotationWaitTime,r=Math.max(Math.min(n/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*r,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(i/1e3))}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},e.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},e.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},e.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=q.a.Now)},e.prototype._userIsMoving=function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},e}(),we=function(){function e(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"Bouncing\"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"autoTransitionRange\",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var i=this._attachedCamera;i&&(e?this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var i=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*i,t.upperRadiusTransitionRange=.05*i}})):this._onMeshTargetChangedObserver&&i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))}))},e.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},e.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},e.prototype._applyBoundRadiusAnimation=function(t){var i=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=z.CreateAnimation(\"radius\",z.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var n=z.TransitionTo(\"radius\",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return i._clearAnimationLocks()}));n&&this._animatables.push(n)}},e.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},e.EasingFunction=new se(.3),e.EasingMode=oe.EASINGMODE_EASEOUT,e}(),Fe=function(){function e(){this._mode=e.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"Framing\"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"mode\",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"radiusScale\",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"positionScale\",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"defaultElevation\",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"elevationReturnTime\",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"elevationReturnWaitTime\",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"zoomStopsAnimation\",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"framingTime\",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._attachedCamera=t;var n=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=n.onPrePointerObservable.add((function(e){e.type!==Ne.a.POINTERDOWN?e.type===Ne.a.POINTERUP&&(i._isPointerDown=!1):i._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&i.zoomOnMesh(e)})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){i._applyUserInteraction(),i._maintainCameraAboveGround()}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},e.prototype.zoomOnMesh=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var n=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(n.minimumWorld,n.maximumWorld,t,i)},e.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var n=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(n.min,n.max,t,i)},e.prototype.zoomOnMeshesHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null);for(var n=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new a.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;ol.upperRadiusLimit?l.upperRadiusLimit:c),c):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var i=q.a.Now-this._lastInteractionTime,n=.5*Math.PI-this._defaultElevation,r=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>r&&i>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=z.CreateAnimation(\"beta\",z.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=z.TransitionTo(\"beta\",n,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){t._clearAnimationLocks(),t.stopAllAnimations()}));o&&this._animatables.push(o)}}},e.prototype._getFrustumSlope=function(){var e=this._attachedCamera;if(!e)return a.d.Zero();var t=e.getScene().getEngine().getAspectRatio(e),i=Math.tan(e.fov/2),n=i*t;return new a.d(n,i)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=q.a.Now,this.stopAllAnimations(),this._clearAnimationLocks())},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()},Object.defineProperty(e.prototype,\"isUserIsMoving\",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!1,configurable:!0}),e.EasingFunction=new he,e.EasingMode=oe.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),Be=function(e,t,i,n){void 0===t&&(t=new a.e),void 0===i&&(i=0),void 0===n&&(n=!1),this.direction=e,this.rotatedDirection=t,this.diff=i,this.ignore=n},Ue=function(){function e(e){this.ui=e,this.name=\"AttachToBoxBehavior\",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new Be(a.e.Up()),new Be(a.e.Down()),new Be(a.e.Left()),new Be(a.e.Right()),new Be(a.e.Forward()),new Be(a.e.Forward().scaleInPlace(-1))],this._tmpMatrix=new a.a,this._tmpVector=new a.e,this._zeroVector=a.e.Zero(),this._lookAtTmpMatrix=new a.a}return e.prototype.init=function(){},e.prototype._closestFace=function(e){var t=this;return this._faceVectors.forEach((function(i){t._target.rotationQuaternion||(t._target.rotationQuaternion=a.b.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),a.e.TransformCoordinatesToRef(i.direction,t._tmpMatrix,i.rotatedDirection),i.diff=a.e.GetAngleBetweenVectors(i.rotatedDirection,e,a.e.Cross(i.rotatedDirection,e))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore||e.diff1)return e._setAllVisibility(e._ownerNode,1),void(e._hoverValue=e.fadeInTime+e.delay);if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return void(e._hoverValue=0);setTimeout(e._update,e._millisecondsPerFrame)}}}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"FadeInOut\"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){this._hovered=e,this._update()},e.prototype._setAllVisibility=function(e,t){var i=this;e.visibility=t,e.getChildMeshes().forEach((function(e){i._setAllVisibility(e,t)}))},e}(),ke=i(65),ze=function(){function e(){this._startDistance=0,this._initialScale=new a.e(0,0,0),this._targetScale=new a.e(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new ke.a({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new ke.a({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"MultiPointerScale\"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},e.prototype.attach=function(e){var t=this;this._ownerNode=e,this._dragBehaviorA.onDragStartObservable.add((function(i){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorA.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),this._dragBehaviorB.onDragStartObservable.add((function(i){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorB.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(e){e.onDragObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var e=t._getCurrentDistance()/t._startDistance;t._initialScale.scaleToRef(e,t._targetScale)}}))})),e.addBehavior(this._dragBehaviorA),e.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var i=t._targetScale.subtract(e.scaling).scaleInPlace(.1);i.length()>.01&&e.scaling.addInPlace(i)}}))},e.prototype.detach=function(){var e=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(t){t.onDragStartObservable.clear(),t.onDragObservable.clear(),e._ownerNode.removeBehavior(t)}))},e}(),Ge=i(31),je=i(24),We=i(60),He=function(){function e(){this._sceneRenderObserver=null,this._targetPosition=new a.e(0,0,0),this._moving=!1,this._startingOrientation=new a.b,this._attachedToElement=!1,this.zDragFactor=3,this.rotateDraggedObject=!0,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new o.c,this.onDragObservable=new o.c,this.onDragEndObservable=new o.c}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"SixDofDrag\"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},Object.defineProperty(e.prototype,\"_pointerCamera\",{get:function(){return this._scene.cameraToUseForPointers?this._scene.cameraToUseForPointers:this._scene.activeCamera},enumerable:!1,configurable:!0}),e.prototype.attach=function(t){var i=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new Q.a(this._scene.getEngine(),{virtual:!0}),e._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var n=null,r=new a.e(0,0,0);this._virtualOriginMesh=new Ge.a(\"\",e._virtualScene),this._virtualOriginMesh.rotationQuaternion=new a.b,this._virtualDragMesh=new Ge.a(\"\",e._virtualScene),this._virtualDragMesh.rotationQuaternion=new a.b;this._pointerObserver=this._scene.onPointerObservable.add((function(e,t){if(e.type==Ne.a.POINTERDOWN){if(!i.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.ray&&(u=e.pickInfo.pickedMesh,i._ownerNode==u||u.isDescendantOf(i._ownerNode))){i._pointerCamera&&i._pointerCamera.cameraRigMode==je.a.RIG_MODE_NONE&&e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),n=i._ownerNode,We.a._RemoveAndStorePivotPoint(n),r.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),i._virtualOriginMesh.removeChild(i._virtualDragMesh),n.computeWorldMatrix(),i._virtualDragMesh.position.copyFrom(n.absolutePosition),n.rotationQuaternion||(n.rotationQuaternion=a.b.RotationYawPitchRoll(n.rotation.y,n.rotation.x,n.rotation.z));var o=n.parent;n.setParent(null),i._virtualDragMesh.rotationQuaternion.copyFrom(n.rotationQuaternion),n.setParent(o),i._virtualOriginMesh.addChild(i._virtualDragMesh),i._targetPosition.copyFrom(i._virtualDragMesh.absolutePosition),i.dragging=!0,i.currentDraggingPointerID=e.event.pointerId,i.detachCameraControls&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.inputs.attachedToElement?(i._pointerCamera.detachControl(),i._attachedToElement=!0):i._attachedToElement=!1),We.a._RestorePivotPoint(n),i.onDragStartObservable.notifyObservers({})}}else if(e.type==Ne.a.POINTERUP||e.type==Ne.a.POINTERDOUBLETAP)i.currentDraggingPointerID==e.event.pointerId&&(i.dragging=!1,i._moving=!1,i.currentDraggingPointerID=-1,n=null,i._virtualOriginMesh.removeChild(i._virtualDragMesh),i.detachCameraControls&&i._attachedToElement&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.attachControl(!0),i._attachedToElement=!1),i.onDragEndObservable.notifyObservers({}));else if(e.type==Ne.a.POINTERMOVE&&i.currentDraggingPointerID==e.event.pointerId&&i.dragging&&e.pickInfo&&e.pickInfo.ray&&n){var s=i.zDragFactor;i._pointerCamera&&i._pointerCamera.cameraRigMode==je.a.RIG_MODE_NONE&&(e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),s=0);var c=e.pickInfo.ray.origin.subtract(r);r.copyFrom(e.pickInfo.ray.origin);var l=-a.e.Dot(c,e.pickInfo.ray.direction);i._virtualOriginMesh.addChild(i._virtualDragMesh),i._virtualDragMesh.position.z-=i._virtualDragMesh.position.z<1?l*i.zDragFactor:l*s*i._virtualDragMesh.position.z,i._virtualDragMesh.position.z<0&&(i._virtualDragMesh.position.z=0),i._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),i._virtualOriginMesh.removeChild(i._virtualDragMesh),i._targetPosition.copyFrom(i._virtualDragMesh.absolutePosition),n.parent&&a.e.TransformCoordinatesToRef(i._targetPosition,a.a.Invert(n.parent.getWorldMatrix()),i._targetPosition),i._moving||i._startingOrientation.copyFrom(i._virtualDragMesh.rotationQuaternion),i._moving=!0}var u}));var o=new a.b;this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(i.dragging&&i._moving&&n){if(We.a._RemoveAndStorePivotPoint(n),n.position.addInPlace(i._targetPosition.subtract(n.position).scale(i.dragDeltaRatio)),i.rotateDraggedObject){o.copyFrom(i._startingOrientation),o.x=-o.x,o.y=-o.y,o.z=-o.z,i._virtualDragMesh.rotationQuaternion.multiplyToRef(o,o),a.b.RotationYawPitchRollToRef(o.toEulerAngles(\"xyz\").y,0,0,o),o.multiplyToRef(i._startingOrientation,o);var e=n.parent;(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&(n.setParent(null),a.b.SlerpToRef(n.rotationQuaternion,o,i.dragDeltaRatio,n.rotationQuaternion),n.setParent(e))}We.a._RestorePivotPoint(n),i.onDragObservable.notifyObservers()}}))},e.prototype.detach=function(){this._scene&&(this.detachCameraControls&&this._attachedToElement&&this._pointerCamera&&!this._pointerCamera.leftCamera&&(this._pointerCamera.attachControl(!0),this._attachedToElement=!1),this._scene.onPointerObservable.remove(this._pointerObserver)),this._ownerNode&&this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),this._virtualOriginMesh&&this._virtualOriginMesh.dispose(),this._virtualDragMesh&&this._virtualDragMesh.dispose(),this.onDragEndObservable.clear(),this.onDragObservable.clear(),this.onDragStartObservable.clear()},e}(),Xe=function(){function e(e,t,i){if(this.targetPosition=a.e.Zero(),this.poleTargetPosition=a.e.Zero(),this.poleTargetLocalOffset=a.e.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=a.b.Identity(),this._bone1Mat=a.a.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=a.e.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var n=t.getPosition();if(t.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var r=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*r.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){e.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(e),c=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=a.e.Distance(s,c),this._bone2Length=a.e.Distance(c,l)}this._bone1.getRotationMatrixToRef(J.c.WORLD,e,this._bone1Mat),this.maxAngle=Math.PI,i&&(i.targetMesh&&(this.targetMesh=i.targetMesh,this.targetMesh.computeWorldMatrix(!0)),i.poleTargetMesh?(this.poleTargetMesh=i.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):i.poleTargetBone?this.poleTargetBone=i.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),i.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset),i.poleAngle&&(this.poleAngle=i.poleAngle),i.bendAxis&&this._bendAxis.copyFrom(i.bendAxis),i.maxAngle&&(this.maxAngle=i.maxAngle),i.slerpAmount&&(this.slerpAmount=i.slerpAmount))}}return Object.defineProperty(e.prototype,\"maxAngle\",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!1,configurable:!0}),e.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||null==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},e.prototype.update=function(){var t=this._bone1;if(t){var i=this.targetPosition,n=this.poleTargetPosition,r=e._tmpMats[0],o=e._tmpMats[1];this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&a.e.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var s=e._tmpVecs[0],c=e._tmpVecs[1],l=e._tmpVecs[2],u=e._tmpVecs[3],h=e._tmpVecs[4],d=e._tmpQuat;t.getAbsolutePositionToRef(this.mesh,s),n.subtractToRef(s,h),0==h.x&&0==h.y&&0==h.z?h.y=1:h.normalize(),i.subtractToRef(s,u),u.normalize(),a.e.CrossToRef(u,h,c),c.normalize(),a.e.CrossToRef(u,c,l),l.normalize(),a.a.FromXYZAxesToRef(l,u,c,r);var f=this._bone1Length,p=this._bone2Length,_=a.e.Distance(s,i);this._maxReach>0&&(_=Math.min(this._maxReach,_));var m=(p*p+_*_-f*f)/(2*p*_),g=(_*_+f*f-p*p)/(2*_*f);m>1&&(m=1),g>1&&(g=1),m<-1&&(m=-1),g<-1&&(g=-1);var v=Math.acos(m),b=Math.acos(g),y=-v-b;if(this._rightHandedSystem)a.a.RotationYawPitchRollToRef(0,0,this._adjustRoll,o),o.multiplyToRef(r,r),a.a.RotationAxisToRef(this._bendAxis,b,o),o.multiplyToRef(r,r);else{var T=e._tmpVecs[5];T.copyFrom(this._bendAxis),T.x*=-1,a.a.RotationAxisToRef(T,-b,o),o.multiplyToRef(r,r)}this.poleAngle&&(a.a.RotationAxisToRef(u,this.poleAngle,o),r.multiplyToRef(o,r)),this._bone1&&(this.slerpAmount<1?(this._slerping||a.b.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),a.b.FromRotationMatrixToRef(r,d),a.b.SlerpToRef(this._bone1Quat,d,this.slerpAmount,this._bone1Quat),y=this._bone2Ang*(1-this.slerpAmount)+y*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,J.c.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(r,J.c.WORLD,this.mesh),this._bone1Mat.copyFrom(r),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,y,J.c.LOCAL),this._bone2Ang=y}},e._tmpVecs=[a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero()],e._tmpQuat=a.b.Identity(),e._tmpMats=[a.a.Identity(),a.a.Identity()],e}(),Ye=function(){function e(e,t,i,n){if(this.upAxis=a.e.Up(),this.upAxisSpace=J.c.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=a.b.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=a.e.Forward(),this.mesh=e,this.bone=t,this.target=i,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var r=J.a.Y,o=J.a.X;null!=n.yawAxis&&(r=n.yawAxis.clone()).normalize(),null!=n.pitchAxis&&(o=n.pitchAxis.clone()).normalize();var s=a.e.Cross(o,r);this._transformYawPitch=a.a.Identity(),a.a.FromXYZAxesToRef(o,r,s,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=J.c.BONE||(this.upAxisSpace=J.c.LOCAL)}return Object.defineProperty(e.prototype,\"minYaw\",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"maxYaw\",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"minPitch\",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"maxPitch\",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),e.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,i=e._tmpVecs[0];t.getAbsolutePositionToRef(this.mesh,i);var n=this.target,r=e._tmpMats[0],o=e._tmpMats[1],s=this.mesh,c=t.getParent(),l=e._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==J.c.BONE&&c?(this._transformYawPitch&&a.e.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),c.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==J.c.LOCAL&&(s.getDirectionToRef(l,l),1==s.scaling.x&&1==s.scaling.y&&1==s.scaling.z||l.normalize());var u=!1,h=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(u=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(h=!0),u||h){var d=e._tmpMats[2],f=e._tmpMats[3];if(this.upAxisSpace==J.c.BONE&&1==l.y&&c)c.getRotationMatrixToRef(J.c.WORLD,this.mesh,d);else if(this.upAxisSpace!=J.c.LOCAL||1!=l.y||c){(_=e._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&a.e.TransformCoordinatesToRef(_,this._transformYawPitchInv,_),c?c.getDirectionToRef(_,this.mesh,_):s.getDirectionToRef(_,_);var p=a.e.Cross(l,_);p.normalize();var _=a.e.Cross(p,l);a.a.FromXYZAxesToRef(p,l,_,d)}else d.copyFrom(s.getWorldMatrix());d.invertToRef(f);var m=null;if(h){var g=e._tmpVecs[3];n.subtractToRef(i,g),a.e.TransformCoordinatesToRef(g,f,g),m=Math.sqrt(g.x*g.x+g.z*g.z);var v=Math.atan2(g.y,m),b=v;v>this._maxPitch?(g.y=this._maxPitchTan*m,b=this._maxPitch):vthis._maxYaw||yMath.PI?this._isAngleBetween(y,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,T=this._maxYaw):this._isAngleBetween(y,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,T=this._minYaw):y>this._maxYaw?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,T=this._maxYaw):yMath.PI){var E=e._tmpVecs[8];E.copyFrom(J.a.Z),this._transformYawPitch&&a.e.TransformCoordinatesToRef(E,this._transformYawPitchInv,E);var S=e._tmpMats[4];this._boneQuat.toRotationMatrix(S),this.mesh.getWorldMatrix().multiplyToRef(S,S),a.e.TransformCoordinatesToRef(E,S,E),a.e.TransformCoordinatesToRef(E,f,E);var A=Math.atan2(E.x,E.z);if(this._getAngleBetween(A,y)>this._getAngleBetween(A,this._midYawConstraint)){null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z));var P=this._getAngleBetween(A,this._maxYaw);this._getAngleBetween(A,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},e.prototype._getAngleBetween=function(e,t){var i=0;return(i=(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)?t-e:e-t)>Math.PI&&(i=2*Math.PI-i),i},e.prototype._isAngleBetween=function(e,t,i){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(i=(i%=2*Math.PI)<0?i+2*Math.PI:i)){if(e>t&&ei&&e>v,y=0;y<6;y++){var T=g[v][y];m&&(T=Ze(T,b,b,r)),f.texImage2D(y,v,_,b,b,0,u,l,T)}d._bindTextureDirectly(f.TEXTURE_CUBE_MAP,null)}else d.updateRawCubeTexture(p,o,n,r,h);p.isReady=!0,null==t||t._removePendingData(p),c&&c()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t._removePendingData(p),l&&e&&l(e.status+\" \"+e.statusText,i)})),p},qe.a.prototype.createRawTexture2DArray=Je(!1),qe.a.prototype.createRawTexture3D=Je(!0),qe.a.prototype.updateRawTexture2DArray=$e(!1),qe.a.prototype.updateRawTexture3D=$e(!0);var et=function(e){function t(t,i,n,r,o,a,s,c,l){void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===c&&(c=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,null,o,!a,s)||this;return u.format=r,u._engine?(u._texture=u._engine.createRawTexture(t,i,n,r,a,s,c,null,l),u.wrapU=Ke.a.CLAMP_ADDRESSMODE,u.wrapV=Ke.a.CLAMP_ADDRESSMODE,u):u}return Object(h.d)(t,e),t.prototype.update=function(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t.CreateLuminanceTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_LUMINANCE,r,o,a,s)},t.CreateLuminanceAlphaTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_LUMINANCE_ALPHA,r,o,a,s)},t.CreateAlphaTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_ALPHA,r,o,a,s)},t.CreateRGBTexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),new t(e,i,n,g.a.TEXTUREFORMAT_RGB,r,o,a,s,c)},t.CreateRGBATexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),new t(e,i,n,g.a.TEXTUREFORMAT_RGBA,r,o,a,s,c)},t.CreateRTexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_FLOAT),new t(e,i,n,g.a.TEXTUREFORMAT_R,r,o,a,s,c)},t}(Ke.a),tt=function(){function e(e,t,i){this.name=e,this.id=t,this.bones=new Array,this.needInitialSkinMatrix=!1,this.overrideMesh=null,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=a.a.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._waitingOverrideMeshId=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new o.c,this.bones=[],this._scene=i||x.a.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;var n=this._scene.getEngine().getCaps();this._canUseTextureForBones=n.textureFloat&&n.maxVertexTextureImageUnits>0}return Object.defineProperty(e.prototype,\"useTextureToStoreBoneMatrices\",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"animationPropertiesOverride\",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isUsingTextureForMatrices\",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"uniqueId\",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return\"Skeleton\"},e.prototype.getChildren=function(){return this.bones.filter((function(e){return!e.getParent()}))},e.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:(this._transformMatrices||this.prepare(),this._transformMatrices)},e.prototype.getTransformMatrixTexture=function(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture},e.prototype.getScene=function(){return this._scene},e.prototype.toString=function(e){var t=\"Name: \"+this.name+\", nBones: \"+this.bones.length;if(t+=\", nAnimationRanges: \"+(this._ranges?Object.keys(this._ranges).length:\"none\"),e){t+=\", Ranges: {\";var i=!0;for(var n in this._ranges)i&&(t+=\", \",i=!1),t+=n;t+=\"}\"}return t},e.prototype.getBoneIndexByName=function(e){for(var t=0,i=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)},e.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0)for(var e=0,t=this.bones;e0&&(a.animation=r.animations[0].serialize()),i.ranges=[],this._ranges){var c=this._ranges[s];if(c){var l={};l.name=s,l.from=c.from,l.to=c.to,i.ranges.push(l)}}}return i},e.Parse=function(t,i){var n,r=new e(t.name,t.id,i);for(t.dimensionsAtRest&&(r.dimensionsAtRest=a.e.FromArray(t.dimensionsAtRest)),r.needInitialSkinMatrix=t.needInitialSkinMatrix,t.overrideMeshId&&(r._hasWaitingData=!0,r._waitingOverrideMeshId=t.overrideMeshId),n=0;n-1&&(c=r.bones[o.parentBoneIndex]);var l=o.rest?a.a.FromArray(o.rest):null,u=new $(o.name,r,c,a.a.FromArray(o.matrix),l,null,s);void 0!==o.id&&null!==o.id&&(u.id=o.id),o.length&&(u.length=o.length),o.metadata&&(u.metadata=o.metadata),o.animation&&u.animations.push(z.Parse(o.animation)),void 0!==o.linkedTransformNodeId&&null!==o.linkedTransformNodeId&&(r._hasWaitingData=!0,u._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(n=0;n0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),i=0;i=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(e.prototype,\"isConnected\",{get:function(){return this._isConnected},enumerable:!1,configurable:!0}),e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,\"leftStick\",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"rightStick\",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!1,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e.DUALSHOCK=4,e}(),at=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.onButtonDownObservable=new o.c,r.onButtonUpObservable=new o.c,r.type=ot.GENERIC,r._buttons=new Array(n.buttons.length),r}return Object(h.d)(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var n=t.y/this.gamepadRotationSensibility*this._yAxisScale;0!=n&&Math.abs(n)>.005&&(e.inertialBetaOffset+=n)}}var r=this.gamepad.leftStick;if(r&&0!=r.y){var o=r.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},e.prototype.getClassName=function(){return\"ArcRotateCameraGamepadInput\"},e.prototype.getSimpleName=function(){return\"gamepad\"},Object(h.c)([Object(w.c)()],e.prototype,\"gamepadRotationSensibility\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"gamepadMoveSensibility\",void 0),e}();it.ArcRotateCameraGamepadInput=st;var ct=i(66),lt=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===ct.a.KEYDOWN?(t._ctrlPressed=r.ctrlKey,t._altPressed=r.altKey,(-1!==t.keysUp.indexOf(r.keyCode)||-1!==t.keysDown.indexOf(r.keyCode)||-1!==t.keysLeft.indexOf(r.keyCode)||-1!==t.keysRight.indexOf(r.keyCode)||-1!==t.keysReset.indexOf(r.keyCode))&&(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),r.preventDefault&&(e||r.preventDefault()))):-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysReset.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),r.preventDefault&&(e||r.preventDefault())))})))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t0?i/(1+this.wheelDeltaPercentage):i*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i,n){if(i.type===Ne.a.POINTERWHEEL){var r=i.event,o=0,a=r,s=0;if(s=a.wheelDelta?a.wheelDelta:60*-(r.deltaY||r.detail),t.wheelDeltaPercentage){if((o=t.computeDeltaFromMouseWheelLegacyEvent(s,t.camera.radius))>0){for(var c=t.camera.radius,l=t.camera.inertialRadiusOffset+o,u=0;u<20&&Math.abs(l)>.001;u++)c-=l,l*=t.camera.inertia;c=L.a.Clamp(c,0,Number.MAX_VALUE),o=t.computeDeltaFromMouseWheelLegacyEvent(s,c)}}else o=s/(40*t.wheelPrecision);o&&(t.camera.inertialRadiusOffset+=o),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ne.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return\"ArcRotateCameraMouseWheelInput\"},e.prototype.getSimpleName=function(){return\"mousewheel\"},Object(h.c)([Object(w.c)()],e.prototype,\"wheelPrecision\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"wheelDeltaPercentage\",void 0),e}();it.ArcRotateCameraMouseWheelInput=ut;var ht=function(){function e(){this.buttons=[0,1,2]}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments);var i=this.camera.getEngine(),n=i.getInputElement(),r=0,o=null;this.pointA=null,this.pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=function(a,s){var c=a.event,l=\"touch\"===c.pointerType;if(!i.isInVRExclusivePointerMode&&(a.type===Ne.a.POINTERMOVE||-1!==t.buttons.indexOf(c.button))){var u=c.srcElement||c.target;if(t._altKey=c.altKey,t._ctrlKey=c.ctrlKey,t._metaKey=c.metaKey,t._shiftKey=c.shiftKey,t._buttonsPressed=c.buttons,i.isPointerLock){var h=c.movementX||c.mozMovementX||c.webkitMovementX||c.msMovementX||0,d=c.movementY||c.mozMovementY||c.webkitMovementY||c.msMovementY||0;t.onTouch(null,h,d),t.pointA=null,t.pointB=null}else if(a.type===Ne.a.POINTERDOWN&&u){try{u.setPointerCapture(c.pointerId)}catch(e){}null===t.pointA?t.pointA={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType}:null===t.pointB&&(t.pointB={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType}),t.onButtonDown(c),e||(c.preventDefault(),n&&n.focus())}else if(a.type===Ne.a.POINTERDOUBLETAP)t.onDoubleTap(c.pointerType);else if(a.type===Ne.a.POINTERUP&&u){try{u.releasePointerCapture(c.pointerId)}catch(e){}l||(t.pointB=null),i._badOS?t.pointA=t.pointB=null:t.pointB&&t.pointA&&t.pointA.pointerId==c.pointerId?(t.pointA=t.pointB,t.pointB=null):t.pointA&&t.pointB&&t.pointB.pointerId==c.pointerId?t.pointB=null:t.pointA=t.pointB=null,(0!==r||o)&&(t.onMultiTouch(t.pointA,t.pointB,r,0,o,null),r=0,o=null),t.onButtonUp(c),e||c.preventDefault()}else if(a.type===Ne.a.POINTERMOVE)if(e||c.preventDefault(),t.pointA&&null===t.pointB){h=c.clientX-t.pointA.x,d=c.clientY-t.pointA.y;t.onTouch(t.pointA,h,d),t.pointA.x=c.clientX,t.pointA.y=c.clientY}else if(t.pointA&&t.pointB){var f=t.pointA.pointerId===c.pointerId?t.pointA:t.pointB;f.x=c.clientX,f.y=c.clientY;var p=t.pointA.x-t.pointB.x,_=t.pointA.y-t.pointB.y,m=p*p+_*_,g={x:(t.pointA.x+t.pointB.x)/2,y:(t.pointA.y+t.pointB.y)/2,pointerId:c.pointerId,type:a.type};t.onMultiTouch(t.pointA,t.pointB,r,m,o,g),o=g,r=m}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ne.a.POINTERDOWN|Ne.a.POINTERUP|Ne.a.POINTERMOVE),this._onLostFocus=function(){t.pointA=t.pointB=null,r=0,o=null,t.onLostFocus()},n&&n.addEventListener(\"contextmenu\",this.onContextMenu.bind(this),!1);var a=this.camera.getScene().getEngine().getHostWindow();a&&Ce.b.RegisterTopRootEvents(a,[{name:\"blur\",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){if(this._onLostFocus){var t=this.camera.getScene().getEngine().getHostWindow();t&&Ce.b.UnregisterTopRootEvents(t,[{name:\"blur\",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.onContextMenu){var i=this.camera.getScene().getEngine().getInputElement();i&&i.removeEventListener(\"contextmenu\",this.onContextMenu)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0},e.prototype.getClassName=function(){return\"BaseCameraPointersInput\"},e.prototype.getSimpleName=function(){return\"pointers\"},e.prototype.onDoubleTap=function(e){},e.prototype.onTouch=function(e,t,i){},e.prototype.onMultiTouch=function(e,t,i,n,r,o){},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.onButtonDown=function(e){},e.prototype.onButtonUp=function(e){},e.prototype.onLostFocus=function(){},Object(h.c)([Object(w.c)()],e.prototype,\"buttons\",void 0),e}(),dt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.buttons=[0,1,2],t.angularSensibilityX=1e3,t.angularSensibilityY=1e3,t.pinchPrecision=12,t.pinchDeltaPercentage=0,t.useNaturalPinchZoom=!1,t.panningSensibility=1e3,t.multiTouchPanning=!0,t.multiTouchPanAndZoom=!0,t.pinchInwards=!0,t._isPanClick=!1,t._twoFingerActivityCount=0,t._isPinching=!1,t}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"ArcRotateCameraPointersInput\"},t.prototype.onTouch=function(e,t,i){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)},t.prototype.onDoubleTap=function(e){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,t,i,n,r,o){if(!(0===i&&null===r||0===n&&null===o)){var a=this.pinchInwards?1:-1;if(this.multiTouchPanAndZoom){if(this.useNaturalPinchZoom?this.camera.radius=this.camera.radius*Math.sqrt(i)/Math.sqrt(n):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(n-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(n-i)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),0!==this.panningSensibility&&r&&o){var s=o.x-r.x,c=o.y-r.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=c/this.panningSensibility}}else{this._twoFingerActivityCount++;var l=Math.sqrt(i),u=Math.sqrt(n);if(this._isPinching||this._twoFingerActivityCount<20&&Math.abs(u-l)>this.camera.pinchToPanMaxDistance)this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(n-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(n-i)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),this._isPinching=!0;else if(0!==this.panningSensibility&&this.multiTouchPanning&&o&&r){s=o.x-r.x,c=o.y-r.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=c/this.panningSensibility}}}},t.prototype.onButtonDown=function(e){this._isPanClick=e.button===this.camera._panningMouseButton},t.prototype.onButtonUp=function(e){this._twoFingerActivityCount=0,this._isPinching=!1},t.prototype.onLostFocus=function(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1},Object(h.c)([Object(w.c)()],t.prototype,\"buttons\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"angularSensibilityX\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"angularSensibilityY\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"pinchPrecision\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"pinchDeltaPercentage\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"useNaturalPinchZoom\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"panningSensibility\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"multiTouchPanning\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"multiTouchPanAndZoom\",void 0),t}(ht);it.ArcRotateCameraPointersInput=dt;var ft=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addMouseWheel=function(){return this.add(new ut),this},t.prototype.addPointers=function(){return this.add(new dt),this},t.prototype.addKeyboard=function(){return this.add(new lt),this},t}(nt);ft.prototype.addVRDeviceOrientation=function(){return this.add(new pt),this};var pt=function(){function e(){this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.camera.attachControl(e);var i=this.camera.getScene().getEngine().getHostWindow();i&&(\"undefined\"!=typeof DeviceOrientationEvent&&\"function\"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){\"granted\"===e?i.addEventListener(\"deviceorientation\",t._deviceOrientationHandler):Ce.b.Warn(\"Permission not granted.\")})).catch((function(e){Ce.b.Error(e)})):i.addEventListener(\"deviceorientation\",this._deviceOrientationHandler))},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=(0|+e.alpha)*this.alphaCorrection),null!==e.gamma&&(this._gamma=(0|+e.gamma)*this.gammaCorrection),this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener(\"deviceorientation\",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return\"ArcRotateCameraVRDeviceOrientationInput\"},e.prototype.getSimpleName=function(){return\"VRDeviceOrientation\"},e}();it.ArcRotateCameraVRDeviceOrientationInput=pt;var _t=function(){function e(){this.keysForward=[87],this.keysBackward=[83],this.keysUp=[69],this.keysDown=[81],this.keysRight=[68],this.keysLeft=[65],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;i.type===ct.a.KEYDOWN?-1===t.keysForward.indexOf(r.keyCode)&&-1===t.keysBackward.indexOf(r.keyCode)&&-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)||(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),e||r.preventDefault()):-1===t.keysForward.indexOf(r.keyCode)&&-1===t.keysBackward.indexOf(r.keyCode)&&-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),e||r.preventDefault())})))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.getClassName=function(){return\"FlyCameraKeyboardInput\"},e.prototype._onLostFocus=function(e){this._keys=[]},e.prototype.getSimpleName=function(){return\"keyboard\"},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t=0&&t._keys.splice(n,1),r.preventDefault&&(e||r.preventDefault())))})))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.checkInputs=function(){var e=this;this._onKeyboardObserver&&this._keys.forEach((function(t){-1!==e.keysHeightOffsetIncr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset+=e.heightSensibility:-1!==e.keysHeightOffsetDecr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset-=e.heightSensibility:-1!==e.keysRotationOffsetIncr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset+=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRotationOffsetDecr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset-=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRadiusIncr.indexOf(t)&&e._modifierRadius()?e.camera.radius+=e.radiusSensibility:-1!==e.keysRadiusDecr.indexOf(t)&&e._modifierRadius()&&(e.camera.radius-=e.radiusSensibility)}))},e.prototype.getClassName=function(){return\"FollowCameraKeyboardMoveInput\"},e.prototype.getSimpleName=function(){return\"keyboard\"},e.prototype._modifierHeightOffset=function(){return this.keysHeightOffsetModifierAlt===this._altPressed&&this.keysHeightOffsetModifierCtrl===this._ctrlPressed&&this.keysHeightOffsetModifierShift===this._shiftPressed},e.prototype._modifierRotationOffset=function(){return this.keysRotationOffsetModifierAlt===this._altPressed&&this.keysRotationOffsetModifierCtrl===this._ctrlPressed&&this.keysRotationOffsetModifierShift===this._shiftPressed},e.prototype._modifierRadius=function(){return this.keysRadiusModifierAlt===this._altPressed&&this.keysRadiusModifierCtrl===this._ctrlPressed&&this.keysRadiusModifierShift===this._shiftPressed},Object(h.c)([Object(w.c)()],e.prototype,\"keysHeightOffsetIncr\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysHeightOffsetDecr\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysHeightOffsetModifierAlt\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysHeightOffsetModifierCtrl\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysHeightOffsetModifierShift\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRotationOffsetIncr\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRotationOffsetDecr\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRotationOffsetModifierAlt\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRotationOffsetModifierCtrl\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRotationOffsetModifierShift\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRadiusIncr\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRadiusDecr\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRadiusModifierAlt\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRadiusModifierCtrl\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"keysRadiusModifierShift\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"heightSensibility\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"rotationSensibility\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"radiusSensibility\",void 0),e}();it.FollowCameraKeyboardMoveInput=gt;var vt=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i,n){if(i.type===Ne.a.POINTERWHEEL){var r=i.event,o=0,a=Math.max(-1,Math.min(1,r.deltaY||r.wheelDelta||-r.detail));t.wheelDeltaPercentage?(console.assert(t.axisControlRadius+t.axisControlHeight+t.axisControlRotation<=1,\"wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: \"+t.axisControlRadius+\", axisControlHeightOffset: \"+t.axisControlHeight+\", axisControlRotationOffset: \"+t.axisControlRotation),t.axisControlRadius?o=.01*a*t.wheelDeltaPercentage*t.camera.radius:t.axisControlHeight?o=.01*a*t.wheelDeltaPercentage*t.camera.heightOffset:t.axisControlRotation&&(o=.01*a*t.wheelDeltaPercentage*t.camera.rotationOffset)):o=a*t.wheelPrecision,o&&(t.axisControlRadius?t.camera.radius+=o:t.axisControlHeight?t.camera.heightOffset-=o:t.axisControlRotation&&(t.camera.rotationOffset-=o)),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ne.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return\"ArcRotateCameraMouseWheelInput\"},e.prototype.getSimpleName=function(){return\"mousewheel\"},Object(h.c)([Object(w.c)()],e.prototype,\"axisControlRadius\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"axisControlHeight\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"axisControlRotation\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"wheelPrecision\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"wheelDeltaPercentage\",void 0),e}();it.FollowCameraMouseWheelInput=vt;var bt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.angularSensibilityX=1,t.angularSensibilityY=1,t.pinchPrecision=1e4,t.pinchDeltaPercentage=0,t.axisXControlRadius=!1,t.axisXControlHeight=!1,t.axisXControlRotation=!0,t.axisYControlRadius=!1,t.axisYControlHeight=!0,t.axisYControlRotation=!1,t.axisPinchControlRadius=!0,t.axisPinchControlHeight=!1,t.axisPinchControlRotation=!1,t.warningEnable=!0,t._warningCounter=0,t}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"FollowCameraPointersInput\"},t.prototype.onTouch=function(e,t,i){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=t/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=i/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=t/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=i/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=t/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=i/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,t,i,n,r,o){if(!(0===i&&null===r||0===n&&null===o)){var a=(n-i)/(this.pinchPrecision*(this.angularSensibilityX+this.angularSensibilityY)/2);this.pinchDeltaPercentage?(a*=.01*this.pinchDeltaPercentage,this.axisPinchControlRotation&&(this.camera.rotationOffset+=a*this.camera.rotationOffset),this.axisPinchControlHeight&&(this.camera.heightOffset+=a*this.camera.heightOffset),this.axisPinchControlRadius&&(this.camera.radius-=a*this.camera.radius)):(this.axisPinchControlRotation&&(this.camera.rotationOffset+=a),this.axisPinchControlHeight&&(this.camera.heightOffset+=a),this.axisPinchControlRadius&&(this.camera.radius-=a))}},t.prototype._warning=function(){if(this.warningEnable&&this._warningCounter++%100==0){var e=\"It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: \";console.assert(this.axisXControlRotation+this.axisXControlHeight+this.axisXControlRadius<=1,e+\"axisXControlRotation: \"+this.axisXControlRotation+\", axisXControlHeight: \"+this.axisXControlHeight+\", axisXControlRadius: \"+this.axisXControlRadius),console.assert(this.axisYControlRotation+this.axisYControlHeight+this.axisYControlRadius<=1,e+\"axisYControlRotation: \"+this.axisYControlRotation+\", axisYControlHeight: \"+this.axisYControlHeight+\", axisYControlRadius: \"+this.axisYControlRadius),console.assert(this.axisPinchControlRotation+this.axisPinchControlHeight+this.axisPinchControlRadius<=1,e+\"axisPinchControlRotation: \"+this.axisPinchControlRotation+\", axisPinchControlHeight: \"+this.axisPinchControlHeight+\", axisPinchControlRadius: \"+this.axisPinchControlRadius)}},Object(h.c)([Object(w.c)()],t.prototype,\"angularSensibilityX\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"angularSensibilityY\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"pinchPrecision\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"pinchDeltaPercentage\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisXControlRadius\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisXControlHeight\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisXControlRotation\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisYControlRadius\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisYControlHeight\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisYControlRotation\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisPinchControlRadius\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisPinchControlHeight\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"axisPinchControlRotation\",void 0),t}(ht);it.FollowCameraPointersInput=bt;var yt=function(){function e(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===ct.a.KEYDOWN?-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysUpward.indexOf(r.keyCode)&&-1===t.keysDownward.indexOf(r.keyCode)||(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),e||r.preventDefault()):-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysUpward.indexOf(r.keyCode)&&-1===t.keysDownward.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),e||r.preventDefault()))})))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t1)e.cameraRotation.x=-this._offsetY/this.touchAngularSensibility;else{var t=e._computeLocalCameraSpeed(),i=new a.e(0,0,t*this._offsetY/this.touchMoveSensibility);a.a.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(a.e.TransformCoordinates(i,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return\"FreeCameraTouchInput\"},e.prototype.getSimpleName=function(){return\"touch\"},Object(h.c)([Object(w.c)()],e.prototype,\"touchAngularSensibility\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"touchMoveSensibility\",void 0),e}();it.FreeCameraTouchInput=Pt;var Ct=function(e){function t(t){var i=e.call(this,t)||this;return i._mouseInput=null,i._mouseWheelInput=null,i}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new yt),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new Tt(e),this.add(this._mouseInput)),this},t.prototype.removeMouse=function(){return this._mouseInput&&this.remove(this._mouseInput),this},t.prototype.addMouseWheel=function(){return this._mouseWheelInput||(this._mouseWheelInput=new At,this.add(this._mouseWheelInput)),this},t.prototype.removeMouseWheel=function(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this},t.prototype.addTouch=function(){return this.add(new Pt),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}(nt);Ct.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new Rt,this.add(this._deviceOrientationInput)),this};var Rt=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new a.b,this._alpha=0,this._beta=0,this._gamma=0,this._onDeviceOrientationChangedObservable=new o.c,this._orientationChanged=function(){e._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,e._screenOrientationAngle=-Ce.b.ToRadians(e._screenOrientationAngle/2),e._screenQuaternion.copyFromFloats(0,Math.sin(e._screenOrientationAngle),0,Math.cos(e._screenOrientationAngle))},this._deviceOrientation=function(t){e._alpha=null!==t.alpha?t.alpha:0,e._beta=null!==t.beta?t.beta:0,e._gamma=null!==t.gamma?t.gamma:0,null!==t.alpha&&e._onDeviceOrientationChangedObservable.notifyObservers()},this._constantTranform=new a.b(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return e.WaitForOrientationChangeAsync=function(e){return new Promise((function(t,i){var n=!1,r=function(){window.removeEventListener(\"deviceorientation\",r),n=!0,t()};e&&setTimeout((function(){n||(window.removeEventListener(\"deviceorientation\",r),i(\"WaitForOrientationChangeAsync timed out\"))}),e),\"undefined\"!=typeof DeviceOrientationEvent&&\"function\"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){\"granted\"==e?window.addEventListener(\"deviceorientation\",r):Ce.b.Warn(\"Permission not granted.\")})).catch((function(e){Ce.b.Error(e)})):window.addEventListener(\"deviceorientation\",r)}))},Object.defineProperty(e.prototype,\"camera\",{get:function(){return this._camera},set:function(e){var t=this;this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new a.b),this._camera&&this._camera.onDisposeObservable.add((function(){t._onDeviceOrientationChangedObservable.clear()}))},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().getEngine().getHostWindow();if(t){var i=function(){t.addEventListener(\"orientationchange\",e._orientationChanged),t.addEventListener(\"deviceorientation\",e._deviceOrientation),e._orientationChanged()};\"undefined\"!=typeof DeviceOrientationEvent&&\"function\"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){\"granted\"===e?i():Ce.b.Warn(\"Permission not granted.\")})).catch((function(e){Ce.b.Error(e)})):i()}},e.prototype.detachControl=function(e){window.removeEventListener(\"orientationchange\",this._orientationChanged),window.removeEventListener(\"deviceorientation\",this._deviceOrientation),this._alpha=0},e.prototype.checkInputs=function(){this._alpha&&(a.b.RotationYawPitchRollToRef(Ce.b.ToRadians(this._alpha),Ce.b.ToRadians(this._beta),-Ce.b.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},e.prototype.getClassName=function(){return\"FreeCameraDeviceOrientationInput\"},e.prototype.getSimpleName=function(){return\"deviceOrientation\"},e}();it.FreeCameraDeviceOrientationInput=Rt;var xt=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._yAxisScale=1,this._cameraTransform=a.a.Identity(),this._deltaTransform=a.e.Zero(),this._vector3=a.e.Zero(),this._vector2=a.d.Zero()}return Object.defineProperty(e.prototype,\"invertYAxis\",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=t.onGamepadConnectedObservable.add((function(t){t.type!==ot.POSE_ENABLED&&(e.gamepad&&t.type!==ot.XBOX||(e.gamepad=t))})),this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add((function(t){e.gamepad===t&&(e.gamepad=null)})),this.gamepad=t.getGamepadByType(ot.XBOX),!this.gamepad&&t.gamepads.length&&(this.gamepad=t.gamepads[0])},e.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var e=this.camera,t=this.gamepad.leftStick,i=t.x/this.gamepadMoveSensibility,n=t.y/this.gamepadMoveSensibility;t.x=Math.abs(i)>.005?0+i:0,t.y=Math.abs(n)>.005?0+n:0;var r=this.gamepad.rightStick;if(r){var o=r.x/this.gamepadAngularSensibility,s=r.y/this.gamepadAngularSensibility*this._yAxisScale;r.x=Math.abs(o)>.001?0+o:0,r.y=Math.abs(s)>.001?0+s:0}else r={x:0,y:0};e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):a.a.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var c=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*c,0,-t.y*c),a.e.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(r.y,r.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return\"FreeCameraGamepadInput\"},e.prototype.getSimpleName=function(){return\"gamepad\"},Object(h.c)([Object(w.c)()],e.prototype,\"gamepadAngularSensibility\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"gamepadMoveSensibility\",void 0),e}();it.FreeCameraGamepadInput=xt;var Ot,Mt=i(112);!function(e){e[e.X=0]=\"X\",e[e.Y=1]=\"Y\",e[e.Z=2]=\"Z\"}(Ot||(Ot={}));var It=function(){function e(t,i){var n=this,r=Object(h.a)(Object(h.a)({},e._GetDefaultOptions()),i);if(this._leftJoystick=!!t,e._globalJoystickIndex++,this._axisTargetedByLeftAndRight=Ot.X,this._axisTargetedByUpAndDown=Ot.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new Mt.a,this.deltaPosition=a.e.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(t){e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas&&(e.Canvas.width=e.vjCanvasWidth,e.Canvas.height=e.vjCanvasHeight),e.halfWidth=e.vjCanvasWidth/2},!e.Canvas){window.addEventListener(\"resize\",this._onResize,!1),e.Canvas=document.createElement(\"canvas\"),e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas.width=window.innerWidth,e.Canvas.height=window.innerHeight,e.Canvas.style.width=\"100%\",e.Canvas.style.height=\"100%\",e.Canvas.style.position=\"absolute\",e.Canvas.style.backgroundColor=\"transparent\",e.Canvas.style.top=\"0px\",e.Canvas.style.left=\"0px\",e.Canvas.style.zIndex=\"5\",e.Canvas.style.msTouchAction=\"none\",e.Canvas.style.touchAction=\"none\",e.Canvas.setAttribute(\"touch-action\",\"none\");var o=e.Canvas.getContext(\"2d\");if(!o)throw new Error(\"Unable to create canvas for virtual joystick\");e.vjCanvasContext=o,e.vjCanvasContext.strokeStyle=\"#ffffff\",e.vjCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e.halfWidth=e.Canvas.width/2,this.pressed=!1,this.limitToContainer=r.limitToContainer,this._joystickColor=r.color,this.containerSize=r.containerSize,this.puckSize=r.puckSize,r.position&&this.setPosition(r.position.x,r.position.y),r.puckImage&&this.setPuckImage(r.puckImage),r.containerImage&&this.setContainerImage(r.containerImage),r.alwaysVisible&&e._alwaysVisibleSticks++,this.alwaysVisible=r.alwaysVisible,this._joystickPointerID=-1,this._joystickPointerPos=new a.d(0,0),this._joystickPreviousPointerPos=new a.d(0,0),this._joystickPointerStartPos=new a.d(0,0),this._deltaJoystickVector=new a.d(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},e.Canvas.addEventListener(\"pointerdown\",this._onPointerDownHandlerRef,!1),e.Canvas.addEventListener(\"pointermove\",this._onPointerMoveHandlerRef,!1),e.Canvas.addEventListener(\"pointerup\",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener(\"pointerout\",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener(\"contextmenu\",(function(e){e.preventDefault()}),!1),requestAnimationFrame((function(){n._drawVirtualJoystick()}))}return e._GetDefaultOptions=function(){return{puckSize:40,containerSize:60,color:\"cyan\",puckImage:void 0,containerImage:void 0,position:void 0,alwaysVisible:!1,limitToContainer:!1}},e.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},e.prototype._onPointerDown=function(t){t.preventDefault(),(!0===this._leftJoystick?t.clientXe.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=t.pointerId,this._joystickPosition?(this._joystickPointerStartPos=this._joystickPosition.clone(),this._joystickPointerPos=this._joystickPosition.clone(),this._joystickPreviousPointerPos=this._joystickPosition.clone(),this._onPointerMove(t)):(this._joystickPointerStartPos.x=t.clientX,this._joystickPointerStartPos.y=t.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone()),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(t.pointerId.toString(),t)):e._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},e.prototype._onPointerMove=function(t){if(this._joystickPointerID==t.pointerId){if(this.limitToContainer){var i=new a.d(t.clientX-this._joystickPointerStartPos.x,t.clientY-this._joystickPointerStartPos.y),n=i.length();n>this.containerSize&&i.scaleInPlace(this.containerSize/n),this._joystickPointerPos.x=this._joystickPointerStartPos.x+i.x,this._joystickPointerPos.y=this._joystickPointerStartPos.y+i.y}else this._joystickPointerPos.x=t.clientX,this._joystickPointerPos.y=t.clientY;this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos),0=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&a.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},Object.defineProperty(t.prototype,\"target\",{get:function(){return this.getTarget()},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),t.prototype.getTarget=function(){return this._currentTarget},t.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(a.c.Matrix[0]),a.e.TransformNormalToRef(this.cameraDirection,a.c.Matrix[0],a.c.Vector3[0]),void this.position.addInPlace(a.c.Vector3[0]);this.position.addInPlace(this.cameraDirection)},t.prototype._checkInputs=function(){var t=this.invertRotation?-this.inverseRotationSpeed:1,i=this._decideIfNeedsToMove(),n=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),n){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this.rotation),this.rotation.x+=this.cameraRotation.x*t,this.rotation.y+=this.cameraRotation.y*t,!this.noRotationConstraint){this.rotation.x>1.570796&&(this.rotation.x=1.570796),this.rotation.x<-1.570796&&(this.rotation.x=-1.570796)}if(this.rotationQuaternion)this.rotation.lengthSquared()&&a.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}i&&(Math.abs(this.cameraDirection.x)Se.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&i&&o.onCollide(i))},o.inputs=new Ct(o),o.inputs.addKeyboard().addMouse(),o}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"angularSensibility\",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysUp\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysUpward\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUpward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUpward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysDown\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysDownward\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDownward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDownward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysLeft\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysRight\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(e){this.inputs.detachElement(),this.cameraDirection=new a.e(0,0,0),this.cameraRotation=new a.d(0,0)},Object.defineProperty(t.prototype,\"collisionMask\",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?a.e.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=a.e.Zero(),this._transformedDirection=a.e.Zero()),this.inputs.checkInputs(),e.prototype._checkInputs.call(this)},t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):e.prototype._updatePosition.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return\"FreeCamera\"},Object(h.c)([Object(w.o)()],t.prototype,\"ellipsoid\",void 0),Object(h.c)([Object(w.o)()],t.prototype,\"ellipsoidOffset\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"checkCollisions\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"applyGravity\",void 0),t}(Lt);B.a.AddNodeConstructor(\"TouchCamera\",(function(e,t){return function(){return new Ft(e,a.e.Zero(),t)}}));var Ft=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.inputs.addTouch(),r._setupInputs(),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"touchAngularSensibility\",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"touchMoveSensibility\",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"TouchCamera\"},t.prototype._setupInputs=function(){var e=this.inputs.attached.touch,t=this.inputs.attached.mouse;t?t.touchEnabled=!1:e.allowMouse=!0},t}(wt);B.a.AddNodeConstructor(\"ArcRotateCamera\",(function(e,t){return function(){return new Bt(e,0,0,1,a.e.Zero(),t)}}));var Bt=function(e){function t(t,i,n,r,s,c,l){void 0===l&&(l=!0);var u=e.call(this,t,a.e.Zero(),c,l)||this;return u.inertialAlphaOffset=0,u.inertialBetaOffset=0,u.inertialRadiusOffset=0,u.lowerAlphaLimit=null,u.upperAlphaLimit=null,u.lowerBetaLimit=.01,u.upperBetaLimit=Math.PI-.01,u.lowerRadiusLimit=null,u.upperRadiusLimit=null,u.inertialPanningX=0,u.inertialPanningY=0,u.pinchToPanMaxDistance=20,u.panningDistanceLimit=null,u.panningOriginTarget=a.e.Zero(),u.panningInertia=.9,u.zoomOnFactor=1,u.targetScreenOffset=a.d.Zero(),u.allowUpsideDown=!0,u.useInputToRestoreState=!0,u._viewMatrix=new a.a,u.panningAxis=new a.e(1,1,0),u.onMeshTargetChangedObservable=new o.c,u.checkCollisions=!1,u.collisionRadius=new a.e(.5,.5,.5),u._previousPosition=a.e.Zero(),u._collisionVelocity=a.e.Zero(),u._newPosition=a.e.Zero(),u._computationVector=a.e.Zero(),u._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),i?(u.setPosition(t),u.onCollide&&u.onCollide(i)):u._previousPosition.copyFrom(u._position);var n=Math.cos(u.alpha),r=Math.sin(u.alpha),o=Math.cos(u.beta),a=Math.sin(u.beta);0===a&&(a=1e-4);var s=u._getTargetPosition();u._computationVector.copyFromFloats(u.radius*n*a,u.radius*o,u.radius*r*a),s.addToRef(u._computationVector,u._newPosition),u._position.copyFrom(u._newPosition);var c=u.upVector;u.allowUpsideDown&&u.beta<0&&(c=(c=c.clone()).negate()),u._computeViewMatrix(u._position,s,c),u._viewMatrix.addAtIndex(12,u.targetScreenOffset.x),u._viewMatrix.addAtIndex(13,u.targetScreenOffset.y),u._collisionTriggered=!1},u._target=a.e.Zero(),s&&u.setTarget(s),u.alpha=i,u.beta=n,u.radius=r,u.getViewMatrix(),u.inputs=new ft(u),u.inputs.addKeyboard().addMouseWheel().addPointers(),u}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"target\",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"position\",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"upVector\",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._YToUpMatrix=new a.a,this._upToYMatrix=new a.a,this._upVector=a.e.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!1,configurable:!0}),t.prototype.setMatUp=function(){a.a.RotationAlignToRef(a.e.UpReadOnly,this._upVector,this._YToUpMatrix),a.a.RotationAlignToRef(this._upVector,a.e.UpReadOnly,this._upToYMatrix)},Object.defineProperty(t.prototype,\"angularSensibilityX\",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"angularSensibilityY\",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"pinchPrecision\",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"pinchDeltaPercentage\",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"useNaturalPinchZoom\",{get:function(){var e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom},set:function(e){var t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"panningSensibility\",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysUp\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysDown\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysLeft\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysRight\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"wheelPrecision\",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"wheelDeltaPercentage\",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"bouncingBehavior\",{get:function(){return this._bouncingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"useBouncingBehavior\",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new we,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"framingBehavior\",{get:function(){return this._framingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"useFramingBehavior\",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new Fe,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"autoRotationBehavior\",{get:function(){return this._autoRotationBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"useAutoRotationBehavior\",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new Le,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!1,configurable:!0}),t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=a.d.Zero()},t.prototype._updateCache=function(t){t||e.prototype._updateCache.call(this),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)},t.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.absolutePosition;this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}var t=this._getLockedTargetPosition();return t||this._target},t.prototype.storeState=function(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this.targetScreenOffset.clone(),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.prototype._restoreStateValues.call(this)&&(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)},t.prototype._isSynchronizedViewMatrix=function(){return!!e.prototype._isSynchronizedViewMatrix.call(this)&&(this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset))},t.prototype.attachControl=function(e,t,i,n){var r=this;void 0===i&&(i=!0),void 0===n&&(n=2),t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._useCtrlForPanning=i,this._panningMouseButton=n,\"boolean\"==typeof arguments[0]&&(arguments.length>1&&(this._useCtrlForPanning=arguments[1]),arguments.length>2&&(this._panningMouseButton=arguments[2])),this.inputs.attachElement(t),this._reset=function(){r.inertialAlphaOffset=0,r.inertialBetaOffset=0,r.inertialRadiusOffset=0,r.inertialPanningX=0,r.inertialPanningY=0}},t.prototype.detachControl=function(e){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var t=this.inertialAlphaOffset;this.beta<=0&&(t*=-1),this.getScene().useRightHandedSystem&&(t*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(t*=-1),this.alpha+=t,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},t.prototype.rebuildAnglesAndRadius=function(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.e.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4);var e=this.alpha;0===this._computationVector.x&&0===this._computationVector.z?this.alpha=Math.PI/2:this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha);var t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*t*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()},t.prototype.setPosition=function(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())},t.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var n=e,r=this._getTargetPosition();if(r&&!i&&r.equals(n))return;this._targetHost=null,this._target=n,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},t.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4),0===this.radius&&(this.radius=1e-4);var r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*n,this.radius*i,this.radius*t*n),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.e.TransformCoordinatesToRef(this._computationVector,this._YToUpMatrix,this._computationVector),r.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var o=this.getScene().collisionCoordinator;this._collider||(this._collider=o.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,o.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.negate()),this._computeViewMatrix(this._position,r,s),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=r,this._viewMatrix},t.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var i=be.a.MinMax(e),n=a.e.Distance(i.min,i.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:n},t)},t.prototype.focusOn=function(e,t){var i,n;if(void 0===t&&(t=!1),void 0===e.min){var r=e||this.getScene().meshes;i=be.a.MinMax(r),n=a.e.Distance(i.min,i.max)}else{i=e,n=e.distance}this._target=be.a.Center(i),t||(this.maxZ=2*n)},t.prototype.createRigCamera=function(e,i){var n=0;switch(this.cameraRigMode){case je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case je.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case je.a.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);break;case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===i?-1:1)}var r=new t(e,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return r._cameraRigParams={},r.isRigCamera=!0,r.rigParent=this,r.upVector=this.upVector,r},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(t.beta=i.beta=this.beta,this.cameraRigMode){case je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case je.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case je.a.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}e.prototype._updateRigCameras.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return\"ArcRotateCamera\"},Object(h.c)([Object(w.c)()],t.prototype,\"alpha\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"beta\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"radius\",void 0),Object(h.c)([Object(w.o)(\"target\")],t.prototype,\"_target\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"inertialAlphaOffset\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"inertialBetaOffset\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"inertialRadiusOffset\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"lowerAlphaLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"upperAlphaLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"lowerBetaLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"upperBetaLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"lowerRadiusLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"upperRadiusLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"inertialPanningX\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"inertialPanningY\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"pinchToPanMaxDistance\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"panningDistanceLimit\",void 0),Object(h.c)([Object(w.o)()],t.prototype,\"panningOriginTarget\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"panningInertia\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"zoomOnFactor\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"targetScreenOffset\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"allowUpsideDown\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"useInputToRestoreState\",void 0),t}(Lt);B.a.AddNodeConstructor(\"DeviceOrientationCamera\",(function(e,t){return function(){return new Ut(e,a.e.Zero(),t)}}));var Ut=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r._tmpDragQuaternion=new a.b,r._disablePointerInputWhenUsingDeviceOrientation=!0,r._dragFactor=0,r._quaternionCache=new a.b,r.inputs.addDeviceOrientation(),r.inputs._deviceOrientationInput&&r.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function(){r._disablePointerInputWhenUsingDeviceOrientation&&r.inputs._mouseInput&&(r.inputs._mouseInput._allowCameraRotation=!1,r.inputs._mouseInput.onPointerMovedObservable.add((function(e){0!=r._dragFactor&&(r._initialQuaternion||(r._initialQuaternion=new a.b),a.b.FromEulerAnglesToRef(0,e.offsetX*r._dragFactor,0,r._tmpDragQuaternion),r._initialQuaternion.multiplyToRef(r._tmpDragQuaternion,r._initialQuaternion))})))})),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"disablePointerInputWhenUsingDeviceOrientation\",{get:function(){return this._disablePointerInputWhenUsingDeviceOrientation},set:function(e){this._disablePointerInputWhenUsingDeviceOrientation=e},enumerable:!1,configurable:!0}),t.prototype.enableHorizontalDragging=function(e){void 0===e&&(e=1/300),this._dragFactor=e},t.prototype.getClassName=function(){return\"DeviceOrientationCamera\"},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._quaternionCache.copyFrom(this.rotationQuaternion),this._initialQuaternion&&this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)},t.prototype.resetToCurrentRotation=function(e){var t=this;void 0===e&&(e=J.a.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new a.b),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),[\"x\",\"y\",\"z\"].forEach((function(i){e[i]?t._initialQuaternion[i]*=-1:t._initialQuaternion[i]=0})),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},t}(wt),Vt=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new _t),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new mt(e)),this},t}(nt),kt=function(e){function t(t,i,n,r){void 0===r&&(r=!0);var o=e.call(this,t,i,n,r)||this;return o.ellipsoid=new a.e(1,1,1),o.ellipsoidOffset=new a.e(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o.cameraDirection=a.e.Zero(),o._trackRoll=0,o.rollCorrect=100,o.bankedTurn=!1,o.bankedTurnLimit=Math.PI/2,o.bankedTurnMultiplier=1,o._needMoveForGravity=!1,o._oldPosition=a.e.Zero(),o._diffPosition=a.e.Zero(),o._newPosition=a.e.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null);var n;n=t,o._newPosition.copyFrom(n),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>Se.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&i&&o.onCollide(i))},o.inputs=new Vt(o),o.inputs.addKeyboard().addMouse(),o}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"angularSensibility\",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysForward\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysForward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysForward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysBackward\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysBackward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysBackward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysUp\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysDown\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysLeft\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"keysRight\",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new a.e(0,0,0)},Object.defineProperty(t.prototype,\"collisionMask\",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?a.e.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=a.e.Zero(),this._transformedDirection=a.e.Zero()),this.inputs.checkInputs(),e.prototype._checkInputs.call(this)},t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):e.prototype._updatePosition.call(this)},t.prototype.restoreRoll=function(e){var t=this._trackRoll,i=t-this.rotation.z;Math.abs(i)>=.001&&(this.rotation.z+=i/e,Math.abs(t-this.rotation.z)<=.001&&(this.rotation.z=t))},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return\"FlyCamera\"},Object(h.c)([Object(w.o)()],t.prototype,\"ellipsoid\",void 0),Object(h.c)([Object(w.o)()],t.prototype,\"ellipsoidOffset\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"checkCollisions\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"applyGravity\",void 0),t}(Lt),zt=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new gt),this},t.prototype.addMouseWheel=function(){return this.add(new vt),this},t.prototype.addPointers=function(){return this.add(new bt),this},t.prototype.addVRDeviceOrientation=function(){return console.warn(\"DeviceOrientation support not yet implemented for FollowCamera.\"),this},t}(nt);B.a.AddNodeConstructor(\"FollowCamera\",(function(e,t){return function(){return new jt(e,a.e.Zero(),t)}})),B.a.AddNodeConstructor(\"ArcFollowCamera\",(function(e,t){return function(){return new Wt(e,0,0,1,null,t)}}));var Gt,jt=function(e){function t(t,i,n,r){void 0===r&&(r=null);var o=e.call(this,t,i,n)||this;return o.radius=12,o.lowerRadiusLimit=null,o.upperRadiusLimit=null,o.rotationOffset=0,o.lowerRotationOffsetLimit=null,o.upperRotationOffsetLimit=null,o.heightOffset=4,o.lowerHeightOffsetLimit=null,o.upperHeightOffsetLimit=null,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=r,o.inputs=new zt(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return Object(h.d)(t,e),t.prototype._follow=function(e){if(e){var t;if(e.rotationQuaternion){var i=new a.a;e.rotationQuaternion.toRotationMatrix(i),t=Math.atan2(i.m[8],i.m[10])}else t=e.rotation.y;var n=Ce.b.ToRadians(this.rotationOffset)+t,r=e.getAbsolutePosition(),o=r.x+Math.sin(n)*this.radius,s=r.z+Math.cos(n)*this.radius,c=o-this.position.x,l=r.y+this.heightOffset-this.position.y,u=s-this.position.z,h=c*this.cameraAcceleration*2,d=l*this.cameraAcceleration,f=u*this.cameraAcceleration*2;(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new a.e(this.position.x+h,this.position.y+d,this.position.z+f),this.setTarget(r)}},t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t),this._reset=function(){}},t.prototype.detachControl=function(e){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){this.inputs.checkInputs(),this._checkLimits(),e.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},t.prototype._checkLimits=function(){null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),null!==this.lowerHeightOffsetLimit&&this.heightOffsetthis.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),null!==this.lowerRotationOffsetLimit&&this.rotationOffsetthis.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return\"FollowCamera\"},Object(h.c)([Object(w.c)()],t.prototype,\"radius\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"lowerRadiusLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"upperRadiusLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"rotationOffset\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"lowerRotationOffsetLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"upperRotationOffsetLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"heightOffset\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"lowerHeightOffsetLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"upperHeightOffsetLimit\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"cameraAcceleration\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"maxCameraSpeed\",void 0),Object(h.c)([Object(w.k)(\"lockedTargetId\")],t.prototype,\"lockedTarget\",void 0),t}(Lt),Wt=function(e){function t(t,i,n,r,o,s){var c=e.call(this,t,a.e.Zero(),s)||this;return c.alpha=i,c.beta=n,c.radius=r,c._cartesianCoordinates=a.e.Zero(),c._meshTarget=o,c._follow(),c}return Object(h.d)(t,e),t.prototype._follow=function(){if(this._meshTarget){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this._meshTarget.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._follow()},t.prototype.getClassName=function(){return\"ArcFollowCamera\"},t}(Lt),Ht=i(38),Xt=i(39);!function(e){e[e.VIVE=0]=\"VIVE\",e[e.OCULUS=1]=\"OCULUS\",e[e.WINDOWS=2]=\"WINDOWS\",e[e.GEAR_VR=3]=\"GEAR_VR\",e[e.DAYDREAM=4]=\"DAYDREAM\",e[e.GENERIC=5]=\"GENERIC\"}(Gt||(Gt={}));var Yt,Kt,Qt=function(){function e(){}return e.InitiateController=function(e){for(var t=0,i=this._ControllerFactories;tthis._maxRotationDistFromHeadset){var n=i-(i<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=n;var r=Math.sin(-n),o=Math.cos(-n);this._calculatedPosition.x=this._calculatedPosition.x*o-this._calculatedPosition.z*r,this._calculatedPosition.z=this._calculatedPosition.x*r+this._calculatedPosition.z*o}}a.e.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),a.b.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),this._mesh&&(this._mesh.position.copyFrom(this.devicePosition),this._mesh.rotationQuaternion&&this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))}},t.prototype.updateFromDevice=function(e){if(!this.isXR&&e){this.rawPose=e,e.position&&(this._deviceRoomPosition.copyFromFloats(e.position[0],e.position[1],-e.position[2]),this._mesh&&this._mesh.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1),this._trackPosition&&this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor,this._calculatedPosition),this._calculatedPosition.addInPlace(this.position));var t=this.rawPose;e.orientation&&t.orientation&&4===t.orientation.length&&(this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0],t.orientation[1],-t.orientation[2],-t.orientation[3]),this._mesh&&(this._mesh.getScene().useRightHandedSystem?(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1):this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion,this._deviceRoomRotationQuaternion)),this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion,this._calculatedRotation))}},t.prototype.attachToMesh=function(e){if(this._mesh&&(this._mesh.parent=null),this._mesh=e,this._poseControlledCamera&&(this._mesh.parent=this._poseControlledCamera),this._mesh.rotationQuaternion||(this._mesh.rotationQuaternion=new a.b),!this.isXR&&(this._updatePoseAndMesh(),this._pointingPoseNode)){for(var t=[],i=this._pointingPoseNode;i.parent;)t.push(i.parent),i=i.parent;t.reverse().forEach((function(e){e.computeWorldMatrix(!0)}))}this._meshAttachedObservable.notifyObservers(e)},t.prototype.attachToPoseControlledCamera=function(e){this._poseControlledCamera=e,this._mesh&&(this._mesh.parent=this._poseControlledCamera)},t.prototype.dispose=function(){this._mesh&&this._mesh.dispose(),this._mesh=null,e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,\"mesh\",{get:function(){return this._mesh},enumerable:!1,configurable:!0}),t.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this.mesh)return new Xt.a(a.e.Zero(),new a.e(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),i=t.getTranslation(),n=new a.e(0,0,-1),r=a.e.TransformNormal(n,t),o=a.e.Normalize(r);return new Xt.a(i,o,e)},t.POINTING_POSE=\"POINTING_POSE\",t}(ot);!function(e){e[e.A=0]=\"A\",e[e.B=1]=\"B\",e[e.X=2]=\"X\",e[e.Y=3]=\"Y\",e[e.LB=4]=\"LB\",e[e.RB=5]=\"RB\",e[e.Back=8]=\"Back\",e[e.Start=9]=\"Start\",e[e.LeftStick=10]=\"LeftStick\",e[e.RightStick=11]=\"RightStick\"}(Yt||(Yt={})),function(e){e[e.Up=12]=\"Up\",e[e.Down=13]=\"Down\",e[e.Left=14]=\"Left\",e[e.Right=15]=\"Right\"}(Kt||(Kt={}));var Zt,Jt,$t=function(e){function t(t,i,n,r){void 0===r&&(r=!1);var a=e.call(this,t,i,n,0,1,2,3)||this;return a._leftTrigger=0,a._rightTrigger=0,a.onButtonDownObservable=new o.c,a.onButtonUpObservable=new o.c,a.onPadDownObservable=new o.c,a.onPadUpObservable=new o.c,a._buttonA=0,a._buttonB=0,a._buttonX=0,a._buttonY=0,a._buttonBack=0,a._buttonStart=0,a._buttonLB=0,a._buttonRB=0,a._buttonLeftStick=0,a._buttonRightStick=0,a._dPadUp=0,a._dPadDown=0,a._dPadLeft=0,a._dPadRight=0,a._isXboxOnePad=!1,a.type=ot.XBOX,a._isXboxOnePad=r,a}return Object(h.d)(t,e),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,\"leftTrigger\",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"rightTrigger\",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!1,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,\"buttonA\",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,Yt.A)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonB\",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,Yt.B)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonX\",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,Yt.X)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonY\",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,Yt.Y)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonStart\",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,Yt.Start)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonBack\",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,Yt.Back)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonLB\",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,Yt.LB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonRB\",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,Yt.RB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonLeftStick\",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Yt.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonRightStick\",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Yt.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dPadUp\",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Kt.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dPadDown\",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Kt.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dPadLeft\",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Kt.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dPadRight\",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Kt.Right)},enumerable:!1,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this._isXboxOnePad,this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ot);!function(e){e[e.Cross=0]=\"Cross\",e[e.Circle=1]=\"Circle\",e[e.Square=2]=\"Square\",e[e.Triangle=3]=\"Triangle\",e[e.L1=4]=\"L1\",e[e.R1=5]=\"R1\",e[e.Share=8]=\"Share\",e[e.Options=9]=\"Options\",e[e.LeftStick=10]=\"LeftStick\",e[e.RightStick=11]=\"RightStick\"}(Zt||(Zt={})),function(e){e[e.Up=12]=\"Up\",e[e.Down=13]=\"Down\",e[e.Left=14]=\"Left\",e[e.Right=15]=\"Right\"}(Jt||(Jt={}));var ei=function(e){function t(t,i,n){var r=e.call(this,t.replace(\"STANDARD GAMEPAD\",\"SONY PLAYSTATION DUALSHOCK\"),i,n,0,1,2,3)||this;return r._leftTrigger=0,r._rightTrigger=0,r.onButtonDownObservable=new o.c,r.onButtonUpObservable=new o.c,r.onPadDownObservable=new o.c,r.onPadUpObservable=new o.c,r._buttonCross=0,r._buttonCircle=0,r._buttonSquare=0,r._buttonTriangle=0,r._buttonShare=0,r._buttonOptions=0,r._buttonL1=0,r._buttonR1=0,r._buttonLeftStick=0,r._buttonRightStick=0,r._dPadUp=0,r._dPadDown=0,r._dPadLeft=0,r._dPadRight=0,r.type=ot.DUALSHOCK,r}return Object(h.d)(t,e),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,\"leftTrigger\",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"rightTrigger\",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!1,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,\"buttonCross\",{get:function(){return this._buttonCross},set:function(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,Zt.Cross)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonCircle\",{get:function(){return this._buttonCircle},set:function(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,Zt.Circle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonSquare\",{get:function(){return this._buttonSquare},set:function(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,Zt.Square)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonTriangle\",{get:function(){return this._buttonTriangle},set:function(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,Zt.Triangle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonOptions\",{get:function(){return this._buttonOptions},set:function(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,Zt.Options)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonShare\",{get:function(){return this._buttonShare},set:function(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,Zt.Share)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonL1\",{get:function(){return this._buttonL1},set:function(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,Zt.L1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonR1\",{get:function(){return this._buttonR1},set:function(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,Zt.R1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonLeftStick\",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Zt.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buttonRightStick\",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Zt.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dPadUp\",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Jt.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dPadDown\",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Jt.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dPadLeft\",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Jt.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dPadRight\",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Jt.Right)},enumerable:!1,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this.buttonCross=this.browserGamepad.buttons[0].value,this.buttonCircle=this.browserGamepad.buttons[1].value,this.buttonSquare=this.browserGamepad.buttons[2].value,this.buttonTriangle=this.browserGamepad.buttons[3].value,this.buttonL1=this.browserGamepad.buttons[4].value,this.buttonR1=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonShare=this.browserGamepad.buttons[8].value,this.buttonOptions=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ot),ti=function(){function e(e){var t=this;if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new o.c,Ht.a.IsWindowObjectExist()?(this._gamepadEventSupported=\"GamepadEvent\"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new o.c((function(e){for(var i in t._babylonGamepads){var n=t._babylonGamepads[i];n&&n._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,n)}})),this._onGamepadConnectedEvent=function(e){var i,n=e.gamepad;n.index in t._babylonGamepads&&t._babylonGamepads[n.index].isConnected||(t._babylonGamepads[n.index]?((i=t._babylonGamepads[n.index]).browserGamepad=n,i._isConnected=!0):i=t._addNewGamepad(n),t.onGamepadConnectedObservable.notifyObservers(i),t._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var i=e.gamepad;for(var n in t._babylonGamepads)if(t._babylonGamepads[n].index===i.index){var r=t._babylonGamepads[n];r._isConnected=!1,t.onGamepadDisconnectedObservable.notifyObservers(r),r.dispose&&r.dispose();break}},this._gamepadSupport)if(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported){var i=this._scene?this._scene.getEngine().getHostWindow():window;i&&(i.addEventListener(\"gamepadconnected\",this._onGamepadConnectedEvent,!1),i.addEventListener(\"gamepaddisconnected\",this._onGamepadDisconnectedEvent,!1))}else this._startMonitoringGamepads()}return Object.defineProperty(e.prototype,\"gamepads\",{get:function(){return this._babylonGamepads},enumerable:!1,configurable:!0}),e.prototype.getGamepadByType=function(e){void 0===e&&(e=ot.XBOX);for(var t=0,i=this._babylonGamepads;t1&&(l=a.generateStencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24),o.is2DArray?i.texImage3D(r,0,l,o.width,o.height,n,0,c,s,null):i.texImage2D(r,0,l,o.width,o.height,0,c,s,null),this._bindTextureDirectly(r,null),o};var li=function(){function e(e,t,i,n,r,s,c,l,u,h,d,f,p,_,m){void 0===c&&(c=g.a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===h&&(h=null),void 0===d&&(d=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f=\"postprocess\"),void 0===_&&(_=!1),void 0===m&&(m=g.a.TEXTUREFORMAT_RGBA),this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.alphaMode=g.a.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=g.a.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new oi.a(2),this._currentRenderTextureInd=0,this._scaleRatio=new a.d(1,1),this._texelSize=a.d.Zero(),this.onActivateObservable=new o.c,this.onSizeChangedObservable=new o.c,this.onApplyObservable=new o.c,this.onBeforeRenderObservable=new o.c,this.onAfterRenderObservable=new o.c,this.name=e,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=r,this.renderTargetSamplingMode=c||g.a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=u||!1,this._textureType=d,this._textureFormat=m,this._samplers=n||[],this._samplers.push(\"textureSampler\"),this._fragmentUrl=t,this._vertexUrl=f,this._parameters=i||[],this._parameters.push(\"scale\"),this._indexParameters=p,_||this.updateEffect(h)}return Object.defineProperty(e.prototype,\"samples\",{get:function(){return this._samples},set:function(e){var t=this;this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((function(e){e.samples!==t._samples&&t._engine.updateRenderTargetTextureSampleCount(e,t._samples)}))},enumerable:!1,configurable:!0}),e.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(e.prototype,\"onActivate\",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onSizeChanged\",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onApply\",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onBeforeRender\",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onAfterRender\",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"inputTexture\",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!1,configurable:!0}),e.prototype.restoreDefaultInputTexture=function(){this._forcedOutputTexture=null},e.prototype.getCamera=function(){return this._camera},Object.defineProperty(e.prototype,\"texelSize\",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return\"PostProcess\"},e.prototype.getEngine=function(){return this._engine},e.prototype.getEffect=function(){return this._effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new oi.a(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,i,n,r,o,a,s){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._effect=this._engine.createEffect({vertex:null!=a?a:this._vertexUrl,fragment:null!=s?s:this._fragmentUrl},[\"position\"],t||this._parameters,i||this._samplers,null!==e?e:\"\",void 0,r,o,n||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype.activate=function(e,t,i){var n=this;void 0===t&&(t=null);var r=(e=e||this._camera).getScene(),o=r.getEngine(),a=o.getCaps().maxTextureSize,s=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,c=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0,l=e.parent;!l||l.leftCamera!=e&&l.rightCamera!=e||(s/=2);var u,h=this._options.width||s,d=this._options.height||c,f=this.renderTargetSamplingMode!==g.a.TEXTURE_NEAREST_LINEAR&&this.renderTargetSamplingMode!==g.a.TEXTURE_NEAREST_NEAREST&&this.renderTargetSamplingMode!==g.a.TEXTURE_LINEAR_LINEAR;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var p=o.currentViewport;p&&(h*=p.width,d*=p.height)}if((f||this.alwaysForcePOT)&&(this._options.width||(h=o.needPOTTextures?Se.a.GetExponentOfTwo(h,a,this.scaleMode):h),this._options.height||(d=o.needPOTTextures?Se.a.GetExponentOfTwo(d,a,this.scaleMode):d)),this.width!==h||this.height!==d){if(this._textures.length>0){for(var _=0;_0)for(var e=0;e0){var i=this._camera._getFirstPostProcess();i&&i.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType=\"BABYLON.\"+this.getClassName(),e.cameraId=this.getCamera().id,e.reusable=this._reusable,e.options=this._options,e.textureType=this._textureType,e},e.Parse=function(e,t,i){var n=c.a.GetClass(e.customType);if(!n||!n._Parse)return null;var r=t.getCameraByID(e.cameraId);return r?n._Parse(e,r,t,i):null},Object(h.c)([Object(w.c)()],e.prototype,\"uniqueId\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"name\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"width\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"height\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"renderTargetSamplingMode\",void 0),Object(h.c)([Object(w.f)()],e.prototype,\"clearColor\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"autoClear\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"alphaMode\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"alphaConstants\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"enablePixelPerfectMode\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"forceFullscreenViewport\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"scaleMode\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"alwaysForcePOT\",void 0),Object(h.c)([Object(w.c)(\"samples\")],e.prototype,\"_samples\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"adaptScaleToCurrentViewport\",void 0),e}();c.a.RegisteredTypes[\"BABYLON.PostProcess\"]=li;var ui=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\nvoid main(void)\\n{\\ngl_FragColor=texture2D(textureSampler,vUV);\\n}\";ai.a.ShadersStore.passPixelShader=ui;var hi=\"\\nvarying vec2 vUV;\\nuniform samplerCube textureSampler;\\nvoid main(void)\\n{\\nvec2 uv=vUV*2.0-1.0;\\n#ifdef POSITIVEX\\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\\n#endif\\n#ifdef NEGATIVEX\\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\\n#endif\\n#ifdef POSITIVEY\\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\\n#endif\\n#ifdef NEGATIVEY\\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\\n#endif\\n#ifdef POSITIVEZ\\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\\n#endif\\n#ifdef NEGATIVEZ\\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\\n#endif\\n}\";ai.a.ShadersStore.passCubePixelShader=hi;var di=function(e){function t(t,i,n,r,o,a,s,c){return void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1),e.call(this,t,\"pass\",null,null,i,n,r,o,a,void 0,s,void 0,null,c)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"PassPostProcess\"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);c.a.RegisteredTypes[\"BABYLON.PassPostProcess\"]=di;var fi=function(e){function t(t,i,n,r,o,a,s,c){void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,\"passCube\",null,null,i,n,r,o,a,\"#define POSITIVEX\",s,void 0,null,c)||this;return l._face=0,l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"face\",{get:function(){return this._face},set:function(e){if(!(e<0||e>5))switch(this._face=e,this._face){case 0:this.updateEffect(\"#define POSITIVEX\");break;case 1:this.updateEffect(\"#define NEGATIVEX\");break;case 2:this.updateEffect(\"#define POSITIVEY\");break;case 3:this.updateEffect(\"#define NEGATIVEY\");break;case 4:this.updateEffect(\"#define POSITIVEZ\");break;case 5:this.updateEffect(\"#define NEGATIVEZ\")}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"PassCubePostProcess\"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);Se.a._RescalePostProcessFactory=function(e){return new di(\"rescale\",1,null,g.a.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,g.a.TEXTURETYPE_UNSIGNED_INT)};var pi=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\nuniform sampler2D leftSampler;\\nvoid main(void)\\n{\\nvec4 leftFrag=texture2D(leftSampler,vUV);\\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\\nvec4 rightFrag=texture2D(textureSampler,vUV);\\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\\n}\";ai.a.ShadersStore.anaglyphPixelShader=pi;var _i=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,\"anaglyph\",null,[\"leftSampler\"],i,n[1],r,o,a)||this;return s._passedProcess=n[0]._rigPostProcess,s.onApplyObservable.add((function(e){e.setTextureFromPostProcess(\"leftSampler\",s._passedProcess)})),s}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"AnaglyphPostProcess\"},t}(li);c.a.RegisteredTypes[\"BABYLON.AnaglyphPostProcess\"]=_i,je.a._setStereoscopicAnaglyphRigMode=function(e){e._rigCameras[0]._rigPostProcess=new di(e.name+\"_passthru\",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new _i(e.name+\"_anaglyph\",1,e._rigCameras)},B.a.AddNodeConstructor(\"AnaglyphArcRotateCamera\",(function(e,t,i){return function(){return new mi(e,0,0,1,a.e.Zero(),i.interaxial_distance,t)}}));var mi=function(e){function t(t,i,n,r,o,a,s){var c=e.call(this,t,i,n,r,o,s)||this;return c.interaxialDistance=a,c.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"AnaglyphArcRotateCamera\"},t}(Bt);B.a.AddNodeConstructor(\"AnaglyphFreeCamera\",(function(e,t,i){return function(){return new gi(e,a.e.Zero(),i.interaxial_distance,t)}}));var gi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"AnaglyphFreeCamera\"},t}(wt);B.a.AddNodeConstructor(\"AnaglyphGamepadCamera\",(function(e,t,i){return function(){return new vi(e,a.e.Zero(),i.interaxial_distance,t)}}));var vi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"AnaglyphGamepadCamera\"},t}(ri);B.a.AddNodeConstructor(\"AnaglyphUniversalCamera\",(function(e,t,i){return function(){return new bi(e,a.e.Zero(),i.interaxial_distance,t)}}));var bi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"AnaglyphUniversalCamera\"},t}(ni),yi=i(58);je.a._setStereoscopicRigMode=function(e){var t=e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,i=e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;e._rigCameras[i?1:0].viewport=new yi.a(0,0,t?.5:1,t?1:.5),e._rigCameras[i?0:1].viewport=new yi.a(t?.5:0,t?0:.5,t?.5:1,t?1:.5)},B.a.AddNodeConstructor(\"StereoscopicArcRotateCamera\",(function(e,t,i){return function(){return new Ti(e,0,0,1,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ti=function(e){function t(t,i,n,r,o,a,s,c){var l=e.call(this,t,i,n,r,o,c)||this;return l.interaxialDistance=a,l.isStereoscopicSideBySide=s,l.setCameraRigMode(s?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"StereoscopicArcRotateCamera\"},t}(Bt);B.a.AddNodeConstructor(\"StereoscopicFreeCamera\",(function(e,t,i){return function(){return new Ei(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ei=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"StereoscopicFreeCamera\"},t}(wt);B.a.AddNodeConstructor(\"StereoscopicGamepadCamera\",(function(e,t,i){return function(){return new Si(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Si=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"StereoscopicGamepadCamera\"},t}(ri);B.a.AddNodeConstructor(\"StereoscopicFreeCamera\",(function(e,t,i){return function(){return new Ai(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ai=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"StereoscopicUniversalCamera\"},t}(ni);B.a.AddNodeConstructor(\"VirtualJoysticksCamera\",(function(e,t){return function(){return new Pi(e,a.e.Zero(),t)}}));var Pi=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.inputs.addVirtualJoystick(),r}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"VirtualJoysticksCamera\"},t}(wt),Ci=function(){function e(){this.compensateDistortion=!0,this.multiviewEnabled=!1}return Object.defineProperty(e.prototype,\"aspectRatio\",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"aspectRatioFov\",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"leftHMatrix\",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return a.a.Translation(e,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"rightHMatrix\",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return a.a.Translation(-e,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"leftPreViewMatrix\",{get:function(){return a.a.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"rightPreViewMatrix\",{get:function(){return a.a.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!1,configurable:!0}),e.GetDefault=function(){var t=new e;return t.hResolution=1280,t.vResolution=800,t.hScreenSize=.149759993,t.vScreenSize=.0935999975,t.vScreenCenter=.0467999987,t.eyeToScreenDistance=.0410000011,t.lensSeparationDistance=.063500002,t.interpupillaryDistance=.064000003,t.distortionK=[1,.219999999,.239999995,0],t.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],t.postProcessScaleFactor=1.714605507808412,t.lensCenterOffset=.151976421,t},e}(),Ri=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\nuniform vec2 LensCenter;\\nuniform vec2 Scale;\\nuniform vec2 ScaleIn;\\nuniform vec4 HmdWarpParam;\\nvec2 HmdWarp(vec2 in01) {\\nvec2 theta=(in01-LensCenter)*ScaleIn;\\nfloat rSq=theta.x*theta.x+theta.y*theta.y;\\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\\nreturn LensCenter+Scale*rvector;\\n}\\nvoid main(void)\\n{\\nvec2 tc=HmdWarp(vUV);\\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\\nelse{\\ngl_FragColor=texture2D(textureSampler,tc);\\n}\\n}\";ai.a.ShadersStore.vrDistortionCorrectionPixelShader=Ri;var xi=function(e){function t(t,i,n,r){var o=e.call(this,t,\"vrDistortionCorrection\",[\"LensCenter\",\"Scale\",\"ScaleIn\",\"HmdWarpParam\"],null,r.postProcessScaleFactor,i,Ke.a.BILINEAR_SAMPLINGMODE)||this;return o._isRightEye=n,o._distortionFactors=r.distortionK,o._postProcessScaleFactor=r.postProcessScaleFactor,o._lensCenterOffset=r.lensCenterOffset,o.adaptScaleToCurrentViewport=!0,o.onSizeChangedObservable.add((function(){o._scaleIn=new a.d(2,2/o.aspectRatio),o._scaleFactor=new a.d(1/o._postProcessScaleFactor*.5,1/o._postProcessScaleFactor*.5*o.aspectRatio),o._lensCenter=new a.d(o._isRightEye?.5-.5*o._lensCenterOffset:.5+.5*o._lensCenterOffset,.5)})),o.onApplyObservable.add((function(e){e.setFloat2(\"LensCenter\",o._lensCenter.x,o._lensCenter.y),e.setFloat2(\"Scale\",o._scaleFactor.x,o._scaleFactor.y),e.setFloat2(\"ScaleIn\",o._scaleIn.x,o._scaleIn.y),e.setFloat4(\"HmdWarpParam\",o._distortionFactors[0],o._distortionFactors[1],o._distortionFactors[2],o._distortionFactors[3])})),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"VRDistortionCorrectionPostProcess\"},t}(li),Oi=\"precision mediump sampler2DArray;\\nvarying vec2 vUV;\\nuniform sampler2DArray multiviewSampler;\\nuniform int imageIndex;\\nvoid main(void)\\n{\\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\\n}\";ai.a.ShadersStore.vrMultiviewToSingleviewPixelShader=Oi;var Mi=i(85),Ii=i(95),Di=i(96);qe.a.prototype.createRenderTargetCubeTexture=function(e,t){var i=Object(h.a)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:g.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,format:g.a.TEXTUREFORMAT_RGBA},t);i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,(i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==g.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=g.a.TEXTURE_NEAREST_SAMPLINGMODE);var n=this._gl,r=new Qe.a(this,Qe.b.RenderTarget);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,r,!0);var o=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=g.a.TEXTURETYPE_UNSIGNED_INT,m.a.Warn(\"Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type\")),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,o.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,o.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);for(var a=0;a<6;a++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),e,e,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);var s=n.createFramebuffer();return this._bindUnboundFramebuffer(s),r._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,e,e),i.generateMipMaps&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),r._framebuffer=s,r.width=e,r.height=e,r.isReady=!0,r.isCube=!0,r.samples=1,r.generateMipMaps=i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r.format=i.format,r._generateDepthBuffer=i.generateDepthBuffer,r._generateStencilBuffer=i.generateStencilBuffer,this._internalTexturesCache.push(r),r};var Ni=function(e){function t(t,i,n,r,s,c,l,u,h,d,f,p,_){void 0===s&&(s=!0),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),void 0===u&&(u=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=!0),void 0===d&&(d=!1),void 0===f&&(f=!1),void 0===p&&(p=g.a.TEXTUREFORMAT_RGBA),void 0===_&&(_=!1);var m=e.call(this,null,n,!r)||this;return m.renderParticles=!0,m.renderSprites=!1,m.ignoreCameraViewport=!1,m.onBeforeBindObservable=new o.c,m.onAfterUnbindObservable=new o.c,m.onBeforeRenderObservable=new o.c,m.onAfterRenderObservable=new o.c,m.onClearObservable=new o.c,m.onResizeObservable=new o.c,m._currentRefreshId=-1,m._refreshRate=1,m._samples=1,m.boundingBoxPosition=a.e.Zero(),(n=m.getScene())?(m._coordinatesMode=Ke.a.PROJECTION_MODE,m.renderList=new Array,m.name=t,m.isRenderTarget=!0,m._initialSizeParameter=i,m._processSizeParameter(i),m._resizeObserver=m.getScene().getEngine().onResizeObservable.add((function(){})),m._generateMipMaps=!!r,m._doNotChangeAspectRatio=s,m._renderingManager=new Di.b(n),m._renderingManager._useSceneAutoClearSetup=!0,f||(m._renderTargetOptions={generateMipMaps:r,type:c,format:p,samplingMode:u,generateDepthBuffer:h,generateStencilBuffer:d},u===Ke.a.NEAREST_SAMPLINGMODE&&(m.wrapU=Ke.a.CLAMP_ADDRESSMODE,m.wrapV=Ke.a.CLAMP_ADDRESSMODE),_||(l?(m._texture=n.getEngine().createRenderTargetCubeTexture(m.getRenderSize(),m._renderTargetOptions),m.coordinatesMode=Ke.a.INVCUBIC_MODE,m._textureMatrix=a.a.Identity()):m._texture=n.getEngine().createRenderTargetTexture(m._size,m._renderTargetOptions))),m):m}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"renderList\",{get:function(){return this._renderList},set:function(e){this._renderList=e,this._renderList&&this._hookArray(this._renderList)},enumerable:!1,configurable:!0}),t.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var n=[],r=0;r0&&(this._postProcesses[0].autoClear=!1))}},t.prototype._shouldRender=function(){return-1===this._currentRefreshId||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},t.prototype.getRenderSize=function(){return this.getRenderWidth()},t.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},t.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},t.prototype.getRenderLayers=function(){var e=this._size.layers;return e||0},Object.defineProperty(t.prototype,\"canRescale\",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.scale=function(e){var t=Math.max(1,this.getRenderSize()*e);this.resize(t)},t.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:e.prototype.getReflectionTextureMatrix.call(this)},t.prototype.resize=function(e){var t=this.isCube;this.releaseInternalTexture();var i=this.getScene();i&&(this._processSizeParameter(e),this._texture=t?i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),s=this.getScene()){var i,n=s.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var r=0;r1||this.activeCamera&&this.activeCamera!==s.activeCamera)&&s.setTransformMatrix(s.activeCamera.getViewMatrix(),s.activeCamera.getProjectionMatrix(!0)),n.setViewport(s.activeCamera.viewport)),s.resetCachedMaterial()}},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var i=e*t,n=Se.a.NearestPOT(i+16384/(128+i));return Math.min(Se.a.FloorPOT(e),n)},t.prototype._prepareRenderingManager=function(e,t,i,n){var r=this.getScene();if(r){this._renderingManager.reset();for(var o=r.getRenderId(),a=0;a=0&&this._renderingManager.dispatchParticles(f))}}},t.prototype._bindFrameBuffer=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var i=this.getScene();if(i){var n=i.getEngine();this._texture&&n.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}},t.prototype.unbindFrameBuffer=function(e,t){var i=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,(function(){i.onAfterRenderObservable.notifyObservers(t)}))},t.prototype.renderToTarget=function(e,t,i,n,r){void 0===n&&(n=0),void 0===r&&(r=null);var o=this.getScene();if(o){var a=o.getEngine();if(this._texture){this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):t&&o.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(e,n),this.is2DArray?this.onBeforeRenderObservable.notifyObservers(n):this.onBeforeRenderObservable.notifyObservers(e);var s=null,c=this.renderList?this.renderList:o.getActiveMeshes().data,l=this.renderList?this.renderList.length:o.getActiveMeshes().length;this.getCustomRenderList&&(s=this.getCustomRenderList(this.is2DArray?n:e,c,l)),s?this._prepareRenderingManager(s,s.length,r,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(c,l,r,!this.renderList),this._defaultRenderListPrepared=!0),s=c),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(a):a.clear(this.clearColor||o.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0);for(var u=0,h=o._beforeRenderTargetDrawStage;u=0&&t.customRenderTargets.splice(i,1);for(var n=0,r=t.cameras;n=0&&o.customRenderTargets.splice(i,1)}this.depthStencilTexture&&this.getScene().getEngine()._releaseTexture(this.depthStencilTexture),e.prototype.dispose.call(this)}},t.prototype._rebuild=function(){this.refreshRate===t.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=t.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},t.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},t.prototype.getViewCount=function(){return 1},t.REFRESHRATE_RENDER_ONCE=0,t.REFRESHRATE_RENDER_ONEVERYFRAME=1,t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,t}(Ke.a);Ke.a._CreateRenderTargetTexture=function(e,t,i,n){return new Ni(e,t,i,n)};var Li=function(e){function t(t,i){void 0===i&&(i=512);var n=e.call(this,\"multiview rtt\",i,t,!1,!0,Qe.b.Unknown,!1,void 0,!1,!1,!0,void 0,!0)||this,r=t.getEngine().createMultiviewRenderTargetTexture(n.getRenderWidth(),n.getRenderHeight());return r.isMultiview=!0,r.format=g.a.TEXTUREFORMAT_RGBA,n._texture=r,n.samples=n._getEngine().getCaps().maxSamples||n.samples,n}return Object(h.d)(t,e),t.prototype._bindFrameBuffer=function(e){void 0===e&&(e=0),this._texture&&this.getScene().getEngine().bindMultiviewFramebuffer(this._texture)},t.prototype.getViewCount=function(){return 2},t}(Ni),wi=i(90);Se.a.prototype.createMultiviewRenderTargetTexture=function(e,t){var i=this._gl;if(!this.getCaps().multiview)throw\"Multiview is not supported\";var n=new Qe.a(this,Qe.b.Unknown,!0);return n.width=e,n.height=t,n._framebuffer=i.createFramebuffer(),n._colorTextureArray=i.createTexture(),i.bindTexture(i.TEXTURE_2D_ARRAY,n._colorTextureArray),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.RGBA8,e,t,2),n._depthStencilTextureArray=i.createTexture(),i.bindTexture(i.TEXTURE_2D_ARRAY,n._depthStencilTextureArray),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.DEPTH32F_STENCIL8,e,t,2),n.isReady=!0,n},Se.a.prototype.bindMultiviewFramebuffer=function(e){var t=this._gl,i=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(e,void 0,void 0,void 0,!0),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,e._framebuffer),!e._colorTextureArray||!e._depthStencilTextureArray)throw\"Invalid multiview frame buffer\";this.getCaps().oculusMultiview?(i.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,e.samples,0,2),i.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,e.samples,0,2)):(i.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,0,2),i.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,0,2))},je.a.prototype._useMultiviewToSingleView=!1,je.a.prototype._multiviewTexture=null,je.a.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new Li(this.getScene(),{width:e,height:t})):this._multiviewTexture=new Li(this.getScene(),{width:e,height:t})},Q.a.prototype._transformMatrixR=a.a.Zero(),Q.a.prototype._multiviewSceneUbo=null,Q.a.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=new Mi.a(this.getEngine(),void 0,!0),this._multiviewSceneUbo.addUniform(\"viewProjection\",16),this._multiviewSceneUbo.addUniform(\"viewProjectionR\",16),this._multiviewSceneUbo.addUniform(\"view\",16)},Q.a.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,a.c.Matrix[0]),wi.a.GetRightPlaneToRef(a.c.Matrix[0],this._frustumPlanes[3])),this._multiviewSceneUbo&&(this._multiviewSceneUbo.updateMatrix(\"viewProjection\",this.getTransformMatrix()),this._multiviewSceneUbo.updateMatrix(\"viewProjectionR\",this._transformMatrixR),this._multiviewSceneUbo.updateMatrix(\"view\",this._viewMatrix),this._multiviewSceneUbo.update())},Q.a.prototype._renderMultiviewToSingleView=function(e){e._resizeOrCreateMultiviewTexture(e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.width>0?e._rigPostProcess.width:this.getEngine().getRenderWidth(!0),e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.height>0?e._rigPostProcess.height:this.getEngine().getRenderHeight(!0)),this._multiviewSceneUbo||this._createMultiviewUbo(),e.outputRenderTarget=e._multiviewTexture,this._renderForCamera(e),e.outputRenderTarget=null;for(var t=0;t=2&&e.onControllersAttachedObservable.notifyObservers(e.controllers)}}}))},t}(wt),Gi=function(e){function t(t){var i=e.call(this,t)||this;return i.onTriggerStateChangedObservable=new o.c,i.onMainButtonStateChangedObservable=new o.c,i.onSecondaryButtonStateChangedObservable=new o.c,i.onPadStateChangedObservable=new o.c,i.onPadValuesChangedObservable=new o.c,i.pad={x:0,y:0},i._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},i._buttons=new Array(t.buttons.length),i.hand=t.hand,i}return Object(h.d)(t,e),t.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(t.prototype,\"defaultModel\",{get:function(){return this._defaultModel},enumerable:!1,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t\\n#include\\n#include\\nvoid main(void)\\n{\\nvec4 result=texture2D(textureSampler,vUV);\\n#ifdef IMAGEPROCESSING\\n#ifndef FROMLINEARSPACE\\n\\nresult.rgb=toLinearSpace(result.rgb);\\n#endif\\nresult=applyImageProcessing(result);\\n#else\\n\\n#ifdef FROMLINEARSPACE\\nresult=applyImageProcessing(result);\\n#endif\\n#endif\\ngl_FragColor=result;\\n}\");ai.a.ShadersStore.imageProcessingPixelShader=Xi;var Yi=function(e){function t(t,i,n,r,o,a,s,c){void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,t,\"imageProcessing\",[],[],i,n,r,o,a,null,s,\"postprocess\",null,!0)||this;return l._fromLinearSpace=!0,l._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,TONEMAPPING_ACES:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1},c?(c.applyByPostProcess=!0,l._attachImageProcessingConfiguration(c,!0),l.fromLinearSpace=!1):(l._attachImageProcessingConfiguration(null,!0),l.imageProcessingConfiguration.applyByPostProcess=!0),l.onApply=function(e){l.imageProcessingConfiguration.bind(e,l.aspectRatio)},l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"imageProcessingConfiguration\",{get:function(){return this._imageProcessingConfiguration},set:function(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e,t){var i=this;if(void 0===t&&(t=!1),e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{var n=null,r=this.getEngine(),o=this.getCamera();if(o)n=o.getScene();else if(r&&r.scenes){var a=r.scenes;n=a[a.length-1]}else n=x.a.LastCreatedScene;this._imageProcessingConfiguration=n?n.imageProcessingConfiguration:new ji.a}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){i._updateParameters()}))),t||this._updateParameters()}},Object.defineProperty(t.prototype,\"isSupported\",{get:function(){var e=this.getEffect();return!e||e.isSupported},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"colorCurves\",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"colorCurvesEnabled\",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"colorGradingTexture\",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"colorGradingEnabled\",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"exposure\",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"toneMappingEnabled\",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"toneMappingType\",{get:function(){return this._imageProcessingConfiguration.toneMappingType},set:function(e){this._imageProcessingConfiguration.toneMappingType=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"contrast\",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vignetteStretch\",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vignetteCentreX\",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vignetteCentreY\",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vignetteWeight\",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vignetteColor\",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vignetteCameraFov\",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vignetteBlendMode\",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vignetteEnabled\",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"fromLinearSpace\",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"ImageProcessingPostProcess\"},t.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);var e=\"\";for(var t in this._defines)this._defines[t]&&(e+=\"#define \"+t+\";\\r\\n\");var i=[\"textureSampler\"],n=[\"scale\"];ji.a&&(ji.a.PrepareSamplers(i,this._defines),ji.a.PrepareUniforms(n,this._defines)),this.updateEffect(e,n,i)},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)},Object(h.c)([Object(w.c)()],t.prototype,\"_fromLinearSpace\",void 0),t}(li),Ki=i(16),Qi=i(4);be.a._GroundMeshParser=function(e,t){return qi.Parse(e,t)};var qi=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.generateOctree=!1,n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"GroundMesh\"},Object.defineProperty(t.prototype,\"subdivisions\",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"subdivisionsX\",{get:function(){return this._subdivisionsX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"subdivisionsY\",{get:function(){return this._subdivisionsY},enumerable:!1,configurable:!0}),t.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},t.prototype.getHeightAtCoordinates=function(e,t){var i=this.getWorldMatrix(),n=a.c.Matrix[5];i.invertToRef(n);var r=a.c.Vector3[8];if(a.e.TransformCoordinatesFromFloatsToRef(e,0,t,n,r),e=r.x,t=r.z,ethis._maxX||tthis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var o=this._getFacetAt(e,t),s=-(o.x*e+o.z*t+o.w)/o.y;return a.e.TransformCoordinatesFromFloatsToRef(0,s,0,i,r),r.y},t.prototype.getNormalAtCoordinates=function(e,t){var i=new a.e(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i},t.prototype.getNormalAtCoordinatesToRef=function(e,t,i){var n=this.getWorldMatrix(),r=a.c.Matrix[5];n.invertToRef(r);var o=a.c.Vector3[8];if(a.e.TransformCoordinatesFromFloatsToRef(e,0,t,r,o),e=o.x,t=o.z,ethis._maxX||tthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(e,t);return a.e.TransformNormalFromFloatsToRef(s.x,s.y,s.z,n,i),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,t){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[n*this._subdivisionsX+i];return te.maxHeight){h=!0;var d=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=d}for(t=0;t<=e.subdivisions;t++)for(i=0;i<=e.subdivisions;i++){var f=new a.e(i*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),p=4*(((f.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(f.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),_=e.buffer[p]/255,m=e.buffer[p+1]/255,g=e.buffer[p+2]/255,v=e.buffer[p+3]/255;h&&(_=1-_,m=1-m,g=1-g);var b=_*l.r+m*l.g+g*l.b;f.y=v>=u?e.minHeight+(e.maxHeight-e.minHeight)*b:e.minHeight-Nt.a,r.push(f.x,f.y,f.z),o.push(0,0,0),c.push(i/e.subdivisions,1-t/e.subdivisions)}for(t=0;t=e.minHeight,P=r[3*T+1]>=e.minHeight,C=r[3*E+1]>=e.minHeight;A&&P&&C&&(n.push(y),n.push(T),n.push(E)),r[3*S+1]>=e.minHeight&&A&&C&&(n.push(S),n.push(y),n.push(E))}Ki.a.ComputeNormals(r,n,o);var R=new Ki.a;return R.indices=n,R.positions=r,R.normals=o,R.uvs=c,R},be.a.CreateGround=function(e,t,i,n,r,o){var a={width:t,height:i,subdivisions:n,updatable:o};return Ji.CreateGround(e,a,r)},be.a.CreateTiledGround=function(e,t,i,n,r,o,a,s,c){var l={xmin:t,zmin:i,xmax:n,zmax:r,subdivisions:o,precision:a,updatable:c};return Ji.CreateTiledGround(e,l,s)},be.a.CreateGroundFromHeightMap=function(e,t,i,n,r,o,a,s,c,l,u){var h={width:i,height:n,subdivisions:r,minHeight:o,maxHeight:a,updatable:c,onReady:l,alphaFilter:u};return Ji.CreateGroundFromHeightMap(e,t,h,s)};var Ji=function(){function e(){}return e.CreateGround=function(e,t,i){var n=new qi(e,i);return n._setReady(!1),n._subdivisionsX=t.subdivisionsX||t.subdivisions||1,n._subdivisionsY=t.subdivisionsY||t.subdivisions||1,n._width=t.width||1,n._height=t.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ,Ki.a.CreateGround(t).applyToMesh(n,t.updatable),n._setReady(!0),n},e.CreateTiledGround=function(e,t,i){void 0===i&&(i=null);var n=new be.a(e,i);return Ki.a.CreateTiledGround(t).applyToMesh(n,t.updatable),n},e.CreateGroundFromHeightMap=function(e,t,i,n){void 0===n&&(n=null);var r=i.width||10,o=i.height||10,a=i.subdivisions||1,c=i.minHeight||0,l=i.maxHeight||1,u=i.colorFilter||new s.a(.3,.59,.11),h=i.alphaFilter||0,d=i.updatable,f=i.onReady;n=n||x.a.LastCreatedScene;var p=new qi(e,n);p._subdivisionsX=a,p._subdivisionsY=a,p._width=r,p._height=o,p._maxX=p._width/2,p._maxZ=p._height/2,p._minX=-p._maxX,p._minZ=-p._maxZ,p._setReady(!1);return Ce.b.LoadImage(t,(function(e){var t=e.width,i=e.height,s=Zi.a.CreateCanvas(t,i).getContext(\"2d\");if(!s)throw new Error(\"Unable to get 2d context for CreateGroundFromHeightMap\");if(!n.isDisposed){s.drawImage(e,0,0);var _=s.getImageData(0,0,t,i).data;Ki.a.CreateGroundFromHeightMap({width:r,height:o,subdivisions:a,minHeight:c,maxHeight:l,colorFilter:u,buffer:_,bufferWidth:t,bufferHeight:i,alphaFilter:h}).applyToMesh(p,d),f&&f(p),p._setReady(!0)}}),(function(){}),n.offlineProvider),p},e}();Ki.a.CreateTorus=function(e){for(var t=[],i=[],n=[],r=[],o=e.diameter||1,s=e.thickness||.5,c=e.tessellation||16,l=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE,u=c+1,h=0;h<=c;h++)for(var d=h/c,f=h*Math.PI*2/c-Math.PI/2,p=a.a.Translation(o/2,0,0).multiply(a.a.RotationY(f)),_=0;_<=c;_++){var m=1-_/c,g=_*Math.PI*2/c+Math.PI,v=Math.cos(g),b=Math.sin(g),y=new a.e(v,b,0),T=y.scale(s/2),E=new a.d(d,m);T=a.e.TransformCoordinates(T,p),y=a.e.TransformNormal(y,p),i.push(T.x,T.y,T.z),n.push(y.x,y.y,y.z),r.push(E.x,E.y);var S=(h+1)%u,A=(_+1)%u;t.push(h*u+_),t.push(h*u+A),t.push(S*u+_),t.push(h*u+A),t.push(S*u+A),t.push(S*u+_)}Ki.a._ComputeSides(l,i,t,n,r,e.frontUVs,e.backUVs);var P=new Ki.a;return P.indices=t,P.positions=i,P.normals=n,P.uvs=r,P},be.a.CreateTorus=function(e,t,i,n,r,o,a){var s={diameter:t,thickness:i,tessellation:n,sideOrientation:a,updatable:o};return tn.CreateTorus(e,s,r)};var $i,en,tn=function(){function e(){}return e.CreateTorus=function(e,t,i){var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreateTorus(t).applyToMesh(n,t.updatable),n},e}(),nn=i(53),rn=function(){function e(){}return e.GetDefaults=function(t){var i=new e;return i.canvasOptions={antialias:!0,depth:!0,stencil:!t||t.isStencilEnable,alpha:!0,multiview:!1,framebufferScaleFactor:1},i.newCanvasCssStyle=\"position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;\",i},e}(),on=function(){function e(e,t){var i=this;if(void 0===t&&(t=rn.GetDefaults()),this._options=t,this._canvas=null,this.xrLayer=null,this.onXRLayerInitObservable=new o.c,this._engine=e.scene.getEngine(),t.canvasElement)this._setManagedOutputCanvas(t.canvasElement);else{var n=document.createElement(\"canvas\");n.style.cssText=this._options.newCanvasCssStyle||\"position:absolute; bottom:0px;right:0px;\",this._setManagedOutputCanvas(n)}e.onXRSessionInit.add((function(){i._addCanvas()})),e.onXRSessionEnded.add((function(){i._removeCanvas()}))}return e.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},e.prototype.initializeXRLayerAsync=function(e){var t=this,i=function(){var i=new XRWebGLLayer(e,t.canvasContext,t._options.canvasOptions);return t.onXRLayerInitObservable.notifyObservers(i),i};return this.canvasContext.makeXRCompatible?this.canvasContext.makeXRCompatible().then((function(){return t.xrLayer=i(),t.xrLayer})):(this.xrLayer=i(),Promise.resolve(this.xrLayer))},e.prototype._addCanvas=function(){var e=this;this._canvas&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.appendChild(this._canvas),this.xrLayer?this._setCanvasSize(!0):this.onXRLayerInitObservable.addOnce((function(t){e._setCanvasSize(!0,t)}))},e.prototype._removeCanvas=function(){this._canvas&&document.body.contains(this._canvas)&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.removeChild(this._canvas),this._setCanvasSize(!1)},e.prototype._setCanvasSize=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=this.xrLayer),this._canvas&&(e?t&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=t.framebufferWidth+\"px\",this._canvas.style.height=t.framebufferHeight+\"px\"):this._engine.setSize(t.framebufferWidth,t.framebufferHeight)):this._originalCanvasSize&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=this._originalCanvasSize.width+\"px\",this._canvas.style.height=this._originalCanvasSize.height+\"px\"):this._engine.setSize(this._originalCanvasSize.width,this._originalCanvasSize.height)))},e.prototype._setManagedOutputCanvas=function(e){this._removeCanvas(),e?(this._originalCanvasSize={width:e.offsetWidth,height:e.offsetHeight},this._canvas=e,this.canvasContext=this._canvas.getContext(\"webgl2\"),this.canvasContext||(this.canvasContext=this._canvas.getContext(\"webgl\"))):(this._canvas=null,this.canvasContext=null)},e}(),an=function(){function e(e){this.scene=e,this._sessionEnded=!1,this.baseLayer=null,this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this.onXRFrameObservable=new o.c,this.onXRReferenceSpaceChanged=new o.c,this.onXRSessionEnded=new o.c,this.onXRSessionInit=new o.c}return Object.defineProperty(e.prototype,\"referenceSpace\",{get:function(){return this._referenceSpace},set:function(e){this._referenceSpace=e,this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._sessionEnded||this.exitXRAsync(),this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear(),this.onXRReferenceSpaceChanged.clear(),this.onXRSessionInit.clear()},e.prototype.exitXRAsync=function(){return this.session&&!this._sessionEnded?(this._sessionEnded=!0,this.session.end().catch((function(e){m.a.Warn(\"Could not end XR session.\")}))):Promise.resolve()},e.prototype.getRenderTargetTextureForEye=function(e){return this._rttProvider.getRenderTargetForEye(e)},e.prototype.getWebXRRenderTarget=function(e){var t=this.scene.getEngine();return this._xrNavigator.xr.native?this._xrNavigator.xr.getWebXRRenderTarget(t):((e=e||rn.GetDefaults(t)).canvasElement=t.getRenderingCanvas()||void 0,new on(this,e))},e.prototype.initializeAsync=function(){return this._xrNavigator=navigator,this._xrNavigator.xr?Promise.resolve():Promise.reject(\"WebXR not available\")},e.prototype.initializeSessionAsync=function(e,t){var i=this;return void 0===e&&(e=\"immersive-vr\"),void 0===t&&(t={}),this._xrNavigator.xr.requestSession(e,t).then((function(e){return i.session=e,i.onXRSessionInit.notifyObservers(e),i._sessionEnded=!1,i.session.addEventListener(\"end\",(function(){var e=i.scene.getEngine();i._sessionEnded=!0,i._rttProvider=null,e.framebufferDimensionsObject=null,e.restoreDefaultFramebuffer(),e.customAnimationFrameRequester=null,i.onXRSessionEnded.notifyObservers(null),e._renderLoop()}),{once:!0}),i.session}))},e.prototype.isSessionSupportedAsync=function(t){return e.IsSessionSupportedAsync(t)},e.prototype.resetReferenceSpace=function(){this.referenceSpace=this.baseReferenceSpace},e.prototype.runXRRenderLoop=function(){var e=this,t=this.scene.getEngine();if(t.customAnimationFrameRequester={requestAnimationFrame:this.session.requestAnimationFrame.bind(this.session),renderFunction:function(i,n){e._sessionEnded||(e.currentFrame=n,e.currentTimestamp=i,n&&(t.framebufferDimensionsObject=e.baseLayer,e.onXRFrameObservable.notifyObservers(n),t._renderLoop(),t.framebufferDimensionsObject=null))}},this._xrNavigator.xr.native)this._rttProvider=this._xrNavigator.xr.getNativeRenderTargetProvider(this.session,this._createRenderTargetTexture.bind(this));else{var i=this._createRenderTargetTexture(this.baseLayer.framebufferWidth,this.baseLayer.framebufferHeight,this.baseLayer.framebuffer);this._rttProvider={getRenderTargetForEye:function(){return i}},t.framebufferDimensionsObject=this.baseLayer}\"undefined\"!=typeof window&&window.cancelAnimationFrame&&window.cancelAnimationFrame(t._frameHandler),t._renderLoop()},e.prototype.setReferenceSpaceTypeAsync=function(e){var t=this;return void 0===e&&(e=\"local-floor\"),this.session.requestReferenceSpace(e).then((function(e){return e}),(function(e){return m.a.Error(\"XR.requestReferenceSpace failed for the following reason: \"),m.a.Error(e),m.a.Log('Defaulting to universally-supported \"viewer\" reference space type.'),t.session.requestReferenceSpace(\"viewer\").then((function(e){var i=new XRRigidTransform({x:0,y:-t.defaultHeightCompensation,z:0});return e.getOffsetReferenceSpace(i)}),(function(e){throw m.a.Error(e),'XR initialization failed: required \"viewer\" reference space type not supported.'}))})).then((function(e){return t.session.requestReferenceSpace(\"viewer\").then((function(i){return t.viewerReferenceSpace=i,e}))})).then((function(e){return t.referenceSpace=t.baseReferenceSpace=e,t.referenceSpace}))},e.prototype.updateRenderStateAsync=function(e){return e.baseLayer&&(this.baseLayer=e.baseLayer),this.session.updateRenderState(e)},e.IsSessionSupportedAsync=function(e){if(!navigator.xr)return Promise.resolve(!1);var t=navigator.xr.isSessionSupported||navigator.xr.supportsSession;return t?t.call(navigator.xr,e).then((function(e){var t=void 0===e||e;return Promise.resolve(t)})).catch((function(e){return m.a.Warn(e),Promise.resolve(!1)})):Promise.resolve(!1)},e.prototype._createRenderTargetTexture=function(e,t,i){void 0===i&&(i=null);var n=new Qe.a(this.scene.getEngine(),Qe.b.Unknown,!0);n.width=e,n.height=t,n._framebuffer=i;var r=new Ni(\"XR renderTargetTexture\",{width:e,height:t},this.scene,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0);return r._texture=n,r},e}();!function(e){e[e.ENTERING_XR=0]=\"ENTERING_XR\",e[e.EXITING_XR=1]=\"EXITING_XR\",e[e.IN_XR=2]=\"IN_XR\",e[e.NOT_IN_XR=3]=\"NOT_IN_XR\"}($i||($i={})),function(e){e[e.NOT_TRACKING=0]=\"NOT_TRACKING\",e[e.TRACKING_LOST=1]=\"TRACKING_LOST\",e[e.TRACKING=2]=\"TRACKING\"}(en||(en={}));var sn,cn=function(){function e(t,i){if(void 0===i&&(i=null),this.scene=t,this._pointerDownOnMeshAsked=!1,this._isActionableMesh=!1,this._teleportationRequestInitiated=!1,this._teleportationBackRequestInitiated=!1,this._rotationRightAsked=!1,this._rotationLeftAsked=!1,this._dpadPressed=!0,this._activePointer=!1,this._id=e._idCounter++,i)this._gazeTracker=i.clone(\"gazeTracker\");else{this._gazeTracker=be.a.CreateTorus(\"gazeTracker\",.0035,.0025,20,t,!1),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var n=new Wi.a(\"targetMat\",t);n.specularColor=s.a.Black(),n.emissiveColor=new s.a(.7,.7,.7),n.backFaceCulling=!1,this._gazeTracker.material=n}}return e.prototype._getForwardRay=function(e){return new Xt.a(a.e.Zero(),new a.e(0,0,e))},e.prototype._selectionPointerDown=function(){this._pointerDownOnMeshAsked=!0,this._currentHit&&this.scene.simulatePointerDown(this._currentHit,{pointerId:this._id})},e.prototype._selectionPointerUp=function(){this._currentHit&&this.scene.simulatePointerUp(this._currentHit,{pointerId:this._id}),this._pointerDownOnMeshAsked=!1},e.prototype._activatePointer=function(){this._activePointer=!0},e.prototype._deactivatePointer=function(){this._activePointer=!1},e.prototype._updatePointerDistance=function(e){void 0===e&&(e=100)},e.prototype.dispose=function(){this._interactionsEnabled=!1,this._teleportationEnabled=!1,this._gazeTracker&&this._gazeTracker.dispose()},e._idCounter=0,e}(),ln=function(e){function t(t,i,n){var r=e.call(this,i,n)||this;r.webVRController=t,r._laserPointer=be.a.CreateCylinder(\"laserPointer\",1,.004,2e-4,20,1,i,!1);var o=new Wi.a(\"laserPointerMat\",i);if(o.emissiveColor=new s.a(.7,.7,.7),o.alpha=.6,r._laserPointer.material=o,r._laserPointer.rotation.x=Math.PI/2,r._laserPointer.position.z=-.5,r._laserPointer.isVisible=!1,r._laserPointer.isPickable=!1,!t.mesh){var a=new be.a(\"preloadControllerMesh\",i),c=new be.a(qt.POINTING_POSE,i);c.rotation.x=-.7,a.addChild(c),t.attachToMesh(a)}return r._setLaserPointerParent(t.mesh),r._meshAttachedObserver=t._meshAttachedObservable.add((function(e){r._setLaserPointerParent(e)})),r}return Object(h.d)(t,e),t.prototype._getForwardRay=function(e){return this.webVRController.getForwardRay(e)},t.prototype._activatePointer=function(){e.prototype._activatePointer.call(this),this._laserPointer.isVisible=!0},t.prototype._deactivatePointer=function(){e.prototype._deactivatePointer.call(this),this._laserPointer.isVisible=!1},t.prototype._setLaserPointerColor=function(e){this._laserPointer.material.emissiveColor=e},t.prototype._setLaserPointerLightingDisabled=function(e){this._laserPointer.material.disableLighting=e},t.prototype._setLaserPointerParent=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e);var i=e.getChildren(void 0,!1),n=e;this.webVRController._pointingPoseNode=null;for(var r=0;r=0){n=i[r],this.webVRController._pointingPoseNode=n;break}this._laserPointer.parent=n},t.prototype._updatePointerDistance=function(e){void 0===e&&(e=100),this._laserPointer.scaling.y=e,this._laserPointer.position.z=-e/2},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._laserPointer.dispose(),this._meshAttachedObserver&&this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)},t}(cn),un=function(e){function t(t,i){var n=e.call(this,i)||this;return n.getCamera=t,n}return Object(h.d)(t,e),t.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new Xt.a(a.e.Zero(),a.e.Forward())},t}(cn),hn=function(){},dn=function(){function e(t,i){var n=this;if(void 0===i&&(i={}),this.webVROptions=i,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.enableGazeEvenWhenNoPointerLock=!1,this.exitVROnDoubleTap=!0,this.onEnteringVRObservable=new o.c,this.onAfterEnteringVRObservable=new o.c,this.onExitingVRObservable=new o.c,this.onControllerMeshLoadedObservable=new o.c,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._teleportationMode=e.TELEPORTATIONMODE_CONSTANTTIME,this._teleportationTime=122,this._teleportationSpeed=20,this._rotationAllowed=!0,this._teleportBackwardsVector=new a.e(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor=\"#444444\",this._teleportationBorderColor=\"#FFFFFF\",this._rotationAngle=0,this._haloCenter=new a.e(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this._gazeColor=new s.a(.7,.7,.7),this._laserColor=new s.a(.7,.7,.7),this._pickedLaserColor=new s.a(.2,.2,1),this._pickedGazeColor=new s.a(0,0,1),this.onNewMeshSelected=new o.c,this.onMeshSelectedWithController=new o.c,this.onNewMeshPicked=new o.c,this.onBeforeCameraTeleport=new o.c,this.onAfterCameraTeleport=new o.c,this.onSelectedMeshUnselected=new o.c,this.teleportationEnabled=!0,this._teleportationInitialized=!1,this._interactionsEnabled=!1,this._interactionsRequested=!1,this._displayGaze=!0,this._displayLaserPointer=!0,this.updateGazeTrackerScale=!0,this.updateGazeTrackerColor=!0,this.updateControllerLaserColor=!0,this.requestPointerLockOnFullScreen=!0,this.xrTestDone=!1,this._onResize=function(){n.moveButtonToBottomRight(),n._fullscreenVRpresenting&&n._webVRready&&n.exitVR()},this._onFullscreenChange=function(){var e=document;void 0!==e.fullscreen?n._fullscreenVRpresenting=document.fullscreen:void 0!==e.mozFullScreen?n._fullscreenVRpresenting=e.mozFullScreen:void 0!==e.webkitIsFullScreen?n._fullscreenVRpresenting=e.webkitIsFullScreen:void 0!==e.msIsFullScreen?n._fullscreenVRpresenting=e.msIsFullScreen:void 0!==document.msFullscreenElement&&(n._fullscreenVRpresenting=document.msFullscreenElement),!n._fullscreenVRpresenting&&n._inputElement&&(n.exitVR(),!n._useCustomVRButton&&n._btnVR&&(n._btnVR.style.top=n._inputElement.offsetTop+n._inputElement.offsetHeight-70+\"px\",n._btnVR.style.left=n._inputElement.offsetLeft+n._inputElement.offsetWidth-100+\"px\",n.updateButtonVisibility()))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this.beforeRender=function(){n._leftController&&n._leftController._activePointer&&n._castRayAndSelectObject(n._leftController),n._rightController&&n._rightController._activePointer&&n._castRayAndSelectObject(n._rightController),n._noControllerIsActive&&(n._scene.getEngine().isPointerLock||n.enableGazeEvenWhenNoPointerLock)?n._castRayAndSelectObject(n._cameraGazer):n._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==ot.POSE_ENABLED)e.leftStick&&e.onleftstickchanged((function(e){n._teleportationInitialized&&n.teleportationEnabled&&(!n._leftController&&!n._rightController||n._leftController&&!n._leftController._activePointer&&n._rightController&&!n._rightController._activePointer)&&(n._checkTeleportWithRay(e,n._cameraGazer),n._checkTeleportBackwards(e,n._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){n._teleportationInitialized&&n._checkRotate(e,n._cameraGazer)})),e.type===ot.XBOX&&(e.onbuttondown((function(e){n._interactionsEnabled&&e===Yt.A&&n._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){n._interactionsEnabled&&e===Yt.A&&n._cameraGazer._selectionPointerUp()})));else{var t=e,i=new ln(t,n._scene,n._cameraGazer._gazeTracker);\"right\"===t.hand||n._leftController&&n._leftController.webVRController!=t?n._rightController=i:n._leftController=i,n._tryEnableInteractionOnController(i)}},this._tryEnableInteractionOnController=function(e){n._interactionsRequested&&!e._interactionsEnabled&&n._enableInteractionOnController(e),n._teleportationRequested&&!e._teleportationEnabled&&n._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof Gi&&(\"left\"===e.hand&&null!=n._leftController&&(n._leftController.dispose(),n._leftController=null),\"right\"===e.hand&&null!=n._rightController&&(n._rightController.dispose(),n._rightController=null))},this._workingVector=a.e.Zero(),this._workingQuaternion=a.b.Identity(),this._workingMatrix=a.a.Identity(),this._scene=t,this._inputElement=t.getEngine().getInputElement(),\"getVRDisplays\"in navigator||(i.useXR=!0),void 0===i.createFallbackVRDeviceOrientationFreeCamera&&(i.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===i.createDeviceOrientationCamera&&(i.createDeviceOrientationCamera=!0),void 0===i.laserToggle&&(i.laserToggle=!0),void 0===i.defaultHeight&&(i.defaultHeight=1.7),i.useCustomVRButton&&(this._useCustomVRButton=!0,i.customVRButton&&(this._btnVR=i.customVRButton)),i.rayLength&&(this._rayLength=i.rayLength),this._defaultHeight=i.defaultHeight,i.positionScale&&(this._rayLength*=i.positionScale,this._defaultHeight*=i.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new a.e(0,this._defaultHeight,0),i.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new Ut(\"deviceOrientationVRHelper\",this._position.clone(),t),this._scene.activeCamera&&(this._deviceOrientationCamera.minZ=this._scene.activeCamera.minZ,this._deviceOrientationCamera.maxZ=this._scene.activeCamera.maxZ,this._scene.activeCamera instanceof Lt&&this._scene.activeCamera.rotation)){var r=this._scene.activeCamera;r.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(r.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(a.b.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z)),this._deviceOrientationCamera.rotation=r.rotation.clone()}this._scene.activeCamera=this._deviceOrientationCamera,this._inputElement&&this._scene.activeCamera.attachControl()}else this._existingCamera=this._scene.activeCamera;this.webVROptions.useXR&&navigator.xr?an.IsSessionSupportedAsync(\"immersive-vr\").then((function(e){e?(m.a.Log(\"Using WebXR. It is recommended to use the WebXRDefaultExperience directly\"),t.createDefaultXRExperienceAsync({floorMeshes:i.floorMeshes||[]}).then((function(e){n.xr=e,n.xrTestDone=!0,n._cameraGazer=new un((function(){return n.xr.baseExperience.camera}),t),n.xr.baseExperience.onStateChangedObservable.add((function(e){switch(e){case $i.ENTERING_XR:n.onEnteringVRObservable.notifyObservers(n),n._interactionsEnabled||n.xr.pointerSelection.detach(),n.xr.pointerSelection.displayLaserPointer=n._displayLaserPointer;break;case $i.EXITING_XR:n.onExitingVRObservable.notifyObservers(n),n._scene.getEngine().resize();break;case $i.IN_XR:n._hasEnteredVR=!0;break;case $i.NOT_IN_XR:n._hasEnteredVR=!1}}))}))):n.completeVRInit(t,i)})):this.completeVRInit(t,i)}return Object.defineProperty(e.prototype,\"onEnteringVR\",{get:function(){return this.onEnteringVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onExitingVR\",{get:function(){return this.onExitingVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onControllerMeshLoaded\",{get:function(){return this.onControllerMeshLoadedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"teleportationTarget\",{get:function(){return this._teleportationTarget},set:function(e){e&&(e.name=\"teleportationTarget\",this._isDefaultTeleportationTarget=!1,this._teleportationTarget=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"gazeTrackerMesh\",{get:function(){return this._cameraGazer._gazeTracker},set:function(e){e&&(this._cameraGazer._gazeTracker&&this._cameraGazer._gazeTracker.dispose(),this._leftController&&this._leftController._gazeTracker&&this._leftController._gazeTracker.dispose(),this._rightController&&this._rightController._gazeTracker&&this._rightController._gazeTracker.dispose(),this._cameraGazer._gazeTracker=e,this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),this._cameraGazer._gazeTracker.isPickable=!1,this._cameraGazer._gazeTracker.isVisible=!1,this._cameraGazer._gazeTracker.name=\"gazeTracker\",this._leftController&&(this._leftController._gazeTracker=this._cameraGazer._gazeTracker.clone(\"gazeTracker\")),this._rightController&&(this._rightController._gazeTracker=this._cameraGazer._gazeTracker.clone(\"gazeTracker\")))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"leftControllerGazeTrackerMesh\",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"rightControllerGazeTrackerMesh\",{get:function(){return this._rightController?this._rightController._gazeTracker:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"displayGaze\",{get:function(){return this._displayGaze},set:function(e){this._displayGaze=e,e||(this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"displayLaserPointer\",{get:function(){return this._displayLaserPointer},set:function(e){this._displayLaserPointer=e,e?(this._rightController&&this._rightController._activatePointer(),this._leftController&&this._leftController._activatePointer()):(this._rightController&&(this._rightController._deactivatePointer(),this._rightController._gazeTracker.isVisible=!1),this._leftController&&(this._leftController._deactivatePointer(),this._leftController._gazeTracker.isVisible=!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"deviceOrientationCamera\",{get:function(){return this._deviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"currentVRCamera\",{get:function(){return this._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"webVRCamera\",{get:function(){return this._webVRCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"vrDeviceOrientationCamera\",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"vrButton\",{get:function(){return this._btnVR},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"_teleportationRequestInitiated\",{get:function(){return this._cameraGazer._teleportationRequestInitiated||null!==this._leftController&&this._leftController._teleportationRequestInitiated||null!==this._rightController&&this._rightController._teleportationRequestInitiated},enumerable:!1,configurable:!0}),e.prototype.completeVRInit=function(e,t){var i=this;if(this.xrTestDone=!0,t.createFallbackVRDeviceOrientationFreeCamera&&(t.useMultiview&&(t.vrDeviceOrientationCameraMetrics||(t.vrDeviceOrientationCameraMetrics=Ci.GetDefault()),t.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new Ui(\"VRDeviceOrientationVRHelper\",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new zi(\"WebVRHelper\",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new un((function(){return i.currentVRCamera}),e),!this._useCustomVRButton){this._btnVR=document.createElement(\"BUTTON\"),this._btnVR.className=\"babylonVRicon\",this._btnVR.id=\"babylonVRiconbtn\",this._btnVR.title=\"Click to switch to VR\";var n=\".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(\"+(window.SVGSVGElement?\"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A\":\"https://cdn.babylonjs.com/Assets/vrButton.png\")+\"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }\";n+=\".babylonVRicon.vrdisplaypresenting { display: none; }\";var r=document.createElement(\"style\");r.appendChild(document.createTextNode(n)),document.getElementsByTagName(\"head\")[0].appendChild(r),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener(\"click\",(function(){i.isInVRMode?i._scene.getEngine().disableVR():i.enterVR()}));var o=this._scene.getEngine().getHostWindow();o&&(o.addEventListener(\"resize\",this._onResize),document.addEventListener(\"fullscreenchange\",this._onFullscreenChange,!1),document.addEventListener(\"mozfullscreenchange\",this._onFullscreenChange,!1),document.addEventListener(\"webkitfullscreenchange\",this._onFullscreenChange,!1),document.addEventListener(\"msfullscreenchange\",this._onFullscreenChange,!1),document.onmsfullscreenchange=this._onFullscreenChange,t.createFallbackVRDeviceOrientationFreeCamera?this.displayVRButton():this._scene.getEngine().onVRDisplayChangedObservable.add((function(e){e.vrDisplay&&i.displayVRButton()})),this._onKeyDown=function(e){27===e.keyCode&&i.isInVRMode&&i.exitVR()},document.addEventListener(\"keydown\",this._onKeyDown),this._scene.onPrePointerObservable.add((function(){i._hasEnteredVR&&i.exitVROnDoubleTap&&(i.exitVR(),i._fullscreenVRpresenting&&i._scene.getEngine().exitFullscreen())}),Ne.a.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(e){return i.onVRDisplayChanged(e)},this._onVrDisplayPresentChange=function(){return i.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){i._webVRrequesting=!0,i.updateButtonVisibility()},this._onVRRequestPresentComplete=function(){i._webVRrequesting=!1,i.updateButtonVisibility()},e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged),e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),o.addEventListener(\"vrdisplaypresentchange\",this._onVrDisplayPresentChange),e.onDisposeObservable.add((function(){i.dispose()})),this._webVRCamera.onControllerMeshLoadedObservable.add((function(e){return i._onDefaultMeshLoaded(e)})),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new ae,this._circleEase.setEasingMode(oe.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,e.onPointerObservable.add((function(t){i._interactionsEnabled&&e.activeCamera===i.vrDeviceOrientationCamera&&\"mouse\"===t.event.pointerType&&(t.type===Ne.a.POINTERDOWN?i._cameraGazer._selectionPointerDown():t.type===Ne.a.POINTERUP&&i._cameraGazer._selectionPointerUp())})),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes}))},e.prototype._onDefaultMeshLoaded=function(e){this._leftController&&this._leftController.webVRController==e&&e.mesh&&this._leftController._setLaserPointerParent(e.mesh),this._rightController&&this._rightController.webVRController==e&&e.mesh&&this._rightController._setLaserPointerParent(e.mesh);try{this.onControllerMeshLoadedObservable.notifyObservers(e)}catch(e){m.a.Warn(\"Error in your custom logic onControllerMeshLoaded: \"+e)}},Object.defineProperty(e.prototype,\"isInVRMode\",{get:function(){return this.xr&&this.webVROptions.useXR&&this.xr.baseExperience.state===$i.IN_XR||this._webVRpresenting||this._fullscreenVRpresenting},enumerable:!1,configurable:!0}),e.prototype.onVrDisplayPresentChange=function(){var e=this._scene.getEngine().getVRDevice();if(e){var t=this._webVRpresenting;this._webVRpresenting=e.isPresenting,t&&!this._webVRpresenting&&this.exitVR()}else m.a.Warn(\"Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?\");this.updateButtonVisibility()},e.prototype.onVRDisplayChanged=function(e){this._webVRsupported=e.vrSupported,this._webVRready=!!e.vrDisplay,this._webVRpresenting=e.vrDisplay&&e.vrDisplay.isPresenting,this.updateButtonVisibility()},e.prototype.moveButtonToBottomRight=function(){if(this._inputElement&&!this._useCustomVRButton&&this._btnVR){var e=this._inputElement.getBoundingClientRect();this._btnVR.style.top=e.top+e.height-70+\"px\",this._btnVR.style.left=e.left+e.width-100+\"px\"}},e.prototype.displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||!this._btnVR||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},e.prototype.updateButtonVisibility=function(){this._btnVR&&!this._useCustomVRButton&&(this._btnVR.className=\"babylonVRicon\",this.isInVRMode?this._btnVR.className+=\" vrdisplaypresenting\":(this._webVRready&&(this._btnVR.className+=\" vrdisplayready\"),this._webVRsupported&&(this._btnVR.className+=\" vrdisplaysupported\"),this._webVRrequesting&&(this._btnVR.className+=\" vrdisplayrequesting\")))},e.prototype.enterVR=function(){var e=this;if(this.xr)this.xr.baseExperience.enterXRAsync(\"immersive-vr\",\"local-floor\",this.xr.renderTarget);else{if(this.onEnteringVRObservable)try{this.onEnteringVRObservable.notifyObservers(this)}catch(e){m.a.Warn(\"Error in your custom logic onEnteringVR: \"+e)}if(this._scene.activeCamera){if(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=a.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this.webVRCamera){var t=this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y,i=a.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-t,n=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=a.b.FromEulerAngles(0,n+i,0)}this._existingCamera=this._scene.activeCamera,this._existingCamera.angularSensibilityX&&(this._cachedAngularSensibility.angularSensibilityX=this._existingCamera.angularSensibilityX,this._existingCamera.angularSensibilityX=Number.MAX_VALUE),this._existingCamera.angularSensibilityY&&(this._cachedAngularSensibility.angularSensibilityY=this._existingCamera.angularSensibilityY,this._existingCamera.angularSensibilityY=Number.MAX_VALUE),this._existingCamera.angularSensibility&&(this._cachedAngularSensibility.angularSensibility=this._existingCamera.angularSensibility,this._existingCamera.angularSensibility=Number.MAX_VALUE)}this._webVRrequesting||(this._webVRready?this._webVRpresenting||(this._scene.getEngine().onVRRequestPresentComplete.addOnce((function(t){e.onAfterEnteringVRObservable.notifyObservers({success:t})})),this._webVRCamera.position=this._position,this._scene.activeCamera=this._webVRCamera):this._vrDeviceOrientationCamera&&(this._vrDeviceOrientationCamera.position=this._position,this._scene.activeCamera&&(this._vrDeviceOrientationCamera.minZ=this._scene.activeCamera.minZ),this._scene.activeCamera=this._vrDeviceOrientationCamera,this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen),this.updateButtonVisibility(),this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce((function(){e.onAfterEnteringVRObservable.notifyObservers({success:!0})}))),this._scene.activeCamera&&this._inputElement&&this._scene.activeCamera.attachControl(),this._interactionsEnabled&&this._scene.registerBeforeRender(this.beforeRender),this._displayLaserPointer&&[this._leftController,this._rightController].forEach((function(e){e&&e._activatePointer()})),this._hasEnteredVR=!0)}},e.prototype.exitVR=function(){if(this.xr)this.xr.baseExperience.exitXRAsync();else if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(e){m.a.Warn(\"Error in your custom logic onExitingVR: \"+e)}this._webVRpresenting&&this._scene.getEngine().disableVR(),this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone()),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._deviceOrientationCamera?(this._deviceOrientationCamera.position=this._position,this._scene.activeCamera=this._deviceOrientationCamera,this._cachedAngularSensibility.angularSensibilityX&&(this._deviceOrientationCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._deviceOrientationCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._deviceOrientationCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)):this._existingCamera&&(this._existingCamera.position=this._position,this._scene.activeCamera=this._existingCamera,this._inputElement&&this._scene.activeCamera.attachControl(),this._cachedAngularSensibility.angularSensibilityX&&(this._existingCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._existingCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._existingCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)),this.updateButtonVisibility(),this._interactionsEnabled&&(this._scene.unregisterBeforeRender(this.beforeRender),this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1)),this._scene.getEngine().resize(),[this._leftController,this._rightController].forEach((function(e){e&&e._deactivatePointer()})),this._hasEnteredVR=!1;var e=this._scene.getEngine();e._onVrDisplayPresentChange&&e._onVrDisplayPresentChange()}},Object.defineProperty(e.prototype,\"position\",{get:function(){return this._position},set:function(e){this._position=e,this._scene.activeCamera&&(this._scene.activeCamera.position=e)},enumerable:!1,configurable:!0}),e.prototype.enableInteractions=function(){var e=this;if(!this._interactionsEnabled){if(this._interactionsRequested=!0,this.xr)return void(this.xr.baseExperience.state===$i.IN_XR&&this.xr.pointerSelection.attach());this._leftController&&this._enableInteractionOnController(this._leftController),this._rightController&&this._enableInteractionOnController(this._rightController),this.raySelectionPredicate=function(t){return t.isVisible&&(t.isPickable||t.name===e._floorMeshName)},this.meshSelectionPredicate=function(){return!0},this._raySelectionPredicate=function(t){return!!(e._isTeleportationFloor(t)||-1===t.name.indexOf(\"gazeTracker\")&&-1===t.name.indexOf(\"teleportationTarget\")&&-1===t.name.indexOf(\"torusTeleportation\"))&&e.raySelectionPredicate(t)},this._interactionsEnabled=!0}},Object.defineProperty(e.prototype,\"_noControllerIsActive\",{get:function(){return!(this._leftController&&this._leftController._activePointer||this._rightController&&this._rightController._activePointer)},enumerable:!1,configurable:!0}),e.prototype._isTeleportationFloor=function(e){for(var t=0;t-1||this._floorMeshesCollection.push(e))},e.prototype.removeFloorMesh=function(e){if(this._floorMeshesCollection){var t=this._floorMeshesCollection.indexOf(e);-1!==t&&this._floorMeshesCollection.splice(t,1)}},e.prototype.enableTeleportation=function(e){var t=this;if(void 0===e&&(e={}),!this._teleportationInitialized){if(this._teleportationRequested=!0,this.enableInteractions(),this.webVROptions.useXR&&(e.floorMeshes||e.floorMeshName)){var i=e.floorMeshes||[];if(!i.length){var n=this._scene.getMeshByName(e.floorMeshName);n&&i.push(n)}if(this.xr)return i.forEach((function(e){t.xr.teleportation.addFloorMesh(e)})),void(this.xr.teleportation.attached||this.xr.teleportation.attach());if(!this.xrTestDone){var r=function(){t.xrTestDone&&(t._scene.unregisterBeforeRender(r),t.xr?t.xr.teleportation.attached||t.xr.teleportation.attach():t.enableTeleportation(e))};return void this._scene.registerBeforeRender(r)}}e.floorMeshName&&(this._floorMeshName=e.floorMeshName),e.floorMeshes&&(this._floorMeshesCollection=e.floorMeshes),e.teleportationMode&&(this._teleportationMode=e.teleportationMode),e.teleportationTime&&e.teleportationTime>0&&(this._teleportationTime=e.teleportationTime),e.teleportationSpeed&&e.teleportationSpeed>0&&(this._teleportationSpeed=e.teleportationSpeed),void 0!==e.easingFunction&&(this._teleportationEasing=e.easingFunction),null!=this._leftController&&this._enableTeleportationOnController(this._leftController),null!=this._rightController&&this._enableTeleportationOnController(this._rightController);var o=new ji.a;o.vignetteColor=new s.b(0,0,0,0),o.vignetteEnabled=!0,this._postProcessMove=new Yi(\"postProcessMove\",1,this._webVRCamera,void 0,void 0,void 0,void 0,o),this._webVRCamera.detachPostProcess(this._postProcessMove),this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&(this._createTeleportationCircles(),this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))}},e.prototype._enableInteractionOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled=!0,this.isInVRMode&&this._displayLaserPointer&&e._activatePointer(),this.webVROptions.laserToggle&&e.webVRController.onMainButtonStateChangedObservable.add((function(i){t._displayLaserPointer&&1===i.value&&(e._activePointer?e._deactivatePointer():e._activatePointer(),t.displayGaze&&(e._gazeTracker.isVisible=e._activePointer))})),e.webVRController.onTriggerStateChangedObservable.add((function(i){var n=e;t._noControllerIsActive&&(n=t._cameraGazer),n._pointerDownOnMeshAsked?i.valuet._padSensibilityUp&&n._selectionPointerDown()})))},e.prototype._checkTeleportWithRay=function(e,t){this._teleportationRequestInitiated&&!t._teleportationRequestInitiated||(t._teleportationRequestInitiated?Math.sqrt(e.y*e.y+e.x*e.x)-this._padSensibilityDown&&(t._rotationLeftAsked=!1):e.x<-this._padSensibilityUp&&t._dpadPressed&&(t._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),t._rotationRightAsked?e.xthis._padSensibilityUp&&t._dpadPressed&&(t._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},e.prototype._checkTeleportBackwards=function(e,t){if(!t._teleportationRequestInitiated)if(e.y>this._padSensibilityUp&&t._dpadPressed){if(!t._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var i=a.b.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),n=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(i=this.currentVRCamera.deviceRotationQuaternion,n=this.currentVRCamera.devicePosition),i.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,a.b.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),a.e.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var r=new Xt.a(n,this._workingVector),o=this._scene.pickWithRay(r,this._raySelectionPredicate);o&&o.pickedPoint&&o.pickedMesh&&this._isTeleportationFloor(o.pickedMesh)&&o.distance<5&&this.teleportCamera(o.pickedPoint),t._teleportationBackRequestInitiated=!0}}else t._teleportationBackRequestInitiated=!1},e.prototype._enableTeleportationOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled||this._enableInteractionOnController(e),e._interactionsEnabled=!0,e._teleportationEnabled=!0,e.webVRController.controllerType===Gt.VIVE&&(e._dpadPressed=!1,e.webVRController.onPadStateChangedObservable.add((function(t){e._dpadPressed=t.pressed,e._dpadPressed||(e._rotationLeftAsked=!1,e._rotationRightAsked=!1,e._teleportationBackRequestInitiated=!1)}))),e.webVRController.onPadValuesChangedObservable.add((function(i){t.teleportationEnabled&&(t._checkTeleportBackwards(i,e),t._checkTeleportWithRay(i,e)),t._checkRotate(i,e)})))},e.prototype._createTeleportationCircles=function(){this._teleportationTarget=be.a.CreateGround(\"teleportationTarget\",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var e=new Hi.a(\"DynamicTexture\",512,this._scene,!0);e.hasAlpha=!0;var t=e.getContext();t.beginPath(),t.arc(256,256,200,0,2*Math.PI,!1),t.fillStyle=this._teleportationFillColor,t.fill(),t.lineWidth=10,t.strokeStyle=this._teleportationBorderColor,t.stroke(),t.closePath(),e.update();var i=new Wi.a(\"TextPlaneMaterial\",this._scene);i.diffuseTexture=e,this._teleportationTarget.material=i;var n=be.a.CreateTorus(\"torusTeleportation\",.75,.1,25,this._scene,!1);n.isPickable=!1,n.parent=this._teleportationTarget;var r=new z(\"animationInnerCircle\",\"position.y\",30,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:0}),o.push({frame:30,value:.4}),o.push({frame:60,value:0}),r.setKeys(o);var a=new me;a.setEasingMode(oe.EASINGMODE_EASEINOUT),r.setEasingFunction(a),n.animations=[],n.animations.push(r),this._scene.beginAnimation(n,0,60,!0),this._hideTeleportationTarget()},e.prototype._displayTeleportationTarget=function(){this._teleportActive=!0,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!0,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!0))},e.prototype._hideTeleportationTarget=function(){this._teleportActive=!1,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!1,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!1))},e.prototype._rotateCamera=function(e){var t=this;if(this.currentVRCamera instanceof wt){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var i=a.b.FromRotationMatrix(a.a.RotationY(Math.PI/4*this._rotationAngle)),n=new z(\"animationRotation\",\"rotationQuaternion\",90,z.ANIMATIONTYPE_QUATERNION,z.ANIMATIONLOOPMODE_CONSTANT),r=[];r.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),r.push({frame:6,value:i}),n.setKeys(r),n.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(n),this._postProcessMove.animations=[];var o=new z(\"animationPP\",\"vignetteWeight\",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:3,value:4}),s.push({frame:6,value:0}),o.setKeys(s),o.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(o);var c=new z(\"animationPP2\",\"vignetteStretch\",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:3,value:10}),l.push({frame:6,value:0}),c.setKeys(l),c.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(c),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._postProcessMove.samples=4,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,6,!1,1,(function(){t._webVRCamera.detachPostProcess(t._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},e.prototype._moveTeleportationSelectorTo=function(e,t,i){if(e.pickedPoint){t._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(e.pickedPoint),this._teleportationTarget.position.copyFrom(e.pickedPoint));var n=this._convertNormalToDirectionOfRay(e.getNormal(!0,!1),i);if(n){var r=a.e.Cross(J.a.Y,n),o=a.e.Cross(n,r);a.e.RotationFromAxisToRef(o,n,r,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(t){var i=this;if(this.currentVRCamera instanceof wt){this.webVRCamera.leftCamera?(this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),this._workingVector.subtractInPlace(this.webVRCamera.position),t.subtractToRef(this._workingVector,this._workingVector)):this._workingVector.copyFrom(t),this.isInVRMode?this._workingVector.y+=this.webVRCamera.deviceDistanceToRoomGround()*this._webVRCamera.deviceScaleFactor:this._workingVector.y+=this._defaultHeight,this.onBeforeCameraTeleport.notifyObservers(this._workingVector);var n,r;if(this._teleportationMode==e.TELEPORTATIONMODE_CONSTANTSPEED){r=90;var o=a.e.Distance(this.currentVRCamera.position,this._workingVector);n=this._teleportationSpeed/o}else r=Math.round(90*this._teleportationTime/1e3),n=1;this.currentVRCamera.animations=[];var s=new z(\"animationCameraTeleportation\",\"position\",90,z.ANIMATIONTYPE_VECTOR3,z.ANIMATIONLOOPMODE_CONSTANT),c=[{frame:0,value:this.currentVRCamera.position},{frame:r,value:this._workingVector}];s.setKeys(c),s.setEasingFunction(this._teleportationEasing),this.currentVRCamera.animations.push(s),this._postProcessMove.animations=[];var l=Math.round(r/2),u=new z(\"animationPP\",\"vignetteWeight\",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),h=[];h.push({frame:0,value:0}),h.push({frame:l,value:8}),h.push({frame:r,value:0}),u.setKeys(h),this._postProcessMove.animations.push(u);var d=new z(\"animationPP2\",\"vignetteStretch\",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),f=[];f.push({frame:0,value:0}),f.push({frame:l,value:10}),f.push({frame:r,value:0}),d.setKeys(f),this._postProcessMove.animations.push(d),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,r,!1,n,(function(){i._webVRCamera.detachPostProcess(i._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,r,!1,n,(function(){i.onAfterCameraTeleport.notifyObservers(i._workingVector)})),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(a.e.Dot(e,t.direction))s){var c=s;s=a,a=c}return a>0&&a0&&s=0))},e.prototype._canDoCollision=function(e,t,i,n){var r=a.e.Distance(this._basePointWorld,e),o=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(r>this._velocityWorldLength+o+t)&&!!function(e,t,i,n){return!(e.x>i.x+n)&&(!(i.x-n>t.x)&&(!(e.y>i.y+n)&&(!(i.y-n>t.y)&&(!(e.z>i.z+n)&&!(i.z-n>t.z)))))}(i,n,this._basePointWorld,this._velocityWorldLength+o)},e.prototype._testTriangle=function(e,t,i,n,r,o,s){var c,l=!1;t||(t=[]),t[e]||(t[e]=new fn.a(0,0,0,0),t[e].copyFromPoints(i,n,r));var u=t[e];if(o||u.isFrontFacingTo(this._normalizedVelocity,0)){var h=u.signedDistanceTo(this._basePoint),d=a.e.Dot(u.normal,this._velocity);if(0==d){if(Math.abs(h)>=1)return;l=!0,c=0}else{var f=(1-h)/d;if((c=(-1-h)/d)>f){var p=f;f=c,c=p}if(c>1||f<0)return;c<0&&(c=0),c>1&&(c=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(l||(this._basePoint.subtractToRef(u.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(c,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,i,n,r,u.normal)&&(_=!0,m=c,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this._velocity.lengthSquared(),v=g;this._basePoint.subtractToRef(i,this._tempVector);var b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,T=pn(v,b,y,m);T.found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(n,this._tempVector),b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(T=pn(v,b,y,m)).found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(r,this._tempVector),b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(T=pn(v,b,y,m)).found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(r)),n.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex);var E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex);if(v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found){var P=(S*T.root-A)/E;P>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),i.addToRef(this._edge,this._collisionPoint))}r.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex),E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex),v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found&&(P=(S*T.root-A)/E)>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint)),i.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex),v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found&&(P=(S*T.root-A)/E)>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),r.addToRef(this._edge,this._collisionPoint))}if(_){var C=m*this._velocity.length();(!this.collisionFound||C=n)r.copyFrom(e);else{var s=o?o.collisionMask:i.collisionMask;i._initialize(e,t,a);for(var c=o&&o.surroundingMeshes||this._scene.meshes,l=0;lthis.capacity&&this._depth-1&&this.entries.splice(i,1)}},e.prototype.addEntries=function(e){for(var t=0;t=n.buttons.length?r[i]=n.axes[i-n.buttons.length].valueOf():r[i]=n.buttons[i].value}},e.prototype._getGamepadDeviceType=function(e){return-1!==e.indexOf(\"054c\")?Pn.DualShock:-1!==e.indexOf(\"Xbox One\")||-1!==e.search(\"Xbox 360\")||-1!==e.search(\"xinput\")?Pn.Xbox:-1!==e.indexOf(\"057e\")?Pn.Switch:Pn.Generic},e._MAX_KEYCODES=255,e._MAX_POINTER_INPUTS=7,e}(),Nn=function(){function e(e,t,i){void 0===i&&(i=0),this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new o.c,this._deviceInputSystem=e}return e.prototype.getInput=function(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)},e}(),Ln=function(){function e(e){var t=this;this.onDeviceConnectedObservable=new o.c((function(e){t.getDevices().forEach((function(i){t.onDeviceConnectedObservable.notifyObserver(e,i)}))})),this.onDeviceDisconnectedObservable=new o.c;var i=Object.keys(Pn).length/2;this._devices=new Array(i),this._firstDevice=new Array(i),this._deviceInputSystem=Dn.Create(e),this._deviceInputSystem.onDeviceConnected=function(e,i){t._addDevice(e,i),t.onDeviceConnectedObservable.notifyObservers(t.getDeviceSource(e,i))},this._deviceInputSystem.onDeviceDisconnected=function(e,i){var n=t.getDeviceSource(e,i);t._removeDevice(e,i),t.onDeviceDisconnectedObservable.notifyObservers(n)},this._deviceInputSystem.onInputChanged||(this._deviceInputSystem.onInputChanged=function(e,i,n,r,o){var a;null===(a=t.getDeviceSource(e,i))||void 0===a||a.onInputChangedObservable.notifyObservers({inputIndex:n,previousState:r,currentState:o})})}return e.prototype.getDeviceSource=function(e,t){if(void 0===t){if(void 0===this._firstDevice[e])return null;t=this._firstDevice[e]}return this._devices[e]&&void 0!==this._devices[e][t]?this._devices[e][t]:null},e.prototype.getDeviceSources=function(e){return this._devices[e].filter((function(e){return!!e}))},e.prototype.getDevices=function(){var e=new Array;return this._devices.forEach((function(t){e.push.apply(e,t)})),e},e.prototype.dispose=function(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._deviceInputSystem.dispose()},e.prototype._addDevice=function(e,t){this._devices[e]||(this._devices[e]=new Array),this._devices[e][t]||(this._devices[e][t]=new Nn(this._deviceInputSystem,e,t),this._updateFirstDevices(e))},e.prototype._removeDevice=function(e,t){delete this._devices[e][t],this._updateFirstDevices(e)},e.prototype._updateFirstDevices=function(e){switch(e){case Pn.Keyboard:case Pn.Mouse:this._firstDevice[e]=0;break;case Pn.Touch:case Pn.DualShock:case Pn.Xbox:case Pn.Switch:case Pn.Generic:var t=this._devices[e];delete this._firstDevice[e];for(var i=0;ie.occlusionRetryCount))return!1;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==Ge.a.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var n=this.getScene();if(n.getBoundingBoxRenderer){var r=n.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery),r.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return e.isOccluded};var Un=!0;Se.a.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},Se.a.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},Se.a.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},Se.a.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},Se.a.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},Se.a.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},Se.a.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)};i(126);qe.a.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){var n=this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0);this._unpackFlipY(!i);try{if(void 0===this._videoTextureSupported&&(this._gl.getError(),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported)this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t);else{if(!e._workingCanvas){e._workingCanvas=Zi.a.CreateCanvas(e.width,e.height);var r=e._workingCanvas.getContext(\"2d\");if(!r)throw new Error(\"Unable to get 2d context\");e._workingContext=r,e._workingCanvas.width=e.width,e._workingCanvas.height=e.height}e._workingContext.clearRect(0,0,e.width,e.height),e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e.width,e.height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e._workingCanvas)}e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),n||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}catch(t){e._isDisabled=!0}}},qe.a.prototype.restoreSingleAttachment=function(){var e=this._gl;this.bindAttachments([e.BACK])},qe.a.prototype.buildTextureLayout=function(e){for(var t=this._gl,i=[],n=0;n1?\"COLOR_ATTACHMENT\"+a:\"COLOR_ATTACHMENT\"+a+\"_WEBGL\"],n.readBuffer(r[a]),n.drawBuffers(r),n.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,n.COLOR_BUFFER_BIT,n.NEAREST)}for(a=0;a1?\"COLOR_ATTACHMENT\"+a:\"COLOR_ATTACHMENT\"+a+\"_WEBGL\"];n.drawBuffers(r)}for(a=0;a1?\"COLOR_ATTACHMENT\"+y:\"COLOR_ATTACHMENT\"+y+\"_WEBGL\"];_.push(A),v.push(P),h.activeTexture(h[\"TEXTURE\"+y]),h.bindTexture(h.TEXTURE_2D,A._webGLTexture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,S.mag),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,S.min),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(E),f,p,0,h.RGBA,this._getWebGLTextureType(E),null),h.framebufferTexture2D(h.DRAW_FRAMEBUFFER,P,h.TEXTURE_2D,A._webGLTexture,0),i&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(h.TEXTURE_2D,null),A._framebuffer=d,A._depthStencilBuffer=b,A.baseWidth=f,A.baseHeight=p,A.width=f,A.height=p,A.isReady=!0,A.samples=1,A.generateMipMaps=i,A.samplingMode=T,A.type=E,A._generateDepthBuffer=n,A._generateStencilBuffer=r,A._attachments=v,A._textureArray=_,this._internalTexturesCache.push(A)}if(o&&this._caps.depthTextureExtension){var C=new Qe.a(this,Qe.b.MultiRenderTarget);h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,C._webGLTexture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this.webGLVersion<2?h.DEPTH_COMPONENT:h.DEPTH_COMPONENT16,f,p,0,h.DEPTH_COMPONENT,h.UNSIGNED_SHORT,null),h.framebufferTexture2D(h.FRAMEBUFFER,h.DEPTH_ATTACHMENT,h.TEXTURE_2D,C._webGLTexture,0),C._framebuffer=d,C.baseWidth=f,C.baseHeight=p,C.width=f,C.height=p,C.isReady=!0,C.samples=1,C.generateMipMaps=i,C.samplingMode=h.NEAREST,C._generateDepthBuffer=n,C._generateStencilBuffer=r,_.push(C),this._internalTexturesCache.push(C)}return h.drawBuffers(v),this._bindUnboundFramebuffer(null),this.resetTextureCache(),_},qe.a.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e[0].samples===t)return t;var i=e[0]._attachments.length;if(0===i)return 1;var n=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e[0]._depthStencilBuffer&&(n.deleteRenderbuffer(e[0]._depthStencilBuffer),e[0]._depthStencilBuffer=null),e[0]._MSAAFramebuffer&&(n.deleteFramebuffer(e[0]._MSAAFramebuffer),e[0]._MSAAFramebuffer=null);for(var r=0;r1&&n.renderbufferStorageMultisample){var o=n.createFramebuffer();if(!o)throw new Error(\"Unable to create multi sampled framebuffer\");this._bindUnboundFramebuffer(o);var a=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),s=[];for(r=0;r1?\"COLOR_ATTACHMENT\"+r:\"COLOR_ATTACHMENT\"+r+\"_WEBGL\"],u=n.createRenderbuffer();if(!u)throw new Error(\"Unable to create multi sampled framebuffer\");n.bindRenderbuffer(n.RENDERBUFFER,u),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(c.type),c.width,c.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,l,n.RENDERBUFFER,u),c._MSAAFramebuffer=o,c._MSAARenderBuffer=u,c.samples=t,c._depthStencilBuffer=a,n.bindRenderbuffer(n.RENDERBUFFER,null),s.push(l)}n.drawBuffers(s)}else this._bindUnboundFramebuffer(e[0]._framebuffer);return this._bindUnboundFramebuffer(null),t};var Vn=i(56);qe.a.prototype._createDepthStencilCubeTexture=function(e,t){var i=new Qe.a(this,Qe.b.Unknown);if(i.isCube=!0,1===this.webGLVersion)return m.a.Error(\"Depth cube texture is not supported by WebGL 1.\"),i;var n=Object(h.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),r=this._gl;this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,i,!0),this._setupDepthStencilTexture(i,e,n.generateStencil,n.bilinearFiltering,n.comparisonFunction);for(var o=0;o<6;o++)n.generateStencil?r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,r.DEPTH24_STENCIL8,e,e,0,r.DEPTH_STENCIL,r.UNSIGNED_INT_24_8,null):r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,r.DEPTH_COMPONENT24,e,e,0,r.DEPTH_COMPONENT,r.UNSIGNED_INT,null);return this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),i},qe.a.prototype._partialLoadFile=function(e,t,i,n,r){void 0===r&&(r=null);this._loadFile(e,(function(e){i[t]=e,i._internalCount++,6===i._internalCount&&n(i)}),void 0,void 0,!0,(function(e,t){r&&e&&r(e.status+\" \"+e.statusText,t)}))},qe.a.prototype._cascadeLoadFiles=function(e,t,i,n){void 0===n&&(n=null);var r=[];r._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(i[o],o,r,t,n)},qe.a.prototype._cascadeLoadImgs=function(e,t,i,n,r){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)this._partialLoadImg(i[a],a,o,e,t,n,r)},qe.a.prototype._partialLoadImg=function(e,t,i,n,r,o,a){var s;void 0===o&&(o=null);s=Vn.a.LoadImage(e,(function(){s&&(i[t]=s,i._internalCount++,n&&n._removePendingData(s)),6===i._internalCount&&r(i)}),(function(e,t){n&&n._removePendingData(s),o&&o(e,t)}),n?n.offlineProvider:null,a),n&&s&&n._addPendingData(s)},qe.a.prototype._setCubeMapTextureParams=function(e,t){var i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),e.samplingMode=t?g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:g.a.TEXTURE_LINEAR_LINEAR,this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)},qe.a.prototype.createCubeTexture=function(e,t,i,n,r,o,a,s,c,l,u,h,d){var f=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=!1),void 0===l&&(l=0),void 0===u&&(u=0),void 0===h&&(h=null);var p=this._gl,_=h||new Qe.a(this,Qe.b.Cube);_.isCube=!0,_.url=e,_.generateMipMaps=!n,_._lodGenerationScale=l,_._lodGenerationOffset=u,this._doNotHandleContextLost||(_._extension=s,_._files=i);var g=e;this._transformTextureUrl&&!h&&(e=this._transformTextureUrl(e));for(var v=e.lastIndexOf(\".\"),b=s||(v>-1?e.substring(v).toLowerCase():\"\"),y=null,T=0,E=qe.a._TextureLoaders;T-1?e.substring(i,e.length):\"\";return(t>-1?e.substring(0,t):e)+this._textureFormatInUse+n}Object.defineProperty(Se.a.prototype,\"texturesSupported\",{get:function(){var e=new Array;return this._caps.astc&&e.push(\"-astc.ktx\"),this._caps.s3tc&&e.push(\"-dxt.ktx\"),this._caps.pvrtc&&e.push(\"-pvrtc.ktx\"),this._caps.etc2&&e.push(\"-etc2.ktx\"),this._caps.etc1&&e.push(\"-etc1.ktx\"),e},enumerable:!0,configurable:!0}),Object.defineProperty(Se.a.prototype,\"textureFormatInUse\",{get:function(){return this._textureFormatInUse||null},enumerable:!0,configurable:!0}),Se.a.prototype.setCompressedTextureExclusions=function(e){this._excludedCompressedTextures=e},Se.a.prototype.setTextureFormatToUse=function(e){for(var t=this.texturesSupported,i=0,n=t.length;i\\nvoid main(void)\\n{\\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\\n}\";ai.a.ShadersStore.rgbdEncodePixelShader=er;var tr=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\n#include\\nvoid main(void)\\n{\\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\\n}\";ai.a.ShadersStore.rgbdDecodePixelShader=tr;var ir=function(){function e(){}return e.GetEnvInfo=function(t){for(var i=new DataView(t.buffer,t.byteOffset,t.byteLength),n=0,r=0;r=0&&p.push(m.substring(g+1))}\"void\"!==a&&p.push(\"return\"),this._functionDescr.push({name:s,type:a,parameters:p,body:d,callIndex:0}),t=h+1;var v=i>0?this._sourceCode.substring(0,i):\"\",b=h+1=0&&this._replaceFunctionCallsByCode(););return this.debug&&console.log(\"numMaxIterations is \"+e+\" after inlining process\"),e>=0},e.prototype._extractBetweenMarkers=function(e,t,i,n){for(var r=n,o=0,a=\"\";r0?this._sourceCode.substring(0,l):\"\",y=h+1=0&&e.charAt(t)!==i;)t--;return t},e.prototype._escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")},e.prototype._replaceNames=function(e,t,i){for(var n=0;n=0){var s=t[r[o]];if(s){var c=s.getBuffer();c&&this._native.recordVertexBuffer(e,c.nativeVertexBuffer,a,s.byteOffset,s.byteStride,s.getSize(),this._getNativeAttribType(s.type),s.normalized)}}}},t.prototype.bindBuffers=function(e,t,i){this._boundBuffersVertexArray&&this._native.deleteVertexArray(this._boundBuffersVertexArray),this._boundBuffersVertexArray=this._native.createVertexArray(),this._recordVertexArrayObject(this._boundBuffersVertexArray,e,t,i),this._native.bindVertexArray(this._boundBuffersVertexArray)},t.prototype.recordVertexArrayObject=function(e,t,i){var n=this._native.createVertexArray();return this._recordVertexArrayObject(n,e,t,i),n},t.prototype.bindVertexArrayObject=function(e){this._native.bindVertexArray(e)},t.prototype.releaseVertexArrayObject=function(e){this._native.deleteVertexArray(e)},t.prototype.getAttributes=function(e,t){var i=e;return this._native.getAttributes(i.nativeProgram,t)},t.prototype.drawElementsType=function(e,t,i,n){this._drawCalls.addCount(1,!1),this._native.drawIndexed(e,t,i)},t.prototype.drawArraysType=function(e,t,i,n){this._drawCalls.addCount(1,!1),this._native.draw(e,t,i)},t.prototype.createPipelineContext=function(){return new or},t.prototype._preparePipelineContext=function(e,t,i,n,r,o,a){var s=e;s.nativeProgram=n?this.createRawShaderProgram(e,t,i,void 0,a):this.createShaderProgram(e,t,i,o,void 0,a)},t.prototype._isRenderingStateCompiled=function(e){return!0},t.prototype._executeWhenRenderingStateIsCompiled=function(e,t){t()},t.prototype.createRawShaderProgram=function(e,t,i,n,r){throw void 0===r&&(r=null),new Error(\"Not Supported\")},t.prototype.createShaderProgram=function(e,t,i,n,r,o){void 0===o&&(o=null),this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=new rr(t);a.processCode(),t=a.code;var s=new rr(i);s.processCode(),i=s.code,t=qe.a._ConcatenateShader(t,n),i=qe.a._ConcatenateShader(i,n);var c=this._native.createProgram(t,i);return this.onAfterShaderCompilationObservable.notifyObservers(this),c},t.prototype._setProgram=function(e){this._currentProgram!==e&&(this._native.setProgram(e),this._currentProgram=e)},t.prototype._releaseEffect=function(e){},t.prototype._deletePipelineContext=function(e){},t.prototype.getUniforms=function(e,t){var i=e;return this._native.getUniforms(i.nativeProgram,t)},t.prototype.bindUniformBlock=function(e,t,i){throw new Error(\"Not Implemented\")},t.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.nativeProgram);for(var i=e.getSamplers(),n=0;n-1?e.substring(y).toLowerCase():\"\"),E=null,S=0,A=Se.a._TextureLoaders;S-1?e.substring(p).toLowerCase():\"\"))){if(i&&6===i.length)throw new Error(\"Multi-file loading not allowed on env files.\");this._loadFile(e,(function(e){return function(e){var t=ir.GetEnvInfo(e);if(f.width=t.width,f.height=t.width,ir.UploadEnvSpherical(f,t),1!==t.version)throw new Error('Unsupported babylon environment map version \"'+t.version+'\"');var i=t.specular;if(!i)throw new Error(\"Nothing else parsed so far\");f._lodGenerationScale=i.lodGenerationScale;var n=ir.CreateImageDataArrayBufferViews(e,t);f.format=g.a.TEXTUREFORMAT_RGBA,f.type=g.a.TEXTURETYPE_UNSIGNED_INT,f.generateMipMaps=!0,f.getEngine().updateTextureSamplingMode(Ke.a.TRILINEAR_SAMPLINGMODE,f),f._isRGBD=!0,f.invertY=!0,d._native.loadCubeTextureWithMips(f._webGLTexture,n,(function(){f.isReady=!0,r&&r()}),(function(){throw new Error(\"Could not load a native cube texture.\")}))}(new Uint8Array(e))}),void 0,void 0,!0,(function(e,t){o&&e&&o(e.status+\" \"+e.statusText,t)}))}else{if(!i||6!==i.length)throw new Error(\"Cannot load cubemap because 6 files were not defined\");var _=[i[0],i[3],i[1],i[4],i[2],i[5]];Promise.all(_.map((function(e){return Ce.b.LoadFileAsync(e).then((function(e){return new Uint8Array(e)}))}))).then((function(e){return new Promise((function(t,i){d._native.loadCubeTexture(f._webGLTexture,e,!n,t,i)}))})).then((function(){f.isReady=!0,r&&r()}),(function(e){o&&o(\"Failed to load cubemap: \"+e.message,e)}))}return this._internalTexturesCache.push(f),f},t.prototype.createRenderTargetTexture=function(e,t){var i=new ci.a;void 0!==t&&\"object\"==typeof t?(i.generateMipMaps=t.generateMipMaps,i.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&t.generateStencilBuffer,i.type=void 0===t.type?g.a.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,i.format=void 0===t.format?g.a.TEXTUREFORMAT_RGBA:t.format):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=g.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,i.format=g.a.TEXTUREFORMAT_RGBA),(i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==g.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=g.a.TEXTURE_NEAREST_SAMPLINGMODE);var n=new sr(this,Qe.b.RenderTarget),r=e.width||e,o=e.height||e;i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=g.a.TEXTURETYPE_UNSIGNED_INT,m.a.Warn(\"Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type\"));var a=this._native.createFramebuffer(n._webGLTexture,r,o,this._getNativeTextureFormat(i.format,i.type),i.samplingMode,!!i.generateStencilBuffer,i.generateDepthBuffer,!!i.generateMipMaps);return n._framebuffer=a,n.baseWidth=r,n.baseHeight=o,n.width=r,n.height=o,n.isReady=!0,n.samples=1,n.generateMipMaps=!!i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n.format=i.format,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(n),n},t.prototype.updateTextureSamplingMode=function(e,t){if(t._webGLTexture){var i=this._getNativeSamplingMode(e);this._native.setTextureSampling(t._webGLTexture,i)}t.samplingMode=e},t.prototype.bindFramebuffer=function(e,t,i,n,r){if(t)throw new Error(\"Cuboid frame buffers are not yet supported in NativeEngine.\");if(i||n)throw new Error(\"Required width/height for frame buffers not yet supported in NativeEngine.\");e._depthStencilTexture?this._bindUnboundFramebuffer(e._depthStencilTexture._framebuffer):this._bindUnboundFramebuffer(e._framebuffer)},t.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),t&&m.a.Warn(\"Disabling mipmap generation not yet supported in NativeEngine. Ignoring.\"),i&&i(),this._bindUnboundFramebuffer(null)},t.prototype.createDynamicVertexBuffer=function(e){return this.createVertexBuffer(e,!0)},t.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0);var n=e,r=this._normalizeIndexData(t);n.is32Bits=4===r.BYTES_PER_ELEMENT,this._native.updateDynamicIndexBuffer(n.nativeIndexBuffer,r,i)},t.prototype.updateDynamicVertexBuffer=function(e,t,i,n){var r=e,o=ArrayBuffer.isView(t)?t:new Float32Array(t);this._native.updateDynamicVertexBuffer(r.nativeVertexBuffer,o,null!=i?i:0,null!=n?n:o.byteLength)},t.prototype._setTexture=function(e,t,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1);var r,o=this._boundUniforms[e];if(!o)return!1;if(!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._native.setTexture(o,null)),!1;if(t.video)this._activeChannel=e,t.update();else if(t.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;return r=n?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,this._activeChannel=e,!(!r||!r._webGLTexture)&&(this._native.setTextureWrapMode(r._webGLTexture,this._getAddressMode(t.wrapU),this._getAddressMode(t.wrapV),this._getAddressMode(t.wrapR)),this._updateAnisotropicLevel(t),this._native.setTexture(o,r._webGLTexture),!0)},t.prototype._updateAnisotropicLevel=function(e){var t=e.getInternalTexture(),i=e.anisotropicFilteringLevel;t&&t._webGLTexture&&t._cachedAnisotropicFilteringLevel!==i&&(this._native.setTextureAnisotropicLevel(t._webGLTexture,i),t._cachedAnisotropicFilteringLevel=i)},t.prototype._getAddressMode=function(e){switch(e){case g.a.TEXTURE_WRAP_ADDRESSMODE:return this._native.ADDRESS_MODE_WRAP;case g.a.TEXTURE_CLAMP_ADDRESSMODE:return this._native.ADDRESS_MODE_CLAMP;case g.a.TEXTURE_MIRROR_ADDRESSMODE:return this._native.ADDRESS_MODE_MIRROR;default:throw new Error(\"Unexpected wrap mode: \"+e+\".\")}},t.prototype._bindTexture=function(e,t){var i=this._boundUniforms[e];i&&this._native.setTexture(i,t._webGLTexture)},t.prototype._deleteBuffer=function(e){e.nativeIndexBuffer&&(this._native.deleteIndexBuffer(e.nativeIndexBuffer),delete e.nativeIndexBuffer),e.nativeVertexBuffer&&(this._native.deleteVertexBuffer(e.nativeVertexBuffer),delete e.nativeVertexBuffer)},t.prototype.releaseEffects=function(){},t.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){throw void 0===o&&(o=0),void 0===a&&(a=0),new Error(\"_uploadCompressedDataToTextureDirectly not implemented.\")},t.prototype._uploadDataToTextureDirectly=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error(\"_uploadDataToTextureDirectly not implemented.\")},t.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error(\"_uploadArrayBufferViewToTexture not implemented.\")},t.prototype._uploadImageToTexture=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error(\"_uploadArrayBufferViewToTexture not implemented.\")},t.prototype._getNativeSamplingMode=function(e){switch(e){case g.a.TEXTURE_NEAREST_NEAREST:return this._native.TEXTURE_NEAREST_NEAREST;case g.a.TEXTURE_LINEAR_LINEAR:return this._native.TEXTURE_LINEAR_LINEAR;case g.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:return this._native.TEXTURE_LINEAR_LINEAR_MIPLINEAR;case g.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:return this._native.TEXTURE_NEAREST_NEAREST_MIPNEAREST;case g.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:return this._native.TEXTURE_NEAREST_LINEAR_MIPNEAREST;case g.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:return this._native.TEXTURE_NEAREST_LINEAR_MIPLINEAR;case g.a.TEXTURE_NEAREST_LINEAR:return this._native.TEXTURE_NEAREST_LINEAR;case g.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:return this._native.TEXTURE_NEAREST_NEAREST_MIPLINEAR;case g.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:return this._native.TEXTURE_LINEAR_NEAREST_MIPNEAREST;case g.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:return this._native.TEXTURE_LINEAR_NEAREST_MIPLINEAR;case g.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:return this._native.TEXTURE_LINEAR_LINEAR_MIPNEAREST;case g.a.TEXTURE_LINEAR_NEAREST:return this._native.TEXTURE_LINEAR_NEAREST;default:throw new Error(\"Unsupported sampling mode: \"+e+\".\")}},t.prototype._getNativeTextureFormat=function(e,t){if(e==g.a.TEXTUREFORMAT_RGBA&&t==g.a.TEXTURETYPE_UNSIGNED_INT)return this._native.TEXTURE_FORMAT_RGBA8;if(e==g.a.TEXTUREFORMAT_RGBA&&t==g.a.TEXTURETYPE_FLOAT)return this._native.TEXTURE_FORMAT_RGBA32F;throw new Error(\"Unsupported texture format or type: format \"+e+\", type \"+t+\".\")},t.prototype._getNativeAlphaMode=function(e){switch(e){case g.a.ALPHA_DISABLE:return this._native.ALPHA_DISABLE;case g.a.ALPHA_ADD:return this._native.ALPHA_ADD;case g.a.ALPHA_COMBINE:return this._native.ALPHA_COMBINE;case g.a.ALPHA_SUBTRACT:return this._native.ALPHA_SUBTRACT;case g.a.ALPHA_MULTIPLY:return this._native.ALPHA_MULTIPLY;case g.a.ALPHA_MAXIMIZED:return this._native.ALPHA_MAXIMIZED;case g.a.ALPHA_ONEONE:return this._native.ALPHA_ONEONE;case g.a.ALPHA_PREMULTIPLIED:return this._native.ALPHA_PREMULTIPLIED;case g.a.ALPHA_PREMULTIPLIED_PORTERDUFF:return this._native.ALPHA_PREMULTIPLIED_PORTERDUFF;case g.a.ALPHA_INTERPOLATE:return this._native.ALPHA_INTERPOLATE;case g.a.ALPHA_SCREENMODE:return this._native.ALPHA_SCREENMODE;default:throw new Error(\"Unsupported alpha mode: \"+e+\".\")}},t.prototype._getNativeAttribType=function(e){switch(e){case Qi.b.UNSIGNED_BYTE:return this._native.ATTRIB_TYPE_UINT8;case Qi.b.SHORT:return this._native.ATTRIB_TYPE_INT16;case Qi.b.FLOAT:return this._native.ATTRIB_TYPE_FLOAT;default:throw new Error(\"Unsupported attribute type: \"+e+\".\")}},t}(Se.a),lr=i(74),ur=function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}(),hr=function(){function e(e,t){this.type=e,this.event=t}return e.GetTypeFromCharacter=function(e){switch(e){case 67:return ur.COPY;case 86:return ur.PASTE;case 88:return ur.CUT;default:return-1}},e}(),dr=i(83),fr=i(69);!function(e){e[e.Clean=0]=\"Clean\",e[e.Stop=1]=\"Stop\",e[e.Sync=2]=\"Sync\",e[e.NoSync=3]=\"NoSync\"}(nr||(nr={}));var pr=function(){function e(){}return Object.defineProperty(e,\"ForceFullSceneLoadingForIncremental\",{get:function(){return fr.a.ForceFullSceneLoadingForIncremental},set:function(e){fr.a.ForceFullSceneLoadingForIncremental=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"ShowLoadingScreen\",{get:function(){return fr.a.ShowLoadingScreen},set:function(e){fr.a.ShowLoadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"loggingLevel\",{get:function(){return fr.a.loggingLevel},set:function(e){fr.a.loggingLevel=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"CleanBoneMatrixWeights\",{get:function(){return fr.a.CleanBoneMatrixWeights},set:function(e){fr.a.CleanBoneMatrixWeights=e},enumerable:!1,configurable:!0}),e.GetDefaultPlugin=function(){return e._registeredPlugins[\".babylon\"]},e._GetPluginForExtension=function(t){var i=e._registeredPlugins[t];return i||(m.a.Warn(\"Unable to find a plugin to load \"+t+\" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type\"),e.GetDefaultPlugin())},e._GetPluginForDirectLoad=function(t){for(var i in e._registeredPlugins){var n=e._registeredPlugins[i].plugin;if(n.canDirectLoad&&n.canDirectLoad(t))return e._registeredPlugins[i]}return e.GetDefaultPlugin()},e._GetPluginForFilename=function(t){var i=t.indexOf(\"?\");-1!==i&&(t=t.substring(0,i));var n=t.lastIndexOf(\".\"),r=t.substring(n,t.length).toLowerCase();return e._GetPluginForExtension(r)},e._GetDirectLoad=function(e){return\"data:\"===e.substr(0,5)?e.substr(5):null},e._LoadData=function(t,i,n,r,o,a,s){var c,l=e._GetDirectLoad(t.name),u=s?e._GetPluginForExtension(s):l?e._GetPluginForDirectLoad(t.name):e._GetPluginForFilename(t.name);if(!(c=void 0!==u.plugin.createPlugin?u.plugin.createPlugin():u.plugin))throw\"The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.\";if(e.OnPluginActivatedObservable.notifyObservers(c),l){if(c.directLoad){var h=c.directLoad(i,l);h.then?h.then((function(e){n(c,e)})).catch((function(e){o(\"Error in directLoad of _loadData: \"+e,e)})):n(c,h)}else n(c,l);return c}var d=u.isBinary,f=function(e,t){i.isDisposed?o(\"Scene has been disposed\"):n(c,e,t)},p=null,_=!1,m=c.onDisposeObservable;m&&m.add((function(){_=!0,p&&(p.abort(),p=null),a()}));var g=function(){if(!_){var e=function(e,t){f(e,t?t.responseURL:void 0)},n=function(e){o(e.message,e)};p=c.requestFile?c.requestFile(i,t.url,e,r,d,n):i._requestFile(t.url,e,r,!0,d,n)}},v=t.file||dr.a.FilesToLoad[t.name.toLowerCase()];if(-1===t.rootUrl.indexOf(\"file:\")||-1!==t.rootUrl.indexOf(\"file:\")&&!v){var b=i.getEngine(),y=b.enableOfflineSupport;if(y){for(var T=!1,E=0,S=i.disableOfflineSupportExceptionRules;Em.snapDistance?(r=Math.floor(Math.abs(C)/m.snapDistance),C<0&&(r*=-1),C%=m.snapDistance,R.scaleToRef(m.snapDistance*r,R),n=!0):R.scaleInPlace(0)),a.a.ScalingToRef(1+R.x,1+R.y,1+R.z,m._tmpMatrix2),m._tmpMatrix2.multiplyToRef(m.attachedNode.getWorldMatrix(),m._tmpMatrix),m._tmpMatrix.decompose(m._tmpVector);Math.abs(m._tmpVector.x)<1e5&&Math.abs(m._tmpVector.y)<1e5&&Math.abs(m._tmpVector.z)<1e5&&m.attachedNode.getWorldMatrix().copyFrom(m._tmpMatrix),n&&(x.snapDistance=m.snapDistance*r,m.onSnapObservable.notifyObservers(x)),m._matrixChanged()}})),m.dragBehavior.onDragStartObservable.add((function(){m._dragging=!0})),m.dragBehavior.onDragObservable.add((function(e){return A(e.dragDistance)})),m.dragBehavior.onDragEndObservable.add(P),null===(h=null===(u=null===(l=null==r?void 0:r.uniformScaleGizmo)||void 0===l?void 0:l.dragBehavior)||void 0===u?void 0:u.onDragObservable)||void 0===h||h.add((function(e){return A(e.delta.y)})),null===(p=null===(f=null===(d=null==r?void 0:r.uniformScaleGizmo)||void 0===d?void 0:d.dragBehavior)||void 0===f?void 0:f.onDragEndObservable)||void 0===p||p.add(P);var O={gizmoMeshes:[v,b],colliderMeshes:[y.arrowMesh,y.arrowTail],material:m._coloredMaterial,hoverMaterial:m._hoverMaterial,disableMaterial:m._disableMaterial,active:!1};null===(_=m._parent)||void 0===_||_.addToAxisCache(m._gizmoMesh,O),m._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!m._customMeshSet&&(m._isHovered=!(-1==O.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!m._parent)){var i=m._isHovered||m._dragging?m._hoverMaterial:m._coloredMaterial;O.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}}));var M=n._getSharedGizmoLight();return M.includedOnlyMeshes=M.includedOnlyMeshes.concat(m._rootMesh.getChildMeshes()),m}return Object(h.d)(t,e),t.prototype._createGizmoMesh=function(e,t,i){void 0===i&&(i=!1);var n=Ar.a.CreateBox(\"yPosMesh\",{size:.4*(1+(t-1)/4)},this.gizmoLayer.utilityLayerScene),r=nn.a.CreateCylinder(\"cylinder\",{diameterTop:.005*t,height:.275,diameterBottom:.005*t,tessellation:96},this.gizmoLayer.utilityLayerScene);return n.scaling.scaleInPlace(.1),n.material=this._coloredMaterial,n.rotation.x=Math.PI/2,n.position.z+=.3,r.material=this._coloredMaterial,r.position.z+=.1375,r.rotation.x=Math.PI/2,i&&(n.visibility=0,r.visibility=0),e.addChild(n),e.addChild(r),{arrowMesh:n,arrowTail:r}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,\"isEnabled\",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh,this.attachedNode=this._parent.attachedNode):(this.attachedMesh=null,this.attachedNode=null)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t.prototype.setCustomMesh=function(t,i){var n=this;void 0===i&&(i=!1),e.prototype.setCustomMesh.call(this,t),i&&(this._rootMesh.getChildMeshes().forEach((function(e){e.material=n._coloredMaterial,e.color&&(e.color=n._coloredMaterial.diffuseColor)})),this._customMeshSet=!1)},t}(Pr.a),xr=i(45),Or=i(40),Mr=function(e){function t(t,i){void 0===t&&(t=s.a.Gray()),void 0===i&&(i=Cr.a.DefaultKeepDepthUtilityLayer);var n=e.call(this,i)||this;n._boundingDimensions=new a.e(1,1,1),n._renderObserver=null,n._pointerObserver=null,n._scaleDragSpeed=.2,n._tmpQuaternion=new a.b,n._tmpVector=new a.e(0,0,0),n._tmpRotationMatrix=new a.a,n.ignoreChildren=!1,n.includeChildPredicate=null,n.rotationSphereSize=.1,n.scaleBoxSize=.1,n.fixedDragMeshScreenSize=!1,n.fixedDragMeshBoundsSize=!1,n.fixedDragMeshScreenSizeDistanceFactor=10,n.onDragStartObservable=new o.c,n.onScaleBoxDragObservable=new o.c,n.onScaleBoxDragEndObservable=new o.c,n.onRotationSphereDragObservable=new o.c,n.onRotationSphereDragEndObservable=new o.c,n.scalePivot=null,n._existingMeshScale=new a.e,n._dragMesh=null,n.pointerDragBehavior=new ke.a,n.updateScale=!1,n._anchorMesh=new Ge.a(\"anchor\",i.utilityLayerScene),n.coloredMaterial=new Wi.a(\"\",i.utilityLayerScene),n.coloredMaterial.disableLighting=!0,n.hoverColoredMaterial=new Wi.a(\"\",i.utilityLayerScene),n.hoverColoredMaterial.disableLighting=!0,n._lineBoundingBox=new Ge.a(\"\",i.utilityLayerScene),n._lineBoundingBox.rotationQuaternion=new a.b;var r=[];r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(0,0,0),new a.e(n._boundingDimensions.x,0,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(0,0,0),new a.e(0,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(0,0,0),new a.e(0,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(n._boundingDimensions.x,0,0),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(n._boundingDimensions.x,0,0),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(0,n._boundingDimensions.y,0),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(0,n._boundingDimensions.y,0),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(0,0,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(0,0,n._boundingDimensions.z),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines(\"lines\",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.forEach((function(e){e.color=t,e.position.addInPlace(new a.e(-n._boundingDimensions.x/2,-n._boundingDimensions.y/2,-n._boundingDimensions.z/2)),e.isPickable=!1,n._lineBoundingBox.addChild(e)})),n._rootMesh.addChild(n._lineBoundingBox),n.setColor(t),n._rotateSpheresParent=new Ge.a(\"\",i.utilityLayerScene),n._rotateSpheresParent.rotationQuaternion=new a.b;for(var c=function(e){var t=xr.a.CreateSphere(\"\",{diameter:1},i.utilityLayerScene);t.rotationQuaternion=new a.b,t.material=l.coloredMaterial,(f=new ke.a({})).moveAttached=!1,f.updateDragPlane=!1,t.addBehavior(f);var r=new a.e(1,0,0),o=0;f.onDragStartObservable.add((function(){r.copyFrom(t.forward),o=0})),f.onDragObservable.add((function(t){if(n.onRotationSphereDragObservable.notifyObservers({}),n.attachedMesh){var i=n.attachedMesh.parent;if(i&&i.scaling&&i.scaling.isNonUniformWithinEpsilon(.001))return void m.a.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");We.a._RemoveAndStorePivotPoint(n.attachedMesh);var s=r,c=t.dragPlaneNormal.scale(a.e.Dot(t.dragPlaneNormal,s)),l=s.subtract(c).normalizeToNew(),u=a.e.Dot(l,t.delta)<0?Math.abs(t.delta.length()):-Math.abs(t.delta.length());u=u/n._boundingDimensions.length()*n._anchorMesh.scaling.length(),n.attachedMesh.rotationQuaternion||(n.attachedMesh.rotationQuaternion=a.b.RotationYawPitchRoll(n.attachedMesh.rotation.y,n.attachedMesh.rotation.x,n.attachedMesh.rotation.z)),n._anchorMesh.rotationQuaternion||(n._anchorMesh.rotationQuaternion=a.b.RotationYawPitchRoll(n._anchorMesh.rotation.y,n._anchorMesh.rotation.x,n._anchorMesh.rotation.z)),o+=u,Math.abs(o)<=2*Math.PI&&(e>=8?a.b.RotationYawPitchRollToRef(0,0,u,n._tmpQuaternion):e>=4?a.b.RotationYawPitchRollToRef(u,0,0,n._tmpQuaternion):a.b.RotationYawPitchRollToRef(0,u,0,n._tmpQuaternion),n._anchorMesh.addChild(n.attachedMesh),n._anchorMesh.rotationQuaternion.multiplyToRef(n._tmpQuaternion,n._anchorMesh.rotationQuaternion),n._anchorMesh.removeChild(n.attachedMesh),n.attachedMesh.setParent(i)),n.updateBoundingBox(),We.a._RestorePivotPoint(n.attachedMesh)}n._updateDummy()})),f.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({}),n._selectNode(t)})),f.onDragEndObservable.add((function(){n.onRotationSphereDragEndObservable.notifyObservers({}),n._selectNode(null),n._updateDummy()})),l._rotateSpheresParent.addChild(t)},l=this,u=0;u<12;u++)c(u);n._rootMesh.addChild(n._rotateSpheresParent),n._scaleBoxesParent=new Ge.a(\"\",i.utilityLayerScene),n._scaleBoxesParent.rotationQuaternion=new a.b;for(var h=0;h<3;h++)for(var d=0;d<3;d++)for(var f,p=function(){var e=(1===h?1:0)+(1===d?1:0)+(1===g?1:0);if(1===e||3===e)return\"continue\";var t=Ar.a.CreateBox(\"\",{size:1},i.utilityLayerScene);t.material=_.coloredMaterial,t.metadata=2===e;var r=new a.e(h-1,d-1,g-1).normalize();(f=new ke.a({dragAxis:r})).updateDragPlane=!1,f.moveAttached=!1,t.addBehavior(f),f.onDragObservable.add((function(i){if(n.onScaleBoxDragObservable.notifyObservers({}),n.attachedMesh){var o=n.attachedMesh.parent;if(o&&o.scaling&&o.scaling.isNonUniformWithinEpsilon(.001))return void m.a.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");We.a._RemoveAndStorePivotPoint(n.attachedMesh);var s=i.dragDistance/n._boundingDimensions.length()*n._anchorMesh.scaling.length(),c=new a.e(s,s,s);2===e&&(c.x*=Math.abs(r.x),c.y*=Math.abs(r.y),c.z*=Math.abs(r.z)),c.scaleInPlace(n._scaleDragSpeed),n.updateBoundingBox(),n.scalePivot?(n.attachedMesh.getWorldMatrix().getRotationMatrixToRef(n._tmpRotationMatrix),n._boundingDimensions.scaleToRef(.5,n._tmpVector),a.e.TransformCoordinatesToRef(n._tmpVector,n._tmpRotationMatrix,n._tmpVector),n._anchorMesh.position.subtractInPlace(n._tmpVector),n._boundingDimensions.multiplyToRef(n.scalePivot,n._tmpVector),a.e.TransformCoordinatesToRef(n._tmpVector,n._tmpRotationMatrix,n._tmpVector),n._anchorMesh.position.addInPlace(n._tmpVector)):(t.absolutePosition.subtractToRef(n._anchorMesh.position,n._tmpVector),n._anchorMesh.position.subtractInPlace(n._tmpVector)),n._anchorMesh.addChild(n.attachedMesh),n._anchorMesh.scaling.addInPlace(c),(n._anchorMesh.scaling.x<0||n._anchorMesh.scaling.y<0||n._anchorMesh.scaling.z<0)&&n._anchorMesh.scaling.subtractInPlace(c),n._anchorMesh.removeChild(n.attachedMesh),n.attachedMesh.setParent(o),We.a._RestorePivotPoint(n.attachedMesh)}n._updateDummy()})),f.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({}),n._selectNode(t)})),f.onDragEndObservable.add((function(){n.onScaleBoxDragEndObservable.notifyObservers({}),n._selectNode(null),n._updateDummy()})),_._scaleBoxesParent.addChild(t)},_=this,g=0;g<3;g++)p();n._rootMesh.addChild(n._scaleBoxesParent);var v=new Array;return n._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){v[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=v[e.event.pointerId]&&(v[e.event.pointerId].material=n.coloredMaterial,delete v[e.event.pointerId]):n._rotateSpheresParent.getChildMeshes().concat(n._scaleBoxesParent.getChildMeshes()).forEach((function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(v[e.event.pointerId]=t,t.material=n.hoverColoredMaterial)}))})),n._renderObserver=n.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){n.attachedMesh&&!n._existingMeshScale.equals(n.attachedMesh.scaling)?n.updateBoundingBox():(n.fixedDragMeshScreenSize||n.fixedDragMeshBoundsSize)&&(n._updateRotationSpheres(),n._updateScaleBoxes()),n._dragMesh&&n.attachedMesh&&n.pointerDragBehavior.dragging&&(n._lineBoundingBox.position.rotateByQuaternionToRef(n._rootMesh.rotationQuaternion,n._tmpVector),n.attachedMesh.setAbsolutePosition(n._dragMesh.position.add(n._tmpVector.scale(-1))))})),n.updateBoundingBox(),n}return Object(h.d)(t,e),t.prototype.setColor=function(e){this.coloredMaterial.emissiveColor=e,this.hoverColoredMaterial.emissiveColor=e.clone().add(new s.a(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach((function(t){t.color&&(t.color=e)}))},t.prototype._attachedNodeChanged=function(e){var t=this;if(e){We.a._RemoveAndStorePivotPoint(e);var i=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(i),We.a._RestorePivotPoint(e),this.updateBoundingBox(),e.getChildMeshes(!1).forEach((function(e){e.markAsDirty(\"scaling\")})),this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce((function(){t._updateDummy()}))}},t.prototype._selectNode=function(e){this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach((function(t){t.isVisible=!e||t==e}))},t.prototype.updateBoundingBox=function(){if(this.attachedMesh){We.a._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null);var t=null;this.attachedMesh.skeleton&&(t=this.attachedMesh.skeleton.overrideMesh,this.attachedMesh.skeleton.overrideMesh=null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=a.b.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=a.b.RotationYawPitchRoll(this._anchorMesh.rotation.y,this._anchorMesh.rotation.x,this._anchorMesh.rotation.z)),this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpVector.copyFrom(this.attachedMesh.position),this.attachedMesh.rotationQuaternion.set(0,0,0,1),this.attachedMesh.position.set(0,0,0);var i=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);i.max.subtractToRef(i.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((i.max.x+i.min.x)/2,(i.max.y+i.min.y)/2,(i.max.z+i.min.z)/2),this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),this._lineBoundingBox.computeWorldMatrix(),this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector),this.attachedMesh.setParent(e),this.attachedMesh.skeleton&&(this.attachedMesh.skeleton.overrideMesh=t)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),We.a._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationSpheres=function(){for(var e=this._rotateSpheresParent.getChildMeshes(),t=0;t<3;t++)for(var i=0;i<2;i++)for(var n=0;n<2;n++){var r=4*t+2*i+n;if(0==t&&(e[r].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*i,this._boundingDimensions.z*n),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Right()).normalizeToNew().add(e[r].position))),1==t&&(e[r].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y/2,this._boundingDimensions.z*n),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Up()).normalizeToNew().add(e[r].position))),2==t&&(e[r].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y*n,this._boundingDimensions.z/2),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Forward()).normalizeToNew().add(e[r].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[r].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var o=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[r].scaling.set(o,o,o)}else this.fixedDragMeshBoundsSize?e[r].scaling.set(this.rotationSphereSize*this._boundingDimensions.x,this.rotationSphereSize*this._boundingDimensions.y,this.rotationSphereSize*this._boundingDimensions.z):e[r].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),t=0,i=0;i<3;i++)for(var n=0;n<3;n++)for(var r=0;r<3;r++){var o=(1===i?1:0)+(1===n?1:0)+(1===r?1:0);if(1!==o&&3!==o){if(e[t])if(e[t].position.set(this._boundingDimensions.x*(i/2),this._boundingDimensions.y*(n/2),this._boundingDimensions.z*(r/2)),e[t].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[t].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var s=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[t].scaling.set(s,s,s)}else this.fixedDragMeshBoundsSize?e[t].scaling.set(this.scaleBoxSize*this._boundingDimensions.x,this.scaleBoxSize*this._boundingDimensions.y,this.scaleBoxSize*this._boundingDimensions.z):e[t].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize);t++}}},t.prototype.setEnabledRotationAxis=function(e){this._rotateSpheresParent.getChildMeshes().forEach((function(t,i){i<4?t.setEnabled(-1!=e.indexOf(\"x\")):i<8?t.setEnabled(-1!=e.indexOf(\"y\")):t.setEnabled(-1!=e.indexOf(\"z\"))}))},t.prototype.setEnabledScaling=function(e,t){void 0===t&&(t=!1),this._scaleBoxesParent.getChildMeshes().forEach((function(i,n){var r=e;t&&!0===i.metadata&&(r=!1),i.setEnabled(r)}))},t.prototype._updateDummy=function(){this._dragMesh&&(this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()),this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling),this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion))},t.prototype.enableDragBehavior=function(){this._dragMesh=be.a.CreateBox(\"dummy\",1,this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new a.b,this.pointerDragBehavior.useObjectOrientationForDragging=!1,this._dragMesh.addBehavior(this.pointerDragBehavior)},t.prototype.dispose=function(){this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),this._lineBoundingBox.dispose(),this._rotateSpheresParent.dispose(),this._scaleBoxesParent.dispose(),this._dragMesh&&this._dragMesh.dispose(),e.prototype.dispose.call(this)},t.MakeNotPickableAndWrapInBoundingBox=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e),e.rotationQuaternion||(e.rotationQuaternion=a.b.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var i=e.position.clone(),n=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var r=Ar.a.CreateBox(\"box\",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,r.scaling),0===r.scaling.y&&(r.scaling.y=Nt.a),0===r.scaling.x&&(r.scaling.x=Nt.a),0===r.scaling.z&&(r.scaling.z=Nt.a),r.position.set((o.max.x+o.min.x)/2,(o.max.y+o.min.y)/2,(o.max.z+o.min.z)/2),e.addChild(r),e.rotationQuaternion.copyFrom(n),e.position.copyFrom(i),e.removeChild(r),r.addChild(e),r.visibility=0,r},t.prototype.setCustomMesh=function(e){m.a.Error(\"Custom meshes are not supported on this gizmo\")},t}(Pr.a),Ir=function(e){function t(t,i,n,r,c,l,u){var h;void 0===i&&(i=s.a.Gray()),void 0===n&&(n=Cr.a.DefaultUtilityLayer),void 0===r&&(r=32),void 0===c&&(c=null),void 0===l&&(l=!1),void 0===u&&(u=1);var d=e.call(this,n)||this;d._pointerObserver=null,d.snapDistance=0,d.onSnapObservable=new o.c,d._isEnabled=!0,d._parent=null,d._dragging=!1,d._parent=c,d._coloredMaterial=new Wi.a(\"\",n.utilityLayerScene),d._coloredMaterial.diffuseColor=i,d._coloredMaterial.specularColor=i.subtract(new s.a(.1,.1,.1)),d._hoverMaterial=new Wi.a(\"\",n.utilityLayerScene),d._hoverMaterial.diffuseColor=s.a.Yellow(),d._disableMaterial=new Wi.a(\"\",n.utilityLayerScene),d._disableMaterial.diffuseColor=s.a.Gray(),d._disableMaterial.alpha=.4,d._gizmoMesh=new be.a(\"\",n.utilityLayerScene);var f=d._createGizmoMesh(d._gizmoMesh,u,r),p=f.rotationMesh,_=f.collider,m=[];d._rotationCircle=d.setupRotationCircle(m,d._gizmoMesh),d._gizmoMesh.lookAt(d._rootMesh.position.add(t)),d._rootMesh.addChild(d._gizmoMesh),d._gizmoMesh.scaling.scaleInPlace(1/3),d.dragBehavior=new ke.a({dragPlaneNormal:t}),d.dragBehavior.moveAttached=!1,d.dragBehavior.maxDragAngle=9*Math.PI/20,d.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,d._rootMesh.addBehavior(d.dragBehavior);var g=0,v=new a.e,b=new a.e,y=new a.a,T=new a.e,E=new a.e;d.dragBehavior.onDragStartObservable.add((function(e){if(d.attachedNode){v.copyFrom(e.dragPlanePoint);var t=new a.e(0,0,1),i=d._rotationCircle.getDirection(t);i.normalize(),d._gizmoMesh.removeChild(d._rotationCircle),v.copyFrom(e.dragPlanePoint),b=e.dragPlanePoint;var n=d._rotationCircle.getAbsolutePosition().clone(),r=d._rotationCircle.getAbsolutePosition().clone().addInPlace(i),o=e.dragPlanePoint,s=a.e.GetAngleBetweenVectors(r.subtract(n),o.subtract(n),d._rotationCircle.up);d._rotationCircle.addRotation(0,s,0),d._dragging=!0}})),d.dragBehavior.onDragEndObservable.add((function(){g=0,d.updateRotationCircle(d._rotationCircle,m,g,b),d._gizmoMesh.addChild(d._rotationCircle),d._dragging=!1}));var S={snapDistance:0},A=0,P=new a.a,C=new a.b;d.dragBehavior.onDragObservable.add((function(e){if(d.attachedNode){var i=new a.e(1,1,1),r=new a.b(0,0,0,1),o=new a.e(0,0,0);d.attachedNode.getWorldMatrix().decompose(i,r,o);var s=e.dragPlanePoint.subtract(o).normalize(),c=v.subtract(o).normalize(),l=a.e.Cross(s,c),u=a.e.Dot(s,c),h=Math.atan2(l.length(),u);T.copyFrom(t),E.copyFrom(t),d.updateGizmoRotationToMatchAttachedMesh&&(r.toRotationMatrix(y),E=a.e.TransformCoordinates(T,y));var f=!1;if(n.utilityLayerScene.activeCamera){var p=n.utilityLayerScene.activeCamera.position.subtract(o);a.e.Dot(p,E)>0&&(T.scaleInPlace(-1),E.scaleInPlace(-1),f=!0)}a.e.Dot(E,l)>0&&(h=-h);var _=!1;if(0!=d.snapDistance)if(A+=h,Math.abs(A)>d.snapDistance){var R=Math.floor(Math.abs(A)/d.snapDistance);A<0&&(R*=-1),A%=d.snapDistance,h=d.snapDistance*R,_=!0}else h=0;g+=f?-h:h,d.updateRotationCircle(d._rotationCircle,m,g,b);var x=Math.sin(h/2);if(C.set(T.x*x,T.y*x,T.z*x,Math.cos(h/2)),P.determinant()>0){var O=new a.e;C.toEulerAnglesToRef(O),a.b.RotationYawPitchRollToRef(O.y,-O.x,-O.z,C)}d.updateGizmoRotationToMatchAttachedMesh?r.multiplyToRef(C,r):C.multiplyToRef(r,r),d.attachedNode.getWorldMatrix().copyFrom(a.a.Compose(i,r,o)),v.copyFrom(e.dragPlanePoint),_&&(S.snapDistance=h,d.onSnapObservable.notifyObservers(S)),d._matrixChanged()}}));var R=n._getSharedGizmoLight();R.includedOnlyMeshes=R.includedOnlyMeshes.concat(d._rootMesh.getChildMeshes(!1));var x={colliderMeshes:[_],gizmoMeshes:[p],material:d._coloredMaterial,hoverMaterial:d._hoverMaterial,disableMaterial:d._disableMaterial,active:!1};return null===(h=d._parent)||void 0===h||h.addToAxisCache(d._gizmoMesh,x),d._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!d._customMeshSet&&(d._isHovered=!(-1==x.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!d._parent)){var i=d._isHovered||d._dragging?d._hoverMaterial:d._coloredMaterial;x.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}})),d}return Object(h.d)(t,e),t.prototype._createGizmoMesh=function(e,t,i){var n=be.a.CreateTorus(\"ignore\",.6,.03*t,i,this.gizmoLayer.utilityLayerScene);n.visibility=0;var r=be.a.CreateTorus(\"\",.6,.005*t,i,this.gizmoLayer.utilityLayerScene);return r.material=this._coloredMaterial,r.rotation.x=Math.PI/2,n.rotation.x=Math.PI/2,e.addChild(r),e.addChild(n),{rotationMesh:r,collider:n}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.setupRotationCircle=function(e,i){for(var n=t._CircleConstants.pi2/t._CircleConstants.tessellation,r=-Math.PI/2;r0?c:-1*c,u=i>0?o:-1*o;a[s].set(t._CircleConstants.radius*Math.sin(l)*Math.cos(u),0,t._CircleConstants.radius*Math.cos(l)*Math.cos(u))}else a[s].set(0,0,0);s++}r++}},t.prototype.updateRotationCircle=function(e,t,i,n){this.updateRotationPath(t,i),be.a.CreateRibbon(\"rotationCircle\",t,!1,!1,0,this.gizmoLayer.utilityLayerScene,void 0,void 0,e.geometry?e:void 0)},Object.defineProperty(t.prototype,\"isEnabled\",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh):this.attachedMesh=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),this._rotationCircle&&this._rotationCircle.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t._CircleConstants={radius:.3,pi2:2*Math.PI,tessellation:70,rotationCircleRange:4},t}(Pr.a),Dr=function(e){function t(t,i,n,r,c){void 0===t&&(t=Cr.a.DefaultUtilityLayer),void 0===i&&(i=32),void 0===n&&(n=!1),void 0===r&&(r=1);var l=e.call(this,t)||this;return l.onDragStartObservable=new o.c,l.onDragEndObservable=new o.c,l._observables=[],l._gizmoAxisCache=new Map,l.xGizmo=new Ir(new a.e(1,0,0),s.a.Red().scale(.5),t,i,l,n,r),l.yGizmo=new Ir(new a.e(0,1,0),s.a.Green().scale(.5),t,i,l,n,r),l.zGizmo=new Ir(new a.e(0,0,1),s.a.Blue().scale(.5),t,i,l,n,r),[l.xGizmo,l.yGizmo,l.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){l.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){l.onDragEndObservable.notifyObservers({})}))})),l.attachedMesh=null,l.attachedNode=null,c?c.addToAxisCache(l._gizmoAxisCache):Pr.a.GizmoAxisPointerObserver(t,l._gizmoAxisCache),l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"attachedMesh\",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"attachedNode\",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),t.prototype._checkBillboardTransform=function(){this._nodeAttached&&this._nodeAttached.billboardMode&&console.log(\"Rotation Gizmo will not work with transforms in billboard mode.\")},Object.defineProperty(t.prototype,\"isHovered\",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){e=e||t.isHovered})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"updateGizmoRotationToMatchAttachedMesh\",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"snapDistance\",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"scaleRatio\",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.dispose=function(){var e=this;this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear(),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)}))},t.prototype.setCustomMesh=function(e){m.a.Error(\"Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)\")},t}(Pr.a),Nr=i(46),Lr=i(84),wr=function(e){function t(i,n,r,c){var l;void 0===n&&(n=s.a.Gray()),void 0===r&&(r=Cr.a.DefaultUtilityLayer),void 0===c&&(c=null);var u=e.call(this,r)||this;u._pointerObserver=null,u.snapDistance=0,u.onSnapObservable=new o.c,u._isEnabled=!1,u._parent=null,u._dragging=!1,u._parent=c,u._coloredMaterial=new Wi.a(\"\",r.utilityLayerScene),u._coloredMaterial.diffuseColor=n,u._coloredMaterial.specularColor=n.subtract(new s.a(.1,.1,.1)),u._hoverMaterial=new Wi.a(\"\",r.utilityLayerScene),u._hoverMaterial.diffuseColor=s.a.Yellow(),u._disableMaterial=new Wi.a(\"\",r.utilityLayerScene),u._disableMaterial.diffuseColor=s.a.Gray(),u._disableMaterial.alpha=.4,u._gizmoMesh=t._CreatePlane(r.utilityLayerScene,u._coloredMaterial),u._gizmoMesh.lookAt(u._rootMesh.position.add(i)),u._gizmoMesh.scaling.scaleInPlace(1/3),u._gizmoMesh.parent=u._rootMesh;var h=0,d=new a.e,f={snapDistance:0};u.dragBehavior=new ke.a({dragPlaneNormal:i}),u.dragBehavior.moveAttached=!1,u._rootMesh.addBehavior(u.dragBehavior),u.dragBehavior.onDragObservable.add((function(e){if(u.attachedNode){if(0==u.snapDistance)u.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z);else if(h+=e.dragDistance,Math.abs(h)>u.snapDistance){var t=Math.floor(Math.abs(h)/u.snapDistance);h%=u.snapDistance,e.delta.normalizeToRef(d),d.scaleInPlace(u.snapDistance*t),u.attachedNode.getWorldMatrix().addTranslationFromFloats(d.x,d.y,d.z),f.snapDistance=u.snapDistance*t,u.onSnapObservable.notifyObservers(f)}u._matrixChanged()}})),u.dragBehavior.onDragStartObservable.add((function(){u._dragging=!0})),u.dragBehavior.onDragEndObservable.add((function(){u._dragging=!1}));var p=r._getSharedGizmoLight();p.includedOnlyMeshes=p.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));var _={gizmoMeshes:u._gizmoMesh.getChildMeshes(),colliderMeshes:u._gizmoMesh.getChildMeshes(),material:u._coloredMaterial,hoverMaterial:u._hoverMaterial,disableMaterial:u._disableMaterial,active:!1};return null===(l=u._parent)||void 0===l||l.addToAxisCache(u._gizmoMesh,_),u._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!u._customMeshSet&&(u._isHovered=!(-1==_.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!u._parent)){var i=u._isHovered||u._dragging?u._hoverMaterial:u._coloredMaterial;_.gizmoMeshes.forEach((function(e){e.material=i}))}})),u}return Object(h.d)(t,e),t._CreatePlane=function(e,t){var i=new Nr.a(\"plane\",e),n=Lr.a.CreatePlane(\"dragPlane\",{width:.1375,height:.1375,sideOrientation:2},e);return n.material=t,n.parent=i,i},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,\"isEnabled\",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedNode=this._parent.attachedNode):this.attachedNode=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()}))},t}(Pr.a),Fr=function(e){function t(t,i,n){void 0===t&&(t=Cr.a.DefaultUtilityLayer),void 0===i&&(i=1);var r=e.call(this,t)||this;return r._meshAttached=null,r._nodeAttached=null,r._observables=[],r._gizmoAxisCache=new Map,r.onDragStartObservable=new o.c,r.onDragEndObservable=new o.c,r._planarGizmoEnabled=!1,r.xGizmo=new Sr.a(new a.e(1,0,0),s.a.Red().scale(.5),t,r,i),r.yGizmo=new Sr.a(new a.e(0,1,0),s.a.Green().scale(.5),t,r,i),r.zGizmo=new Sr.a(new a.e(0,0,1),s.a.Blue().scale(.5),t,r,i),r.xPlaneGizmo=new wr(new a.e(1,0,0),s.a.Red().scale(.5),r.gizmoLayer,r),r.yPlaneGizmo=new wr(new a.e(0,1,0),s.a.Green().scale(.5),r.gizmoLayer,r),r.zPlaneGizmo=new wr(new a.e(0,0,1),s.a.Blue().scale(.5),r.gizmoLayer,r),[r.xGizmo,r.yGizmo,r.zGizmo,r.xPlaneGizmo,r.yPlaneGizmo,r.zPlaneGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){r.onDragEndObservable.notifyObservers({})}))})),r.attachedMesh=null,n?n.addToAxisCache(r._gizmoAxisCache):Pr.a.GizmoAxisPointerObserver(t,r._gizmoAxisCache),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"attachedMesh\",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"attachedNode\",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=null,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"isHovered\",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){e=e||t.isHovered})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"planarGizmoEnabled\",{get:function(){return this._planarGizmoEnabled},set:function(e){var t=this;this._planarGizmoEnabled=e,[this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(i){i&&(i.isEnabled=e,e&&(i.attachedMesh?i.attachedMesh=t.attachedMesh:i.attachedNode=t.attachedNode))}),this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"updateGizmoRotationToMatchAttachedMesh\",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.updateGizmoRotationToMatchAttachedMesh=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"snapDistance\",{get:function(){return this._snapDistance},set:function(e){this._snapDistance=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.snapDistance=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"scaleRatio\",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.scaleRatio=e)}))},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.dispose=function(){var e=this;[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(e){e&&e.dispose()})),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)})),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){m.a.Error(\"Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)\")},t}(Pr.a);Ki.a.CreatePolyhedron=function(e){var t=[];t[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},t[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},t[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},t[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},t[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},t[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},t[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},t[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},t[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},t[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},t[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},t[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},t[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},t[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},t[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var i,n,r,o,c,l,u=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,h=e.size,d=e.sizeX||h||1,f=e.sizeY||h||1,p=e.sizeZ||h||1,_=e.custom||t[u],m=_.face.length,g=e.faceUV||new Array(m),v=e.faceColors,b=void 0===e.flat||e.flat,y=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE,T=new Array,E=new Array,S=new Array,A=new Array,P=new Array,C=0,R=0,x=new Array,O=0,M=0;if(b)for(M=0;M0&&e.forEach((function(e,i){t._gizmoAxisCache.set(i,e)}))},e.prototype.dispose=function(){var e=this;for(var t in this._pointerObservers.forEach((function(t){e.scene.onPointerObservable.remove(t)})),this.gizmos){var i=this.gizmos[t];i&&i.dispose()}this._defaultKeepDepthUtilityLayer.dispose(),this._defaultUtilityLayer.dispose(),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},e}(),kr=i(48),zr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._needProjectionMatrixCompute=!0,t}return Object(h.d)(t,e),t.prototype._setPosition=function(e){this._position=e},Object.defineProperty(t.prototype,\"position\",{get:function(){return this._position},set:function(e){this._setPosition(e)},enumerable:!1,configurable:!0}),t.prototype._setDirection=function(e){this._direction=e},Object.defineProperty(t.prototype,\"direction\",{get:function(){return this._direction},set:function(e){this._setDirection(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"shadowMinZ\",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"shadowMaxZ\",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),t.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=a.e.Zero()),a.e.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=a.e.Zero()),a.e.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},t.prototype.getDepthScale=function(){return 50},t.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},t.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},t.prototype.setDirectionToTarget=function(e){return this.direction=a.e.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=a.e.Cross(this.direction,J.a.Y),t=a.e.Cross(e,this.direction);return a.e.RotationFromAxis(e,t,this.direction)},t.prototype.needCube=function(){return!1},t.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},t.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.position=a.e.Zero()},t.prototype._isSynchronized=function(){return!!this._cache.position.equals(this.position)},t.prototype.computeWorldMatrix=function(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=a.a.Identity()),a.a.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)},t.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},t.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},t.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},Object(h.c)([Object(w.o)()],t.prototype,\"position\",null),Object(h.c)([Object(w.o)()],t.prototype,\"direction\",null),Object(h.c)([Object(w.c)()],t.prototype,\"shadowMinZ\",null),Object(h.c)([Object(w.c)()],t.prototype,\"shadowMaxZ\",null),t}(kr.a);B.a.AddNodeConstructor(\"Light_Type_1\",(function(e,t){return function(){return new Gr(e,a.e.Zero(),t)}}));var Gr=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r._shadowFrustumSize=0,r._shadowOrthoScale=.1,r.autoUpdateExtends=!0,r.autoCalcShadowZBounds=!1,r._orthoLeft=Number.MAX_VALUE,r._orthoRight=Number.MIN_VALUE,r._orthoTop=Number.MIN_VALUE,r._orthoBottom=Number.MAX_VALUE,r.position=i.scale(-1),r.direction=i,r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"shadowFrustumSize\",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"shadowOrthoScale\",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"DirectionalLight\"},t.prototype.getTypeID=function(){return kr.a.LIGHTTYPEID_DIRECTIONALLIGHT},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},t.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e){var t=this.getScene().activeCamera;t&&a.a.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:t.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:t.maxZ,e)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,t,i){var n=this.getScene().activeCamera;if(n){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var r=a.e.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var o=Number.MAX_VALUE,s=Number.MIN_VALUE,c=0;cthis._orthoRight&&(this._orthoRight=r.x),r.y>this._orthoTop&&(this._orthoTop=r.y),this.autoCalcShadowZBounds&&(r.zs&&(s=r.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=o,this._shadowMaxZ=s)}var d=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;a.a.OrthoOffCenterLHToRef(this._orthoLeft-d*this.shadowOrthoScale,this._orthoRight+d*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,e)}},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform(\"vLightData\",4),this._uniformBuffer.addUniform(\"vLightDiffuse\",4),this._uniformBuffer.addUniform(\"vLightSpecular\",4),this._uniformBuffer.addUniform(\"shadowsInfo\",3),this._uniformBuffer.addUniform(\"depthValues\",2),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4(\"vLightData\",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4(\"vLightData\",this.direction.x,this.direction.y,this.direction.z,1,t),this)},t.prototype.transferToNodeMaterialEffect=function(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),this)},t.prototype.getDepthMinZ=function(e){return 1},t.prototype.getDepthMaxZ=function(e){return 1},t.prototype.prepareLightSpecificDefines=function(e,t){e[\"DIRLIGHT\"+t]=!0},Object(h.c)([Object(w.c)()],t.prototype,\"shadowFrustumSize\",null),Object(h.c)([Object(w.c)()],t.prototype,\"shadowOrthoScale\",null),Object(h.c)([Object(w.c)()],t.prototype,\"autoUpdateExtends\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"autoCalcShadowZBounds\",void 0),t}(zr);be.a.CreateHemisphere=function(e,t,i,n){var r={segments:t,diameter:i};return jr.CreateHemisphere(e,r,n)};var jr=function(){function e(){}return e.CreateHemisphere=function(e,t,i){t.diameter||(t.diameter=1),t.segments||(t.segments=16);var n=xr.a.CreateSphere(\"\",{slice:.5,diameter:t.diameter,segments:t.segments},i),r=be.a.CreateDisc(\"\",t.diameter/2,3*t.segments+(4-t.segments),i);r.rotation.x=-Math.PI/2,r.parent=n;var o=be.a.MergeMeshes([r,n],!0);return o.name=e,o},e}();B.a.AddNodeConstructor(\"Light_Type_2\",(function(e,t){return function(){return new Wr(e,a.e.Zero(),a.e.Zero(),0,0,t)}}));var Wr=function(e){function t(t,i,n,r,o,s){var c=e.call(this,t,s)||this;return c._innerAngle=0,c._projectionTextureMatrix=a.a.Zero(),c._projectionTextureLightNear=1e-6,c._projectionTextureLightFar=1e3,c._projectionTextureUpDirection=a.e.Up(),c._projectionTextureViewLightDirty=!0,c._projectionTextureProjectionLightDirty=!0,c._projectionTextureDirty=!0,c._projectionTextureViewTargetVector=a.e.Zero(),c._projectionTextureViewLightMatrix=a.a.Zero(),c._projectionTextureProjectionLightMatrix=a.a.Zero(),c._projectionTextureScalingMatrix=a.a.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),c.position=i,c.direction=n,c.angle=r,c.exponent=o,c}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"angle\",{get:function(){return this._angle},set:function(e){this._angle=e,this._cosHalfAngle=Math.cos(.5*e),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"innerAngle\",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"shadowAngleScale\",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"projectionTextureMatrix\",{get:function(){return this._projectionTextureMatrix},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"projectionTextureLightNear\",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"projectionTextureLightFar\",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"projectionTextureUpDirection\",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"projectionTexture\",{get:function(){return this._projectionTexture},set:function(e){var i=this;this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady()&&(t._IsProceduralTexture(this._projectionTexture)?this._projectionTexture.getEffect().executeWhenCompiled((function(){i._markMeshesAsLightDirty()})):t._IsTexture(this._projectionTexture)&&this._projectionTexture.onLoadObservable.addOnce((function(){i._markMeshesAsLightDirty()}))))},enumerable:!1,configurable:!0}),t._IsProceduralTexture=function(e){return void 0!==e.onGeneratedObservable},t._IsTexture=function(e){return void 0!==e.onLoadObservable},t.prototype.getClassName=function(){return\"SpotLight\"},t.prototype.getTypeID=function(){return kr.a.LIGHTTYPEID_SPOTLIGHT},t.prototype._setDirection=function(t){e.prototype._setDirection.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setPosition=function(t){e.prototype._setPosition.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){var n=this.getScene().activeCamera;if(n){this._shadowAngleScale=this._shadowAngleScale||1;var r=this._shadowAngleScale*this._angle;a.a.PerspectiveFovLHToRef(r,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),e)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),a.a.LookAtLHToRef(this.position,this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},t.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,i=e/(e-t),n=-i*t,r=1/Math.tan(this._angle/2);a.a.FromValuesToRef(r/1,0,0,0,0,r,0,0,0,0,i,1,0,0,n,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof Ke.a){var e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;a.a.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,.5,0,.5,.5,.5,1,this._projectionTextureScalingMatrix)}this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform(\"vLightData\",4),this._uniformBuffer.addUniform(\"vLightDiffuse\",4),this._uniformBuffer.addUniform(\"vLightSpecular\",4),this._uniformBuffer.addUniform(\"vLightDirection\",3),this._uniformBuffer.addUniform(\"vLightFalloff\",4),this._uniformBuffer.addUniform(\"shadowsInfo\",3),this._uniformBuffer.addUniform(\"depthValues\",2),this._uniformBuffer.create()},t.prototype._computeAngleValues=function(){this._lightAngleScale=1/Math.max(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},t.prototype.transferTexturesToEffect=function(e,t){return this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix(\"textureProjectionMatrix\"+t,this._projectionTextureMatrix),e.setTexture(\"projectionLightSampler\"+t,this.projectionTexture)),this},t.prototype.transferToEffect=function(e,t){var i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4(\"vLightData\",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,t),i=a.e.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4(\"vLightData\",this.position.x,this.position.y,this.position.z,this.exponent,t),i=a.e.Normalize(this.direction)),this._uniformBuffer.updateFloat4(\"vLightDirection\",i.x,i.y,i.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4(\"vLightFalloff\",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this},t.prototype.transferToNodeMaterialEffect=function(e,t){var i;return i=this.computeTransformedInformation()?a.e.Normalize(this.transformedDirection):a.e.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(t,-i.x,-i.y,-i.z):e.setFloat3(t,i.x,i.y,i.z),this},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},t.prototype.prepareLightSpecificDefines=function(e,t){e[\"SPOTLIGHT\"+t]=!0,e[\"PROJECTEDLIGHTTEXTURE\"+t]=!(!this.projectionTexture||!this.projectionTexture.isReady())},Object(h.c)([Object(w.c)()],t.prototype,\"angle\",null),Object(h.c)([Object(w.c)()],t.prototype,\"innerAngle\",null),Object(h.c)([Object(w.c)()],t.prototype,\"shadowAngleScale\",null),Object(h.c)([Object(w.c)()],t.prototype,\"exponent\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"projectionTextureLightNear\",null),Object(h.c)([Object(w.c)()],t.prototype,\"projectionTextureLightFar\",null),Object(h.c)([Object(w.c)()],t.prototype,\"projectionTextureUpDirection\",null),Object(h.c)([Object(w.m)(\"projectedLightTexture\")],t.prototype,\"_projectionTexture\",void 0),t}(zr),Hr=function(e){function t(t){void 0===t&&(t=Cr.a.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._cachedPosition=new a.e,i._cachedForward=new a.e(0,0,1),i._pointerObserver=null,i.onClickedObservable=new o.c,i._light=null,i.attachedMesh=new Ge.a(\"\",i.gizmoLayer.utilityLayerScene),i._attachedMeshParent=new Nr.a(\"parent\",i.gizmoLayer.utilityLayerScene),i.attachedMesh.parent=i._attachedMeshParent,i._material=new Wi.a(\"light\",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new s.a(.5,.5,.5),i._material.specularColor=new s.a(.1,.1,.1),i._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){i._light&&(i._isHovered=!(!e.pickInfo||-1==i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),i._isHovered&&0===e.event.button&&i.onClickedObservable.notifyObservers(i._light))}),Ne.a.POINTERDOWN),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"light\",{get:function(){return this._light},set:function(e){var i=this;if(this._light=e,e){this._lightMesh&&this._lightMesh.dispose(),e instanceof ki.a?this._lightMesh=t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):this._lightMesh=e instanceof Gr?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Wr?t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene):t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),this._lightMesh.getChildMeshes(!1).forEach((function(e){e.material=i._material})),this._lightMesh.parent=this._rootMesh;var n=this.gizmoLayer._getSharedGizmoLight();n.includedOnlyMeshes=n.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),this._lightMesh.rotationQuaternion=new a.b,this.attachedMesh.reservedDataStore||(this.attachedMesh.reservedDataStore={}),this.attachedMesh.reservedDataStore.lightGizmo=this,e.parent&&this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()),e.position&&(this.attachedMesh.position.copyFrom(e.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position)),e.direction&&(this.attachedMesh.setDirection(e.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(this.attachedMesh.forward)),this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"material\",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._update=function(){e.prototype._update.call(this),this._light&&(this._light.parent&&this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()),this._light.position&&(this.attachedMesh.position.equals(this._cachedPosition)?(this.attachedMesh.position.copyFrom(this._light.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position)):(this._light.position.copyFrom(this.attachedMesh.position),this._cachedPosition.copyFrom(this.attachedMesh.position))),this._light.direction&&(a.e.DistanceSquared(this.attachedMesh.forward,this._cachedForward)>1e-4?(this._light.direction.copyFrom(this.attachedMesh.forward),this._cachedForward.copyFrom(this.attachedMesh.forward)):a.e.DistanceSquared(this.attachedMesh.forward,this._light.direction)>1e-4&&(this.attachedMesh.setDirection(this._light.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(this.attachedMesh.forward))))},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._material.dispose(),e.prototype.dispose.call(this),this._attachedMeshParent.dispose()},t._CreateHemisphericLightMesh=function(e){var i=new be.a(\"hemisphereLight\",e),n=jr.CreateHemisphere(i.name,{segments:10,diameter:1},e);n.position.z=-.15,n.rotation.x=Math.PI/2,n.parent=i;var r=this._CreateLightLines(3,e);return r.parent=i,r.position.z,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreatePointLightMesh=function(e){var i=new be.a(\"pointLight\",e),n=xr.a.CreateSphere(i.name,{segments:10,diameter:1},e);return n.rotation.x=Math.PI/2,n.parent=i,this._CreateLightLines(5,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreateSpotLightMesh=function(e){var i=new be.a(\"spotLight\",e);xr.a.CreateSphere(i.name,{segments:10,diameter:1},e).parent=i;var n=jr.CreateHemisphere(i.name,{segments:10,diameter:2},e);return n.parent=i,n.rotation.x=-Math.PI/2,this._CreateLightLines(2,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreateDirectionalLightMesh=function(e){var i=new be.a(\"directionalLight\",e),n=new be.a(i.name,e);n.parent=i,xr.a.CreateSphere(i.name,{diameter:1.2,segments:10},e).parent=n;var r=be.a.CreateCylinder(i.name,6,.3,.3,6,1,e);r.parent=n,(o=r.clone(i.name)).scaling.y=.5,o.position.x+=1.25,(a=r.clone(i.name)).scaling.y=.5,a.position.x+=-1.25;var o,a,s=be.a.CreateCylinder(i.name,1,0,.6,6,1,e);return s.position.y+=3,s.parent=n,(o=s.clone(i.name)).position.y=1.5,o.position.x+=1.25,(a=s.clone(i.name)).position.y=1.5,a.position.x+=-1.25,n.scaling.scaleInPlace(t._Scale),n.rotation.z=Math.PI/2,n.rotation.y=Math.PI/2,i},t._Scale=.007,t._CreateLightLines=function(e,t){var i=new be.a(\"root\",t);i.rotation.x=Math.PI/2;var n=new be.a(\"linePivot\",t);n.parent=i;var r=be.a.CreateCylinder(\"line\",2,.2,.3,6,1,t);if(r.position.y=r.scaling.y/2+1.2,r.parent=n,e<2)return n;for(var o=0;o<4;o++){(a=n.clone(\"lineParentClone\")).rotation.z=Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}if(e<3)return i;for(o=0;o<4;o++){(a=n.clone(\"linePivotClone\")).rotation.z=Math.PI/2,a.rotation.y=Math.PI/2*o}if(e<4)return i;for(o=0;o<4;o++){var a;(a=n.clone(\"linePivotClone\")).rotation.z=Math.PI+Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}return e<5||((a=n.clone(\"linePivotClone\")).rotation.z=Math.PI),i},t}(Pr.a),Xr=function(){function e(e,t){void 0===e&&(e=a.e.Zero()),void 0===t&&(t=a.e.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}(),Yr=function(){function e(e,t,i){void 0===e&&(e=a.e.Zero()),void 0===t&&(t=a.e.Up()),void 0===i&&(i=a.d.Zero()),this.position=e,this.normal=t,this.uv=i}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e}(),Kr=function(e){function t(t){void 0===t&&(t=Cr.a.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._pointerObserver=null,i.onClickedObservable=new o.c,i._camera=null,i._invProjection=new a.a,i._material=new Wi.a(\"cameraGizmoMaterial\",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new s.a(.5,.5,.5),i._material.specularColor=new s.a(.1,.1,.1),i._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){i._camera&&(i._isHovered=!(!e.pickInfo||-1==i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),i._isHovered&&0===e.event.button&&i.onClickedObservable.notifyObservers(i._camera))}),Ne.a.POINTERDOWN),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"displayFrustum\",{get:function(){return this._cameraLinesMesh.isEnabled()},set:function(e){this._cameraLinesMesh.setEnabled(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"camera\",{get:function(){return this._camera},set:function(e){var i=this;if(this._camera=e,this.attachedNode=e,e){this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._cameraMesh=t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),this._cameraLinesMesh=t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene),this._cameraMesh.getChildMeshes(!1).forEach((function(e){e.material=i._material})),this._cameraMesh.parent=this._rootMesh,this._cameraLinesMesh.parent=this._rootMesh,this.gizmoLayer.utilityLayerScene.activeCamera&&this.gizmoLayer.utilityLayerScene.activeCamera.maxZ<1.5*e.maxZ&&(this.gizmoLayer.utilityLayerScene.activeCamera.maxZ=1.5*e.maxZ),this.attachedNode.reservedDataStore||(this.attachedNode.reservedDataStore={}),this.attachedNode.reservedDataStore.cameraGizmo=this;var n=this.gizmoLayer._getSharedGizmoLight();n.includedOnlyMeshes=n.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)),this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"material\",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._update=function(){e.prototype._update.call(this),this._camera&&(this._camera.getProjectionMatrix().invertToRef(this._invProjection),this._cameraLinesMesh.setPivotMatrix(this._invProjection,!1),this._cameraLinesMesh.scaling.x=1/this._rootMesh.scaling.x,this._cameraLinesMesh.scaling.y=1/this._rootMesh.scaling.y,this._cameraLinesMesh.scaling.z=1/this._rootMesh.scaling.z,this._cameraMesh.parent=null,this._cameraMesh.rotation.y=.5*Math.PI*(this._camera.getScene().useRightHandedSystem?1:-1),this._cameraMesh.parent=this._rootMesh)},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._material.dispose(),e.prototype.dispose.call(this)},t._CreateCameraMesh=function(e){var i=new be.a(\"rootCameraGizmo\",e),n=new be.a(i.name,e);n.parent=i,Ar.a.CreateBox(i.name,{width:1,height:.8,depth:.5},e).parent=n;var r=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.8,diameterBottom:.8},e);r.parent=n,r.position.y=.3,r.position.x=-.6,r.rotation.x=.5*Math.PI;var o=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.6,diameterBottom:.6},e);o.parent=n,o.position.y=.5,o.position.x=.4,o.rotation.x=.5*Math.PI;var a=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.5,diameterBottom:.5},e);return a.parent=n,a.position.y=0,a.position.x=.6,a.rotation.z=.5*Math.PI,i.scaling.scaleInPlace(t._Scale),n.position.x=-.9,i},t._CreateCameraFrustum=function(e){var t=new be.a(\"rootCameraGizmo\",e),i=new be.a(t.name,e);i.parent=t;for(var n=0;n<4;n+=2)for(var r=0;r<4;r+=2){var o;(o=Or.a.CreateLines(\"lines\",{points:[new a.e(-1+r,-1+n,-1),new a.e(-1+r,-1+n,1)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Or.a.CreateLines(\"lines\",{points:[new a.e(-1,-1+r,-1+n),new a.e(1,-1+r,-1+n)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Or.a.CreateLines(\"lines\",{points:[new a.e(-1+r,-1,-1+n),new a.e(-1+r,1,-1+n)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1}return t},t._Scale=.05,t}(Pr.a);ai.a.IncludesShadersStore.kernelBlurVaryingDeclaration=\"varying vec2 sampleCoord{X};\";var Qr=\"vec4 pack(float depth)\\n{\\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\\nvec4 res=fract(depth*bit_shift);\\nres-=res.xxyz*bit_mask;\\nreturn res;\\n}\\nfloat unpack(vec4 color)\\n{\\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\\nreturn dot(color,bit_shift);\\n}\";ai.a.IncludesShadersStore.packingFunctions=Qr;var qr=\"#ifdef DOF\\nfactor=sampleCoC(sampleCoord{X});\\ncomputedWeight=KERNEL_WEIGHT{X}*factor;\\nsumOfWeights+=computedWeight;\\n#else\\ncomputedWeight=KERNEL_WEIGHT{X};\\n#endif\\n#ifdef PACKEDFLOAT\\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\\n#else\\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\\n#endif\";ai.a.IncludesShadersStore.kernelBlurFragment=qr;var Zr=\"#ifdef DOF\\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});\\ncomputedWeight=KERNEL_DEP_WEIGHT{X}*factor;\\nsumOfWeights+=computedWeight;\\n#else\\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\\n#endif\\n#ifdef PACKEDFLOAT\\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\\n#else\\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\\n#endif\";ai.a.IncludesShadersStore.kernelBlurFragment2=Zr;var Jr=\"\\nuniform sampler2D textureSampler;\\nuniform vec2 delta;\\n\\nvarying vec2 sampleCenter;\\n#ifdef DOF\\nuniform sampler2D circleOfConfusionSampler;\\nuniform vec2 cameraMinMaxZ;\\nfloat sampleDistance(const in vec2 offset) {\\nfloat depth=texture2D(circleOfConfusionSampler,offset).g;\\nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;\\n}\\nfloat sampleCoC(const in vec2 offset) {\\nfloat coc=texture2D(circleOfConfusionSampler,offset).r;\\nreturn coc;\\n}\\n#endif\\n#include[0..varyingCount]\\n#ifdef PACKEDFLOAT\\n#include\\n#endif\\nvoid main(void)\\n{\\nfloat computedWeight=0.0;\\n#ifdef PACKEDFLOAT\\nfloat blend=0.;\\n#else\\nvec4 blend=vec4(0.);\\n#endif\\n#ifdef DOF\\nfloat sumOfWeights=CENTER_WEIGHT;\\nfloat factor=0.0;\\n\\n#ifdef PACKEDFLOAT\\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\\n#else\\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\\n#endif\\n#endif\\n#include[0..varyingCount]\\n#include[0..depCount]\\n#ifdef PACKEDFLOAT\\ngl_FragColor=pack(blend);\\n#else\\ngl_FragColor=blend;\\n#endif\\n#ifdef DOF\\ngl_FragColor/=sumOfWeights;\\n#endif\\n}\";ai.a.ShadersStore.kernelBlurPixelShader=Jr;ai.a.IncludesShadersStore.kernelBlurVertex=\"sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};\";var $r=\"\\nattribute vec2 position;\\n\\nuniform vec2 delta;\\n\\nvarying vec2 sampleCenter;\\n#include[0..varyingCount]\\nconst vec2 madd=vec2(0.5,0.5);\\nvoid main(void) {\\nsampleCenter=(position*madd+madd);\\n#include[0..varyingCount]\\ngl_Position=vec4(position,0.0,1.0);\\n}\";ai.a.ShadersStore.kernelBlurVertexShader=$r;var eo=function(e){function t(t,i,n,r,o,a,s,c,l,u,h){void 0===a&&(a=Ke.a.BILINEAR_SAMPLINGMODE),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=\"\"),void 0===h&&(h=!1);var d=e.call(this,t,\"kernelBlur\",[\"delta\",\"direction\",\"cameraMinMaxZ\"],[\"circleOfConfusionSampler\"],r,o,a,s,c,null,l,\"kernelBlur\",{varyingCount:0,depCount:0},!0)||this;return d.blockCompilation=h,d._packedFloat=!1,d._staticDefines=\"\",d._staticDefines=u,d.direction=i,d.onApplyObservable.add((function(e){d._outputTexture?e.setFloat2(\"delta\",1/d._outputTexture.width*d.direction.x,1/d._outputTexture.height*d.direction.y):e.setFloat2(\"delta\",1/d.width*d.direction.x,1/d.height*d.direction.y)})),d.kernel=n,d}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"kernel\",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.blockCompilation||this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"packedFloat\",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this.blockCompilation||this._updateParameters())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"BlurPostProcess\"},t.prototype.updateEffect=function(e,t,i,n,r,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._updateParameters(r,o)},t.prototype._updateParameters=function(t,i){for(var n=this._kernel,r=(n-1)/2,o=[],a=[],s=0,c=0;c0)return Math.max(r,3)}return Math.max(t,3)},t.prototype._gaussianWeight=function(e){var t=-e*e/(1/3*2*(1/3));return 1/(Math.sqrt(2*Math.PI)*(1/3))*Math.exp(t)},t.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,\"\")},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.direction,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,void 0,!1)}),e,n,r)},Object(h.c)([Object(w.c)(\"kernel\")],t.prototype,\"_kernel\",void 0),Object(h.c)([Object(w.c)(\"packedFloat\")],t.prototype,\"_packedFloat\",void 0),Object(h.c)([Object(w.n)()],t.prototype,\"direction\",void 0),t}(li);c.a.RegisteredTypes[\"BABYLON.BlurPostProcess\"]=eo;var to=function(e){function t(t,i,n,r,o,s,c){void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=Ke.a.BILINEAR_SAMPLINGMODE),void 0===c&&(c=!0);var l=e.call(this,t,i,n,r,!0,o,!1,s,c)||this;return l.scene=n,l.mirrorPlane=new fn.a(0,1,0,1),l._transformMatrix=a.a.Zero(),l._mirrorMatrix=a.a.Zero(),l._adaptiveBlurKernel=0,l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.ignoreCameraViewport=!0,l._updateGammaSpace(),l._imageProcessingConfigChangeObserver=n.imageProcessingConfiguration.onUpdateParameters.add((function(){l._updateGammaSpace})),l.onBeforeRenderObservable.add((function(){a.a.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=n.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),n.setTransformMatrix(l._transformMatrix,n.getProjectionMatrix()),n.clipPlane=l.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=a.e.TransformCoordinates(n.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){n.setTransformMatrix(l._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,n.clipPlane=null})),l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"blurRatio\",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"adaptiveBlurKernel\",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"blurKernel\",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"blurKernelX\",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"blurKernelY\",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),t.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*i},t.prototype._onRatioRescale=function(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()},t.prototype._updateGammaSpace=function(){this.gammaSpace=!this.scene.imageProcessingConfiguration.isEnabled||!this.scene.imageProcessingConfiguration.applyByPostProcess},t.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var e=this.getScene().getEngine(),t=e.getCaps().textureFloatRender?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_HALF_FLOAT;this._blurX=new eo(\"horizontal blur\",new a.d(1,0),this._blurKernelX,this._blurRatio,null,Ke.a.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.inputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new eo(\"vertical blur\",new a.d(0,1),this._blurKernelY,this._blurRatio,null,Ke.a.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}else this._blurY&&(this.removePostProcess(this._blurY),this._blurY.dispose(),this._blurY=null),this._blurX&&(this.removePostProcess(this._blurX),this._blurX.dispose(),this._blurX=null)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),n=new t(this.name,i.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(n.renderList=this.renderList.slice(0)),n},t.prototype.serialize=function(){if(!this.name)return null;var t=e.prototype.serialize.call(this);return t.mirrorPlane=this.mirrorPlane.asArray(),t},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver)},t}(Ni);Ke.a._CreateMirror=function(e,t,i,n){return new to(e,t,i,n)};var io=i(34),no=function(e){function t(t,i,n,r,s,c,l,u,h,d,f,p,_,m){var v;void 0===n&&(n=null),void 0===r&&(r=!1),void 0===s&&(s=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=g.a.TEXTUREFORMAT_RGBA),void 0===h&&(h=!1),void 0===d&&(d=null),void 0===f&&(f=!1),void 0===p&&(p=.8),void 0===_&&(_=0);var b=e.call(this,i)||this;if(b.onLoadObservable=new o.c,b.boundingBoxPosition=a.e.Zero(),b._rotationY=0,b._files=null,b._forcedExtension=null,b._extensions=null,b.name=t,b.url=t,b._noMipmap=r,b.hasAlpha=!1,b._format=u,b.isCube=!0,b._textureMatrix=a.a.Identity(),b._createPolynomials=f,b.coordinatesMode=Ke.a.CUBIC_MODE,b._extensions=n,b._files=s,b._forcedExtension=d,b._loaderOptions=m,!t&&!s)return b;var y=t.lastIndexOf(\".\"),T=d||(y>-1?t.substring(y).toLowerCase():\"\"),E=\".dds\"===T,S=\".env\"===T;if(S?(b.gammaSpace=!1,b._prefiltered=!1,b.anisotropicFilteringLevel=1):(b._prefiltered=h,h&&(b.gammaSpace=!1,b.anisotropicFilteringLevel=1)),b._texture=b._getFromCache(t,r),!s&&(S||E||n||(n=[\"_px.jpg\",\"_py.jpg\",\"_pz.jpg\",\"_nx.jpg\",\"_ny.jpg\",\"_nz.jpg\"]),s=[],n))for(var A=0;A\\n#define RECIPROCAL_PI2 0.15915494\\n\\nuniform vec3 vEyePosition;\\n\\nvarying vec3 vPositionW;\\n#ifdef MAINUV1\\nvarying vec2 vMainUV1;\\n#endif\\n#ifdef MAINUV2\\nvarying vec2 vMainUV2;\\n#endif\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef DIFFUSE\\n#if DIFFUSEDIRECTUV == 1\\n#define vDiffuseUV vMainUV1\\n#elif DIFFUSEDIRECTUV == 2\\n#define vDiffuseUV vMainUV2\\n#else\\nvarying vec2 vDiffuseUV;\\n#endif\\nuniform sampler2D diffuseSampler;\\n#endif\\n\\n#ifdef REFLECTION\\n#ifdef REFLECTIONMAP_3D\\n#define sampleReflection(s,c) textureCube(s,c)\\nuniform samplerCube reflectionSampler;\\n#ifdef TEXTURELODSUPPORT\\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\\n#else\\nuniform samplerCube reflectionSamplerLow;\\nuniform samplerCube reflectionSamplerHigh;\\n#endif\\n#else\\n#define sampleReflection(s,c) texture2D(s,c)\\nuniform sampler2D reflectionSampler;\\n#ifdef TEXTURELODSUPPORT\\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\\n#else\\nuniform samplerCube reflectionSamplerLow;\\nuniform samplerCube reflectionSamplerHigh;\\n#endif\\n#endif\\n#ifdef REFLECTIONMAP_SKYBOX\\nvarying vec3 vPositionUVW;\\n#else\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvarying vec3 vDirectionW;\\n#endif\\n#endif\\n#include\\n#endif\\n\\n#ifndef FROMLINEARSPACE\\n#define FROMLINEARSPACE;\\n#endif\\n\\n#ifndef SHADOWONLY\\n#define SHADOWONLY;\\n#endif\\n#include\\n\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include\\n#include\\n#include\\n#include\\n\\n#include\\n#ifdef REFLECTIONFRESNEL\\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\\n{\\n\\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\\n}\\n#endif\\nvoid main(void) {\\n#include\\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\\n\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=vec3(0.0,1.0,0.0);\\n#endif\\n\\nfloat shadow=1.;\\nfloat globalShadow=0.;\\nfloat shadowLightCount=0.;\\n#include[0..maxSimultaneousLights]\\n#ifdef SHADOWINUSE\\nglobalShadow/=shadowLightCount;\\n#else\\nglobalShadow=1.0;\\n#endif\\n#ifndef BACKMAT_SHADOWONLY\\n\\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\\n#ifdef REFLECTION\\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\\n#ifdef REFLECTIONMAP_OPPOSITEZ\\nreflectionVector.z*=-1.0;\\n#endif\\n\\n#ifdef REFLECTIONMAP_3D\\nvec3 reflectionCoords=reflectionVector;\\n#else\\nvec2 reflectionCoords=reflectionVector.xy;\\n#ifdef REFLECTIONMAP_PROJECTION\\nreflectionCoords/=reflectionVector.z;\\n#endif\\nreflectionCoords.y=1.0-reflectionCoords.y;\\n#endif\\n#ifdef REFLECTIONBLUR\\nfloat reflectionLOD=vReflectionInfos.y;\\n#ifdef TEXTURELODSUPPORT\\n\\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\\n#else\\nfloat lodReflectionNormalized=saturate(reflectionLOD);\\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\\nif(lodReflectionNormalizedDoubled<1.0){\\nreflectionColor=mix(\\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\\nreflectionSpecularMid,\\nlodReflectionNormalizedDoubled\\n);\\n} else {\\nreflectionColor=mix(\\nreflectionSpecularMid,\\nsampleReflection(reflectionSamplerLow,reflectionCoords),\\nlodReflectionNormalizedDoubled-1.0\\n);\\n}\\n#endif\\n#else\\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\\nreflectionColor=reflectionSample;\\n#endif\\n#ifdef RGBDREFLECTION\\nreflectionColor.rgb=fromRGBD(reflectionColor);\\n#endif\\n#ifdef GAMMAREFLECTION\\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\\n#endif\\n#ifdef REFLECTIONBGR\\nreflectionColor.rgb=reflectionColor.bgr;\\n#endif\\n\\nreflectionColor.rgb*=vReflectionInfos.x;\\n#endif\\n\\nvec3 diffuseColor=vec3(1.,1.,1.);\\nfloat finalAlpha=alpha;\\n#ifdef DIFFUSE\\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\\n#ifdef GAMMADIFFUSE\\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\\n#endif\\n\\ndiffuseMap.rgb*=vDiffuseInfos.y;\\n#ifdef DIFFUSEHASALPHA\\nfinalAlpha*=diffuseMap.a;\\n#endif\\ndiffuseColor=diffuseMap.rgb;\\n#endif\\n\\n#ifdef REFLECTIONFRESNEL\\nvec3 colorBase=diffuseColor;\\n#else\\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\\n#endif\\ncolorBase=max(colorBase,0.0);\\n\\n#ifdef USERGBCOLOR\\nvec3 finalColor=colorBase;\\n#else\\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\\n#else\\nvec3 mainColor=vPrimaryColor.rgb;\\n#endif\\nvec3 finalColor=colorBase*mainColor;\\n#endif\\n\\n#ifdef REFLECTIONFRESNEL\\nvec3 reflectionAmount=vReflectionControl.xxx;\\nvec3 reflectionReflectance0=vReflectionControl.yyy;\\nvec3 reflectionReflectance90=vReflectionControl.zzz;\\nfloat VdotN=dot(normalize(vEyePosition),normalW);\\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\\nreflectionAmount*=planarReflectionFresnel;\\n#ifdef REFLECTIONFALLOFF\\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\\nreflectionAmount*=reflectionDistanceFalloff;\\n#endif\\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\\n#endif\\n#ifdef OPACITYFRESNEL\\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\\n\\nconst float startAngle=0.1;\\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\\nfinalAlpha*=fadeFactor*fadeFactor;\\n#endif\\n\\n#ifdef SHADOWINUSE\\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\\n#endif\\n\\nvec4 color=vec4(finalColor,finalAlpha);\\n#else\\nvec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);\\n#endif\\n#include\\n#ifdef IMAGEPROCESSINGPOSTPROCESS\\n\\n\\ncolor.rgb=clamp(color.rgb,0.,30.0);\\n#else\\n\\ncolor=applyImageProcessing(color);\\n#endif\\n#ifdef PREMULTIPLYALPHA\\n\\ncolor.rgb*=color.a;\\n#endif\\n#ifdef NOISE\\ncolor.rgb+=dither(vPositionW.xy,0.5);\\ncolor=max(color,0.0);\\n#endif\\ngl_FragColor=color;\\n}\\n\";ai.a.ShadersStore.backgroundPixelShader=uo;var ho=\"uniform mat4 view;\\nuniform mat4 viewProjection;\\nuniform float shadowLevel;\\n#ifdef DIFFUSE\\nuniform mat4 diffuseMatrix;\\nuniform vec2 vDiffuseInfos;\\n#endif\\n#ifdef REFLECTION\\nuniform vec2 vReflectionInfos;\\nuniform mat4 reflectionMatrix;\\nuniform vec3 vReflectionMicrosurfaceInfos;\\nuniform float fFovMultiplier;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\";ai.a.IncludesShadersStore.backgroundVertexDeclaration=ho;i(78),i(79),i(117),i(137),i(80),i(81),i(111),i(157),i(138);var fo=\"precision highp float;\\n#include<__decl__backgroundVertex>\\n#include\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#include\\n\\n#include\\n\\nvarying vec3 vPositionW;\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef MAINUV1\\nvarying vec2 vMainUV1;\\n#endif\\n#ifdef MAINUV2\\nvarying vec2 vMainUV2;\\n#endif\\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\\nvarying vec2 vDiffuseUV;\\n#endif\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#ifdef REFLECTIONMAP_SKYBOX\\nvarying vec3 vPositionUVW;\\n#endif\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvarying vec3 vDirectionW;\\n#endif\\nvoid main(void) {\\n#ifdef REFLECTIONMAP_SKYBOX\\nvPositionUVW=position;\\n#endif\\n#include\\n#include\\n#ifdef MULTIVIEW\\nif (gl_ViewID_OVR == 0u) {\\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\\n} else {\\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\\n}\\n#else\\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\\n#endif\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\nvPositionW=vec3(worldPos);\\n#ifdef NORMAL\\nmat3 normalWorld=mat3(finalWorld);\\n#ifdef NONUNIFORMSCALING\\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\\n#endif\\nvNormalW=normalize(normalWorld*normal);\\n#endif\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\\nif (fFovMultiplier<=1.0) {\\nvDirectionW=normalize(segment);\\n} else {\\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\\n}\\n#endif\\n#endif\\n#ifndef UV1\\nvec2 uv=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef MAINUV1\\nvMainUV1=uv;\\n#endif\\n#ifdef MAINUV2\\nvMainUV2=uv2;\\n#endif\\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\\nif (vDiffuseInfos.x == 0.)\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\\n}\\nelse\\n{\\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n\\n#include\\n\\n#include\\n\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n}\\n\";ai.a.ShadersStore.backgroundVertexShader=fo;var po=i(67),_o=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.GAMMADIFFUSE=!1,t.DIFFUSEHASALPHA=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONBLUR=!1,t.REFLECTIONFRESNEL=!1,t.REFLECTIONFALLOFF=!1,t.TEXTURELODSUPPORT=!1,t.PREMULTIPLYALPHA=!1,t.USERGBCOLOR=!1,t.USEHIGHLIGHTANDSHADOWCOLORS=!1,t.BACKMAT_SHADOWONLY=!1,t.NOISE=!1,t.REFLECTIONBGR=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.MULTIVIEW=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.EQUIRECTANGULAR_RELFECTION_FOV=!1,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.SHADOWFLOAT=!1,t.rebuild(),t}return Object(h.d)(t,e),t}(oo.a),mo=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.primaryColor=s.a.White(),n._primaryColorShadowLevel=0,n._primaryColorHighlightLevel=0,n.reflectionTexture=null,n.reflectionBlur=0,n.diffuseTexture=null,n._shadowLights=null,n.shadowLights=null,n.shadowLevel=0,n.sceneCenter=a.e.Zero(),n.opacityFresnel=!0,n.reflectionFresnel=!1,n.reflectionFalloffDistance=0,n.reflectionAmount=1,n.reflectionReflectance0=.05,n.reflectionReflectance90=.5,n.useRGBColor=!0,n.enableNoise=!1,n._fovMultiplier=1,n.useEquirectangularFOV=!1,n._maxSimultaneousLights=4,n.maxSimultaneousLights=4,n._shadowOnly=!1,n.shadowOnly=!1,n._imageProcessingObserver=null,n.switchToBGR=!1,n._renderTargets=new oi.a(16),n._reflectionControls=a.f.Zero(),n._white=s.a.White(),n._primaryShadowColor=s.a.Black(),n._primaryHighlightColor=s.a.Black(),n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),n._diffuseTexture&&n._diffuseTexture.isRenderTarget&&n._renderTargets.push(n._diffuseTexture),n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),n._renderTargets},n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"_perceptualColor\",{get:function(){return this.__perceptualColor},set:function(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"primaryColorShadowLevel\",{get:function(){return this._primaryColorShadowLevel},set:function(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"primaryColorHighlightLevel\",{get:function(){return this._primaryColorHighlightLevel},set:function(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"reflectionStandardFresnelWeight\",{set:function(e){var i=e;i<.5?(i*=2,this.reflectionReflectance0=t.StandardReflectance0*i,this.reflectionReflectance90=t.StandardReflectance90*i):(i=2*i-1,this.reflectionReflectance0=t.StandardReflectance0+(1-t.StandardReflectance0)*i,this.reflectionReflectance90=t.StandardReflectance90+(1-t.StandardReflectance90)*i)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"fovMultiplier\",{get:function(){return this._fovMultiplier},set:function(e){isNaN(e)&&(e=1),this._fovMultiplier=Math.max(0,Math.min(2,e))},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){t._computePrimaryColorFromPerceptualColor(),t._markAllSubMeshesAsImageProcessingDirty()}))))},Object.defineProperty(t.prototype,\"imageProcessingConfiguration\",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraColorCurvesEnabled\",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraColorGradingEnabled\",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraToneMappingEnabled\",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraExposure\",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraContrast\",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraColorGradingTexture\",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraColorCurves\",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"hasRenderTargetTextures\",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!1,configurable:!0}),t.prototype.needAlphaTesting=function(){return!0},t.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha||this._shadowOnly},t.prototype.isReadyForSubMesh=function(e,t,i){var n=this;if(void 0===i&&(i=!1),t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new _o);var r=this.getScene(),o=t._materialDefines;if(this._isReadyForSubMesh(t))return!0;var a=r.getEngine();if(ro.a.PrepareDefinesForLights(r,e,o,!1,this._maxSimultaneousLights),o._needNormals=!0,ro.a.PrepareDefinesForMultiview(r,o),o._areTexturesDirty){if(o._needUVs=!1,r.texturesEnabled){if(r.getEngine().getCaps().textureLOD&&(o.TEXTURELODSUPPORT=!0),this._diffuseTexture&&so.a.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;ro.a.PrepareDefinesForMergedUV(this._diffuseTexture,o,\"DIFFUSE\"),o.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,o.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,o.OPACITYFRESNEL=this._opacityFresnel}else o.DIFFUSE=!1,o.DIFFUSEHASALPHA=!1,o.GAMMADIFFUSE=!1,o.OPACITYFRESNEL=!1;var s=this._reflectionTexture;if(s&&so.a.ReflectionTextureEnabled){if(!s.isReadyOrNotBlocking())return!1;switch(o.REFLECTION=!0,o.GAMMAREFLECTION=s.gammaSpace,o.RGBDREFLECTION=s.isRGBD,o.REFLECTIONBLUR=this._reflectionBlur>0,o.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,o.LODINREFLECTIONALPHA=s.lodLevelInAlpha,o.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,o.REFLECTIONBGR=this.switchToBGR,s.coordinatesMode===Ke.a.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=s.isCube,s.coordinatesMode){case Ke.a.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case Ke.a.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case Ke.a.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case Ke.a.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0;break;case Ke.a.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case Ke.a.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ke.a.CUBIC_MODE:case Ke.a.INVCUBIC_MODE:default:o.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(o.REFLECTIONFRESNEL=!0,o.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=1/this.reflectionFalloffDistance):(o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1)}else o.REFLECTION=!1,o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1,o.REFLECTIONBLUR=!1,o.REFLECTIONMAP_3D=!1,o.REFLECTIONMAP_SPHERICAL=!1,o.REFLECTIONMAP_PLANAR=!1,o.REFLECTIONMAP_CUBIC=!1,o.REFLECTIONMAP_PROJECTION=!1,o.REFLECTIONMAP_SKYBOX=!1,o.REFLECTIONMAP_EXPLICIT=!1,o.REFLECTIONMAP_EQUIRECTANGULAR=!1,o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,o.INVERTCUBICMAP=!1,o.REFLECTIONMAP_OPPOSITEZ=!1,o.LODINREFLECTIONALPHA=!1,o.GAMMAREFLECTION=!1,o.RGBDREFLECTION=!1}o.PREMULTIPLYALPHA=this.alphaMode===g.a.ALPHA_PREMULTIPLIED||this.alphaMode===g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.USERGBCOLOR=this._useRGBColor,o.NOISE=this._enableNoise}if(o._areLightsDirty&&(o.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel),o.BACKMAT_SHADOWONLY=this._shadowOnly),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o)}if(ro.a.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),ro.a.PrepareDefinesForFrameBoundValues(r,a,o,i,null,t.getRenderingMesh().hasThinInstances),ro.a.PrepareDefinesForAttributes(e,o,!1,!0,!1)&&e&&(r.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(Qi.b.NormalKind)||(e.createNormals(!0),m.a.Warn(\"BackgroundMaterial: Normals have been created for the mesh: \"+e.name))),o.isDirty){o.markAsProcessed(),r.resetCachedMaterial();var c=new po.a;o.FOG&&c.addFallback(0,\"FOG\"),o.POINTSIZE&&c.addFallback(1,\"POINTSIZE\"),o.MULTIVIEW&&c.addFallback(0,\"MULTIVIEW\"),ro.a.HandleFallbacksForShadows(o,c,this._maxSimultaneousLights);var l=[Qi.b.PositionKind];o.NORMAL&&l.push(Qi.b.NormalKind),o.UV1&&l.push(Qi.b.UVKind),o.UV2&&l.push(Qi.b.UV2Kind),ro.a.PrepareAttributesForBones(l,e,o,c),ro.a.PrepareAttributesForInstances(l,o);var u=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"mBones\",\"vPrimaryColor\",\"vPrimaryColorShadow\",\"vReflectionInfos\",\"reflectionMatrix\",\"vReflectionMicrosurfaceInfos\",\"fFovMultiplier\",\"shadowLevel\",\"alpha\",\"vBackgroundCenter\",\"vReflectionControl\",\"vDiffuseInfos\",\"diffuseMatrix\"],h=[\"diffuseSampler\",\"reflectionSampler\",\"reflectionSamplerLow\",\"reflectionSamplerHigh\"],d=[\"Material\",\"Scene\"];ji.a&&(ji.a.PrepareUniforms(u,o),ji.a.PrepareSamplers(h,o)),ro.a.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var f=o.toString();t.setEffect(r.getEngine().createEffect(\"background\",{attributes:l,uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:f,fallbacks:c,onCompiled:function(e){n.onCompiled&&n.onCompiled(e),n.bindSceneUniformBuffer(e,r.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a),o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=r.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype._computePrimaryColorFromPerceptualColor=function(){this.__perceptualColor&&(this._primaryColor.copyFrom(this.__perceptualColor),this._primaryColor.toLinearSpaceToRef(this._primaryColor),this._imageProcessingConfiguration&&this._primaryColor.scaleToRef(1/this._imageProcessingConfiguration.exposure,this._primaryColor),this._computePrimaryColors())},t.prototype._computePrimaryColors=function(){0===this._primaryColorShadowLevel&&0===this._primaryColorHighlightLevel||(this._primaryColor.scaleToRef(this._primaryColorShadowLevel,this._primaryShadowColor),this._primaryColor.subtractToRef(this._primaryShadowColor,this._primaryShadowColor),this._white.subtractToRef(this._primaryColor,this._primaryHighlightColor),this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel,this._primaryHighlightColor),this._primaryColor.addToRef(this._primaryHighlightColor,this._primaryHighlightColor))},t.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform(\"vPrimaryColor\",4),this._uniformBuffer.addUniform(\"vPrimaryColorShadow\",4),this._uniformBuffer.addUniform(\"vDiffuseInfos\",2),this._uniformBuffer.addUniform(\"vReflectionInfos\",2),this._uniformBuffer.addUniform(\"diffuseMatrix\",16),this._uniformBuffer.addUniform(\"reflectionMatrix\",16),this._uniformBuffer.addUniform(\"vReflectionMicrosurfaceInfos\",3),this._uniformBuffer.addUniform(\"fFovMultiplier\",1),this._uniformBuffer.addUniform(\"pointSize\",1),this._uniformBuffer.addUniform(\"shadowLevel\",1),this._uniformBuffer.addUniform(\"alpha\",1),this._uniformBuffer.addUniform(\"vBackgroundCenter\",3),this._uniformBuffer.addUniform(\"vReflectionControl\",4),this._uniformBuffer.create()},t.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture(\"diffuseSampler\",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture(\"reflectionSampler\",null),e.prototype.unbind.call(this)},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix(\"world\",e)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),r=i._materialDefines;if(r){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),ro.a.BindBonesParameters(t,this._activeEffect);var a=this._mustRebind(n,o,t.visibility);if(a){this._uniformBuffer.bindToEffect(o,\"Material\"),this.bindViewProjection(o);var s=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(n.texturesEnabled&&(this._diffuseTexture&&so.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2(\"vDiffuseInfos\",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),ro.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,\"diffuse\")),s&&so.a.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix(\"reflectionMatrix\",s.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2(\"vReflectionInfos\",s.level,this._reflectionBlur),this._uniformBuffer.updateFloat3(\"vReflectionMicrosurfaceInfos\",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat(\"shadowLevel\",this.shadowLevel),this._uniformBuffer.updateFloat(\"alpha\",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat(\"pointSize\",this.pointSize),r.USEHIGHLIGHTANDSHADOWCOLORS?(this._uniformBuffer.updateColor4(\"vPrimaryColor\",this._primaryHighlightColor,1),this._uniformBuffer.updateColor4(\"vPrimaryColorShadow\",this._primaryShadowColor,1)):this._uniformBuffer.updateColor4(\"vPrimaryColor\",this._primaryColor,1)),this._uniformBuffer.updateFloat(\"fFovMultiplier\",this._fovMultiplier),n.texturesEnabled&&(this._diffuseTexture&&so.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture(\"diffuseSampler\",this._diffuseTexture),s&&so.a.ReflectionTextureEnabled&&(r.REFLECTIONBLUR&&r.TEXTURELODSUPPORT?this._uniformBuffer.setTexture(\"reflectionSampler\",s):r.REFLECTIONBLUR?(this._uniformBuffer.setTexture(\"reflectionSampler\",s._lodTextureMid||s),this._uniformBuffer.setTexture(\"reflectionSamplerLow\",s._lodTextureLow||s),this._uniformBuffer.setTexture(\"reflectionSamplerHigh\",s._lodTextureHigh||s)):this._uniformBuffer.setTexture(\"reflectionSampler\",s),r.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3(\"vBackgroundCenter\",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4(\"vReflectionControl\",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w)))),ro.a.BindClipPlane(this._activeEffect,n),ro.a.BindEyePosition(o,n)}!a&&this.isFrozen||(n.lightsEnabled&&ro.a.BindLights(n,t,this._activeEffect,r,this._maxSimultaneousLights,!1),this.bindView(o),ro.a.BindFogParameters(n,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._reflectionTexture===t||this._diffuseTexture===t)},t.prototype.dispose=function(t,i){void 0===t&&(t=!1),void 0===i&&(i=!1),i&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return w.a.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType=\"BABYLON.BackgroundMaterial\",e},t.prototype.getClassName=function(){return\"BackgroundMaterial\"},t.Parse=function(e,i,n){return w.a.Parse((function(){return new t(e.name,i)}),e,i,n)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,Object(h.c)([Object(w.e)()],t.prototype,\"_primaryColor\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"primaryColor\",void 0),Object(h.c)([Object(w.e)()],t.prototype,\"__perceptualColor\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_primaryColorShadowLevel\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_primaryColorHighlightLevel\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"primaryColorHighlightLevel\",null),Object(h.c)([Object(w.m)()],t.prototype,\"_reflectionTexture\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionTexture\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_reflectionBlur\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionBlur\",void 0),Object(h.c)([Object(w.m)()],t.prototype,\"_diffuseTexture\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"diffuseTexture\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"shadowLights\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_shadowLevel\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"shadowLevel\",void 0),Object(h.c)([Object(w.o)()],t.prototype,\"_sceneCenter\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"sceneCenter\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_opacityFresnel\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"opacityFresnel\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_reflectionFresnel\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionFresnel\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_reflectionFalloffDistance\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionFalloffDistance\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_reflectionAmount\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionAmount\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_reflectionReflectance0\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionReflectance0\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_reflectionReflectance90\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionReflectance90\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_useRGBColor\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useRGBColor\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_enableNoise\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"enableNoise\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_maxSimultaneousLights\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_shadowOnly\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"shadowOnly\",void 0),Object(h.c)([Object(w.i)()],t.prototype,\"_imageProcessingConfiguration\",void 0),t}(ao.a);c.a.RegisteredTypes[\"BABYLON.BackgroundMaterial\"]=mo;var go=function(){function e(t,i){var n=this;this._errorHandler=function(e,t){n.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=Object(h.a)(Object(h.a)({},e._getDefaultOptions()),t),this._scene=i,this.onErrorObservable=new o.c,this._setupBackground(),this._setupImageProcessing()}return e._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new s.a(.2,.2,.3).toLinearSpace().scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:g.a.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new s.a(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:a.e.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(e.prototype,\"rootMesh\",{get:function(){return this._rootMesh},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"skybox\",{get:function(){return this._skybox},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"skyboxTexture\",{get:function(){return this._skyboxTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"skyboxMaterial\",{get:function(){return this._skyboxMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"ground\",{get:function(){return this._ground},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"groundTexture\",{get:function(){return this._groundTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"groundMirror\",{get:function(){return this._groundMirror},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"groundMirrorRenderList\",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"groundMaterial\",{get:function(){return this._groundMaterial},enumerable:!1,configurable:!0}),e.prototype.updateOptions=function(e){var t=Object(h.a)(Object(h.a)({},this._options),e);this._ground&&!t.createGround&&(this._ground.dispose(),this._ground=null),this._groundMaterial&&!t.createGround&&(this._groundMaterial.dispose(),this._groundMaterial=null),this._groundTexture&&this._options.groundTexture!=t.groundTexture&&(this._groundTexture.dispose(),this._groundTexture=null),this._skybox&&!t.createSkybox&&(this._skybox.dispose(),this._skybox=null),this._skyboxMaterial&&!t.createSkybox&&(this._skyboxMaterial.dispose(),this._skyboxMaterial=null),this._skyboxTexture&&this._options.skyboxTexture!=t.skyboxTexture&&(this._skyboxTexture.dispose(),this._skyboxTexture=null),this._groundMirror&&!t.enableGroundMirror&&(this._groundMirror.dispose(),this._groundMirror=null),this._scene.environmentTexture&&this._options.environmentTexture!=t.environmentTexture&&this._scene.environmentTexture.dispose(),this._options=t,this._setupBackground(),this._setupImageProcessing()},e.prototype.setMainColor=function(e){this.groundMaterial&&(this.groundMaterial.primaryColor=e),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=e),this.groundMirror&&(this.groundMirror.clearColor=new s.b(e.r,e.g,e.b,1))},e.prototype._setupImageProcessing=function(){this._options.setupImageProcessing&&(this._scene.imageProcessingConfiguration.contrast=this._options.cameraContrast,this._scene.imageProcessingConfiguration.exposure=this._options.cameraExposure,this._scene.imageProcessingConfiguration.toneMappingEnabled=this._options.toneMappingEnabled,this._setupEnvironmentTexture())},e.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof Zn.a)this._scene.environmentTexture=this._options.environmentTexture;else{var e=no.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new be.a(\"BackgroundHelper\",this._scene)),this._rootMesh.rotation.y=this._options.backgroundYRotation;var e=this._getSceneSize();this._options.createGround&&(this._setupGround(e),this._setupGroundMaterial(),this._setupGroundDiffuseTexture(),this._options.enableGroundMirror&&this._setupGroundMirrorTexture(e),this._setupMirrorInGroundMaterial()),this._options.createSkybox&&(this._setupSkybox(e),this._setupSkyboxMaterial(),this._setupSkyboxReflectionTexture()),this._rootMesh.position.x=e.rootPosition.x,this._rootMesh.position.z=e.rootPosition.z,this._rootMesh.position.y=e.rootPosition.y},e.prototype._getSceneSize=function(){var e=this,t=this._options.groundSize,i=this._options.skyboxSize,n=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:t,skyboxSize:i,rootPosition:n};var r=this._scene.getWorldExtends((function(t){return t!==e._ground&&t!==e._rootMesh&&t!==e._skybox})),o=r.max.subtract(r.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof Bt&&this._scene.activeCamera.upperRadiusLimit&&(i=t=2*this._scene.activeCamera.upperRadiusLimit);var a=o.length();a>t&&(i=t=2*a),t*=1.1,i*=1.5,(n=r.min.add(o.scale(.5))).y=r.min.y-this._options.groundYBias}return{groundSize:t,skyboxSize:i,rootPosition:n}},e.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=be.a.CreatePlane(\"BackgroundPlane\",e.groundSize,this._scene),this._ground.rotation.x=Math.PI/2,this._ground.parent=this._rootMesh,this._ground.onDisposeObservable.add((function(){t._ground=null}))),this._ground.receiveShadows=this._options.enableGroundShadow},e.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new mo(\"BackgroundPlaneMaterial\",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,this._groundMaterial.shadowLevel=this._options.groundShadowLevel,this._groundMaterial.primaryColor=this._options.groundColor,this._groundMaterial.useRGBColor=!1,this._groundMaterial.enableNoise=!0,this._ground&&(this._ground.material=this._groundMaterial)},e.prototype._setupGroundDiffuseTexture=function(){this._groundMaterial&&(this._groundTexture||(this._options.groundTexture instanceof Zn.a?this._groundMaterial.diffuseTexture=this._options.groundTexture:(this._groundTexture=new Ke.a(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._groundTexture.gammaSpace=!1,this._groundTexture.hasAlpha=!0,this._groundMaterial.diffuseTexture=this._groundTexture)))},e.prototype._setupGroundMirrorTexture=function(e){var t=Ke.a.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new to(\"BackgroundPlaneMirrorTexture\",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Ke.a.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new fn.a(0,-1,0,e.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=t,this._groundMirror.wrapV=t,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var i=0;i0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)},e.prototype.dispose=function(e){var t,i,n,r;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._textureRoughness)||void 0===i||i.dispose(),null===(n=this._bumpTexture)||void 0===n||n.dispose(),null===(r=this._tintTexture)||void 0===r||r.dispose())},e.prototype.getClassName=function(){return\"PBRClearCoatConfiguration\"},e.AddFallbacks=function(e,t,i){return e.CLEARCOAT_BUMP&&t.addFallback(i++,\"CLEARCOAT_BUMP\"),e.CLEARCOAT_TINT&&t.addFallback(i++,\"CLEARCOAT_TINT\"),e.CLEARCOAT&&t.addFallback(i++,\"CLEARCOAT\"),i},e.AddUniforms=function(e){e.push(\"vClearCoatTangentSpaceParams\",\"vClearCoatParams\",\"vClearCoatRefractionParams\",\"vClearCoatTintParams\",\"clearCoatColorAtDistance\",\"clearCoatMatrix\",\"clearCoatRoughnessMatrix\",\"clearCoatBumpMatrix\",\"clearCoatTintMatrix\",\"vClearCoatInfos\",\"vClearCoatBumpInfos\",\"vClearCoatTintInfos\")},e.AddSamplers=function(e){e.push(\"clearCoatSampler\",\"clearCoatRoughnessSampler\",\"clearCoatBumpSampler\",\"clearCoatTintSampler\")},e.PrepareUniformBuffer=function(e){e.addUniform(\"vClearCoatParams\",2),e.addUniform(\"vClearCoatRefractionParams\",4),e.addUniform(\"vClearCoatInfos\",4),e.addUniform(\"clearCoatMatrix\",16),e.addUniform(\"clearCoatRoughnessMatrix\",16),e.addUniform(\"vClearCoatBumpInfos\",2),e.addUniform(\"vClearCoatTangentSpaceParams\",2),e.addUniform(\"clearCoatBumpMatrix\",16),e.addUniform(\"vClearCoatTintParams\",4),e.addUniform(\"clearCoatColorAtDistance\",1),e.addUniform(\"vClearCoatTintInfos\",2),e.addUniform(\"clearCoatTintMatrix\",16)},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},e._DefaultIndexOfRefraction=1.5,Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"isEnabled\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"intensity\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"roughness\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"indexOfRefraction\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"texture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"useRoughnessFromMainTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"textureRoughness\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"remapF0OnInterfaceChange\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"bumpTexture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"isTintEnabled\",void 0),Object(h.c)([Object(w.e)()],e.prototype,\"tintColor\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"tintColorAtDistance\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"tintThickness\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"tintTexture\",void 0),e}(),So=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new a.d(1,0),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){return!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&so.a.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!t.isVerticesDataPresent(Qi.b.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&i.texturesEnabled&&(this._texture&&so.a.AnisotropicTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._texture,e,\"ANISOTROPIC_TEXTURE\"):e.ANISOTROPIC_TEXTURE=!1)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1)},e.prototype.bindForSubMesh=function(e,t,i){e.useUbo&&i&&e.isSync||(this._texture&&so.a.AnisotropicTextureEnabled&&(e.updateFloat2(\"vAnisotropyInfos\",this._texture.coordinatesIndex,this._texture.level),ro.a.BindTextureMatrix(this._texture,e,\"anisotropy\")),e.updateFloat3(\"vAnisotropy\",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&so.a.AnisotropicTextureEnabled&&e.setTexture(\"anisotropySampler\",this._texture)},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},e.prototype.getClassName=function(){return\"PBRAnisotropicConfiguration\"},e.AddFallbacks=function(e,t,i){return e.ANISOTROPIC&&t.addFallback(i++,\"ANISOTROPIC\"),i},e.AddUniforms=function(e){e.push(\"vAnisotropy\",\"vAnisotropyInfos\",\"anisotropyMatrix\")},e.PrepareUniformBuffer=function(e){e.addUniform(\"vAnisotropy\",3),e.addUniform(\"vAnisotropyInfos\",2),e.addUniform(\"anisotropyMatrix\",16)},e.AddSamplers=function(e){e.push(\"anisotropySampler\")},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"isEnabled\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"intensity\",void 0),Object(h.c)([Object(w.n)()],e.prototype,\"direction\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"texture\",void 0),e}(),Ao=function(){function e(t){this._useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._internalMarkAllSubMeshesAsMiscDirty=t}return e.prototype._markAllSubMeshesAsMiscDirty=function(){this._internalMarkAllSubMeshesAsMiscDirty()},e.prototype.prepareDefines=function(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation},e.prototype.getClassName=function(){return\"PBRBRDFConfiguration\"},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},e.DEFAULT_USE_ENERGY_CONSERVATION=!0,e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0,e.DEFAULT_USE_SPHERICAL_HARMONICS=!0,e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0,Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsMiscDirty\")],e.prototype,\"useEnergyConservation\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsMiscDirty\")],e.prototype,\"useSmithVisibilityHeightCorrelated\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsMiscDirty\")],e.prototype,\"useSphericalHarmonics\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsMiscDirty\")],e.prototype,\"useSpecularGlossinessInputEnergyConservation\",void 0),e}(),Po=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=s.a.White(),this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._roughness=null,this.roughness=null,this._textureRoughness=null,this.textureRoughness=null,this._albedoScaling=!1,this.albedoScaling=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&so.a.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&so.a.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){var i;this._isEnabled?(e.SHEEN=this._isEnabled,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=null!==this._roughness,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=null!==this._texture&&this._texture._texture===(null===(i=this._textureRoughness)||void 0===i?void 0:i._texture)&&this._texture.checkTransformsAreIdentical(this._textureRoughness),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&so.a.SheenTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._texture,e,\"SHEEN_TEXTURE\"):e.SHEEN_TEXTURE=!1,this._textureRoughness&&so.a.SheenTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._textureRoughness,e,\"SHEEN_TEXTURE_ROUGHNESS\"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=!1)},e.prototype.bindForSubMesh=function(e,t,i,n){var r,o,a,s,c,l,u,h,d=n._materialDefines,f=d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;e.useUbo&&i&&e.isSync||(f&&so.a.SheenTextureEnabled?(e.updateFloat4(\"vSheenInfos\",this._texture.coordinatesIndex,this._texture.level,-1,-1),ro.a.BindTextureMatrix(this._texture,e,\"sheen\")):(this._texture||this._textureRoughness)&&so.a.SheenTextureEnabled&&(e.updateFloat4(\"vSheenInfos\",null!==(o=null===(r=this._texture)||void 0===r?void 0:r.coordinatesIndex)&&void 0!==o?o:0,null!==(s=null===(a=this._texture)||void 0===a?void 0:a.level)&&void 0!==s?s:0,null!==(l=null===(c=this._textureRoughness)||void 0===c?void 0:c.coordinatesIndex)&&void 0!==l?l:0,null!==(h=null===(u=this._textureRoughness)||void 0===u?void 0:u.level)&&void 0!==h?h:0),this._texture&&ro.a.BindTextureMatrix(this._texture,e,\"sheen\"),!this._textureRoughness||f||d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE||ro.a.BindTextureMatrix(this._textureRoughness,e,\"sheenRoughness\")),e.updateFloat4(\"vSheenColor\",this.color.r,this.color.g,this.color.b,this.intensity),null!==this._roughness&&e.updateFloat(\"vSheenRoughness\",this._roughness)),t.texturesEnabled&&(this._texture&&so.a.SheenTextureEnabled&&e.setTexture(\"sheenSampler\",this._texture),this._textureRoughness&&!f&&!d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&so.a.SheenTextureEnabled&&e.setTexture(\"sheenRoughnessSampler\",this._textureRoughness))},e.prototype.hasTexture=function(e){return this._texture===e||this._textureRoughness===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)},e.prototype.dispose=function(e){var t,i;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._textureRoughness)||void 0===i||i.dispose())},e.prototype.getClassName=function(){return\"PBRSheenConfiguration\"},e.AddFallbacks=function(e,t,i){return e.SHEEN&&t.addFallback(i++,\"SHEEN\"),i},e.AddUniforms=function(e){e.push(\"vSheenColor\",\"vSheenRoughness\",\"vSheenInfos\",\"sheenMatrix\",\"sheenRoughnessMatrix\")},e.PrepareUniformBuffer=function(e){e.addUniform(\"vSheenColor\",4),e.addUniform(\"vSheenRoughness\",1),e.addUniform(\"vSheenInfos\",4),e.addUniform(\"sheenMatrix\",16),e.addUniform(\"sheenRoughnessMatrix\",16)},e.AddSamplers=function(e){e.push(\"sheenSampler\"),e.push(\"sheenRoughnessSampler\")},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"isEnabled\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"linkSheenWithAlbedo\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"intensity\",void 0),Object(h.c)([Object(w.e)()],e.prototype,\"color\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"texture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"useRoughnessFromMainTexture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"roughness\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"textureRoughness\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"albedoScaling\",void 0),e}(),Co=function(){function e(e,t,i){this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isScatteringEnabled=!1,this.isScatteringEnabled=!1,this._scatteringDiffusionProfileIndex=0,this.refractionIntensity=1,this.translucencyIntensity=1,this.useAlbedoToTintRefraction=!1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1.5,this.indexOfRefraction=1.5,this._volumeIndexOfRefraction=-1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.tintColor=s.a.White(),this.tintColorAtDistance=1,this.diffusionDistance=s.a.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._useMaskFromThicknessTextureGltf=!1,this.useMaskFromThicknessTextureGltf=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e,this._internalMarkScenePrePassDirty=t,this._scene=i}return Object.defineProperty(e.prototype,\"scatteringDiffusionProfile\",{get:function(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null},set:function(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"volumeIndexOfRefraction\",{get:function(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction},set:function(e){this._volumeIndexOfRefraction=e>=1?e:-1},enumerable:!1,configurable:!0}),e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype._markScenePrePassDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var i=this._getRefractionTexture(t);if(i&&so.a.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){if(e._areTexturesDirty&&(e.SUBSURFACE=!1,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=!1,e.SS_REFRACTION=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)&&(e.SUBSURFACE=!0,e._areTexturesDirty&&t.texturesEnabled&&this._thicknessTexture&&so.a.ThicknessTextureEnabled&&ro.a.PrepareDefinesForMergedUV(this._thicknessTexture,e,\"SS_THICKNESSANDMASK_TEXTURE\"),e.SS_MASK_FROM_THICKNESS_TEXTURE=this._useMaskFromThicknessTexture,e.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=this._useMaskFromThicknessTextureGltf),this._isRefractionEnabled&&t.texturesEnabled)){var i=this._getRefractionTexture(t);i&&so.a.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction)}},e.prototype.bindForSubMesh=function(e,t,i,n,r,o){var a=this._getRefractionTexture(t);if(!e.useUbo||!n||!e.isSync){if(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&(e.updateFloat2(\"vThicknessInfos\",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),ro.a.BindTextureMatrix(this._thicknessTexture,e,\"thickness\")),e.updateFloat2(\"vThicknessParam\",this.minimumThickness,this.maximumThickness-this.minimumThickness),a&&so.a.RefractionTextureEnabled){e.updateMatrix(\"refractionMatrix\",a.getReflectionTextureMatrix());var s=1;a.isCube||a.depth&&(s=a.depth);var c=a.getSize().width,l=this.volumeIndexOfRefraction;e.updateFloat4(\"vRefractionInfos\",a.level,1/l,s,this._invertRefractionY?-1:1),e.updateFloat3(\"vRefractionMicrosurfaceInfos\",c,a.lodGenerationScale,a.lodGenerationOffset),o&&e.updateFloat2(\"vRefractionFilteringInfo\",c,L.a.Log2(c))}this.isScatteringEnabled&&e.updateFloat(\"scatteringDiffusionProfile\",this._scatteringDiffusionProfileIndex),e.updateColor3(\"vDiffusionDistance\",this.diffusionDistance),e.updateFloat4(\"vTintColor\",this.tintColor.r,this.tintColor.g,this.tintColor.b,this.tintColorAtDistance),e.updateFloat3(\"vSubSurfaceIntensity\",this.refractionIntensity,this.translucencyIntensity,0)}t.texturesEnabled&&(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&e.setTexture(\"thicknessSampler\",this._thicknessTexture),a&&so.a.RefractionTextureEnabled&&(r?e.setTexture(\"refractionSampler\",a):(e.setTexture(\"refractionSampler\",a._lodTextureMid||a),e.setTexture(\"refractionSamplerLow\",a._lodTextureLow||a),e.setTexture(\"refractionSamplerHigh\",a._lodTextureHigh||a))))},e.prototype.unbind=function(e){return!(!this._refractionTexture||!this._refractionTexture.isRenderTarget)&&(e.setTexture(\"refractionSampler\",null),!0)},e.prototype._getRefractionTexture=function(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null},Object.defineProperty(e.prototype,\"disableAlphaBlending\",{get:function(){return this.isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!1,configurable:!0}),e.prototype.fillRenderTargetTextures=function(e){so.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},e.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e},e.prototype.hasRenderTargetTextures=function(){return!!(so.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},e.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture)},e.prototype.getAnimatables=function(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture)},e.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose())},e.prototype.getClassName=function(){return\"PBRSubSurfaceConfiguration\"},e.AddFallbacks=function(e,t,i){return e.SS_SCATTERING&&t.addFallback(i++,\"SS_SCATTERING\"),e.SS_TRANSLUCENCY&&t.addFallback(i++,\"SS_TRANSLUCENCY\"),i},e.AddUniforms=function(e){e.push(\"vDiffusionDistance\",\"vTintColor\",\"vSubSurfaceIntensity\",\"vRefractionMicrosurfaceInfos\",\"vRefractionFilteringInfo\",\"vRefractionInfos\",\"vThicknessInfos\",\"vThicknessParam\",\"refractionMatrix\",\"thicknessMatrix\",\"scatteringDiffusionProfile\")},e.AddSamplers=function(e){e.push(\"thicknessSampler\",\"refractionSampler\",\"refractionSamplerLow\",\"refractionSamplerHigh\")},e.PrepareUniformBuffer=function(e){e.addUniform(\"vRefractionMicrosurfaceInfos\",3),e.addUniform(\"vRefractionFilteringInfo\",2),e.addUniform(\"vRefractionInfos\",4),e.addUniform(\"refractionMatrix\",16),e.addUniform(\"vThicknessInfos\",2),e.addUniform(\"thicknessMatrix\",16),e.addUniform(\"vThicknessParam\",2),e.addUniform(\"vDiffusionDistance\",3),e.addUniform(\"vTintColor\",4),e.addUniform(\"vSubSurfaceIntensity\",3),e.addUniform(\"scatteringDiffusionProfile\",1)},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"isRefractionEnabled\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"isTranslucencyEnabled\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markScenePrePassDirty\")],e.prototype,\"isScatteringEnabled\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"_scatteringDiffusionProfileIndex\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"refractionIntensity\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"translucencyIntensity\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"useAlbedoToTintRefraction\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"thicknessTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"refractionTexture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"indexOfRefraction\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"_volumeIndexOfRefraction\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"volumeIndexOfRefraction\",null),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"invertRefractionY\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"linkRefractionWithTransparency\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"minimumThickness\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"maximumThickness\",void 0),Object(h.c)([Object(w.e)()],e.prototype,\"tintColor\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"tintColorAtDistance\",void 0),Object(h.c)([Object(w.e)()],e.prototype,\"diffusionDistance\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"useMaskFromThicknessTexture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],e.prototype,\"useMaskFromThicknessTextureGltf\",void 0),e}(),Ro=i(105),xo=i(25),Oo=(i(160),\"uniform vec3 vReflectionColor;\\nuniform vec4 vAlbedoColor;\\n\\nuniform vec4 vLightingIntensity;\\nuniform vec4 vReflectivityColor;\\nuniform vec4 vMetallicReflectanceFactors;\\nuniform vec3 vEmissiveColor;\\nuniform float visibility;\\n\\n#ifdef ALBEDO\\nuniform vec2 vAlbedoInfos;\\n#endif\\n#ifdef AMBIENT\\nuniform vec4 vAmbientInfos;\\n#endif\\n#ifdef BUMP\\nuniform vec3 vBumpInfos;\\nuniform vec2 vTangentSpaceParams;\\n#endif\\n#ifdef OPACITY\\nuniform vec2 vOpacityInfos;\\n#endif\\n#ifdef EMISSIVE\\nuniform vec2 vEmissiveInfos;\\n#endif\\n#ifdef LIGHTMAP\\nuniform vec2 vLightmapInfos;\\n#endif\\n#ifdef REFLECTIVITY\\nuniform vec3 vReflectivityInfos;\\n#endif\\n#ifdef MICROSURFACEMAP\\nuniform vec2 vMicroSurfaceSamplerInfos;\\n#endif\\n\\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)\\nuniform mat4 view;\\n#endif\\n\\n#ifdef REFLECTION\\nuniform vec2 vReflectionInfos;\\n#ifdef REALTIME_FILTERING\\nuniform vec2 vReflectionFilteringInfo;\\n#endif\\nuniform mat4 reflectionMatrix;\\nuniform vec3 vReflectionMicrosurfaceInfos;\\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\\nuniform vec3 vReflectionPosition;\\nuniform vec3 vReflectionSize;\\n#endif\\n#endif\\n\\n#ifdef CLEARCOAT\\nuniform vec2 vClearCoatParams;\\nuniform vec4 vClearCoatRefractionParams;\\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\\nuniform vec4 vClearCoatInfos;\\n#endif\\n#ifdef CLEARCOAT_TEXTURE\\nuniform mat4 clearCoatMatrix;\\n#endif\\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\\nuniform mat4 clearCoatRoughnessMatrix;\\n#endif\\n#ifdef CLEARCOAT_BUMP\\nuniform vec2 vClearCoatBumpInfos;\\nuniform vec2 vClearCoatTangentSpaceParams;\\nuniform mat4 clearCoatBumpMatrix;\\n#endif\\n#ifdef CLEARCOAT_TINT\\nuniform vec4 vClearCoatTintParams;\\nuniform float clearCoatColorAtDistance;\\n#ifdef CLEARCOAT_TINT_TEXTURE\\nuniform vec2 vClearCoatTintInfos;\\nuniform mat4 clearCoatTintMatrix;\\n#endif\\n#endif\\n#endif\\n\\n#ifdef ANISOTROPIC\\nuniform vec3 vAnisotropy;\\n#ifdef ANISOTROPIC_TEXTURE\\nuniform vec2 vAnisotropyInfos;\\nuniform mat4 anisotropyMatrix;\\n#endif\\n#endif\\n\\n#ifdef SHEEN\\nuniform vec4 vSheenColor;\\n#ifdef SHEEN_ROUGHNESS\\nuniform float vSheenRoughness;\\n#endif\\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\\nuniform vec4 vSheenInfos;\\n#endif\\n#ifdef SHEEN_TEXTURE\\nuniform mat4 sheenMatrix;\\n#endif\\n#ifdef SHEEN_TEXTURE_ROUGHNESS\\nuniform mat4 sheenRoughnessMatrix;\\n#endif\\n#endif\\n\\n#ifdef SUBSURFACE\\n#ifdef SS_REFRACTION\\nuniform vec3 vRefractionMicrosurfaceInfos;\\nuniform vec4 vRefractionInfos;\\nuniform mat4 refractionMatrix;\\n#ifdef REALTIME_FILTERING\\nuniform vec2 vRefractionFilteringInfo;\\n#endif\\n#endif\\n#ifdef SS_THICKNESSANDMASK_TEXTURE\\nuniform vec2 vThicknessInfos;\\nuniform mat4 thicknessMatrix;\\n#endif\\nuniform vec2 vThicknessParam;\\nuniform vec3 vDiffusionDistance;\\nuniform vec4 vTintColor;\\nuniform vec3 vSubSurfaceIntensity;\\n#endif\\n#ifdef PREPASS\\n#ifdef PREPASS_IRRADIANCE\\nuniform float scatteringDiffusionProfile;\\n#endif\\n#endif\");ai.a.IncludesShadersStore.pbrFragmentDeclaration=Oo;var Mo=\"layout(std140,column_major) uniform;\\nuniform Material\\n{\\nuniform vec2 vAlbedoInfos;\\nuniform vec4 vAmbientInfos;\\nuniform vec2 vOpacityInfos;\\nuniform vec2 vEmissiveInfos;\\nuniform vec2 vLightmapInfos;\\nuniform vec3 vReflectivityInfos;\\nuniform vec2 vMicroSurfaceSamplerInfos;\\nuniform vec2 vReflectionInfos;\\nuniform vec2 vReflectionFilteringInfo;\\nuniform vec3 vReflectionPosition;\\nuniform vec3 vReflectionSize;\\nuniform vec3 vBumpInfos;\\nuniform mat4 albedoMatrix;\\nuniform mat4 ambientMatrix;\\nuniform mat4 opacityMatrix;\\nuniform mat4 emissiveMatrix;\\nuniform mat4 lightmapMatrix;\\nuniform mat4 reflectivityMatrix;\\nuniform mat4 microSurfaceSamplerMatrix;\\nuniform mat4 bumpMatrix;\\nuniform vec2 vTangentSpaceParams;\\nuniform mat4 reflectionMatrix;\\nuniform vec3 vReflectionColor;\\nuniform vec4 vAlbedoColor;\\nuniform vec4 vLightingIntensity;\\nuniform vec3 vReflectionMicrosurfaceInfos;\\nuniform float pointSize;\\nuniform vec4 vReflectivityColor;\\nuniform vec3 vEmissiveColor;\\nuniform float visibility;\\nuniform vec4 vMetallicReflectanceFactors;\\nuniform vec2 vMetallicReflectanceInfos;\\nuniform mat4 metallicReflectanceMatrix;\\nuniform vec2 vClearCoatParams;\\nuniform vec4 vClearCoatRefractionParams;\\nuniform vec4 vClearCoatInfos;\\nuniform mat4 clearCoatMatrix;\\nuniform mat4 clearCoatRoughnessMatrix;\\nuniform vec2 vClearCoatBumpInfos;\\nuniform vec2 vClearCoatTangentSpaceParams;\\nuniform mat4 clearCoatBumpMatrix;\\nuniform vec4 vClearCoatTintParams;\\nuniform float clearCoatColorAtDistance;\\nuniform vec2 vClearCoatTintInfos;\\nuniform mat4 clearCoatTintMatrix;\\nuniform vec3 vAnisotropy;\\nuniform vec2 vAnisotropyInfos;\\nuniform mat4 anisotropyMatrix;\\nuniform vec4 vSheenColor;\\nuniform float vSheenRoughness;\\nuniform vec4 vSheenInfos;\\nuniform mat4 sheenMatrix;\\nuniform mat4 sheenRoughnessMatrix;\\nuniform vec3 vRefractionMicrosurfaceInfos;\\nuniform vec2 vRefractionFilteringInfo;\\nuniform vec4 vRefractionInfos;\\nuniform mat4 refractionMatrix;\\nuniform vec2 vThicknessInfos;\\nuniform mat4 thicknessMatrix;\\nuniform vec2 vThicknessParam;\\nuniform vec3 vDiffusionDistance;\\nuniform vec4 vTintColor;\\nuniform vec3 vSubSurfaceIntensity;\\nuniform float scatteringDiffusionProfile;\\nuniform vec4 vDetailInfos;\\nuniform mat4 detailMatrix;\\n};\\nuniform Scene {\\nmat4 viewProjection;\\n#ifdef MULTIVIEW\\nmat4 viewProjectionR;\\n#endif\\nmat4 view;\\n};\";ai.a.IncludesShadersStore.pbrUboDeclaration=Mo;var Io=\"uniform vec4 vEyePosition;\\nuniform vec3 vAmbientColor;\\nuniform vec4 vCameraInfos;\\n\\nvarying vec3 vPositionW;\\n#if DEBUGMODE>0\\nuniform vec2 vDebugMode;\\nvarying vec4 vClipSpacePosition;\\n#endif\\n#ifdef MAINUV1\\nvarying vec2 vMainUV1;\\n#endif\\n#ifdef MAINUV2\\nvarying vec2 vMainUV2;\\n#endif\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\\nvarying vec3 vEnvironmentIrradiance;\\n#endif\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\";ai.a.IncludesShadersStore.pbrFragmentExtraDeclaration=Io;var Do=\"#ifdef ALBEDO\\n#if ALBEDODIRECTUV == 1\\n#define vAlbedoUV vMainUV1\\n#elif ALBEDODIRECTUV == 2\\n#define vAlbedoUV vMainUV2\\n#else\\nvarying vec2 vAlbedoUV;\\n#endif\\nuniform sampler2D albedoSampler;\\n#endif\\n#ifdef AMBIENT\\n#if AMBIENTDIRECTUV == 1\\n#define vAmbientUV vMainUV1\\n#elif AMBIENTDIRECTUV == 2\\n#define vAmbientUV vMainUV2\\n#else\\nvarying vec2 vAmbientUV;\\n#endif\\nuniform sampler2D ambientSampler;\\n#endif\\n#ifdef OPACITY\\n#if OPACITYDIRECTUV == 1\\n#define vOpacityUV vMainUV1\\n#elif OPACITYDIRECTUV == 2\\n#define vOpacityUV vMainUV2\\n#else\\nvarying vec2 vOpacityUV;\\n#endif\\nuniform sampler2D opacitySampler;\\n#endif\\n#ifdef EMISSIVE\\n#if EMISSIVEDIRECTUV == 1\\n#define vEmissiveUV vMainUV1\\n#elif EMISSIVEDIRECTUV == 2\\n#define vEmissiveUV vMainUV2\\n#else\\nvarying vec2 vEmissiveUV;\\n#endif\\nuniform sampler2D emissiveSampler;\\n#endif\\n#ifdef LIGHTMAP\\n#if LIGHTMAPDIRECTUV == 1\\n#define vLightmapUV vMainUV1\\n#elif LIGHTMAPDIRECTUV == 2\\n#define vLightmapUV vMainUV2\\n#else\\nvarying vec2 vLightmapUV;\\n#endif\\nuniform sampler2D lightmapSampler;\\n#endif\\n#ifdef REFLECTIVITY\\n#if REFLECTIVITYDIRECTUV == 1\\n#define vReflectivityUV vMainUV1\\n#elif REFLECTIVITYDIRECTUV == 2\\n#define vReflectivityUV vMainUV2\\n#else\\nvarying vec2 vReflectivityUV;\\n#endif\\nuniform sampler2D reflectivitySampler;\\n#endif\\n#ifdef MICROSURFACEMAP\\n#if MICROSURFACEMAPDIRECTUV == 1\\n#define vMicroSurfaceSamplerUV vMainUV1\\n#elif MICROSURFACEMAPDIRECTUV == 2\\n#define vMicroSurfaceSamplerUV vMainUV2\\n#else\\nvarying vec2 vMicroSurfaceSamplerUV;\\n#endif\\nuniform sampler2D microSurfaceSampler;\\n#endif\\n#ifdef METALLIC_REFLECTANCE\\n#if METALLIC_REFLECTANCEDIRECTUV == 1\\n#define vMetallicReflectanceUV vMainUV1\\n#elif METALLIC_REFLECTANCEDIRECTUV == 2\\n#define vMetallicReflectanceUV vMainUV2\\n#else\\nvarying vec2 vMetallicReflectanceUV;\\n#endif\\nuniform sampler2D metallicReflectanceSampler;\\n#endif\\n#ifdef CLEARCOAT\\n#if defined(CLEARCOAT_TEXTURE)\\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\\n#define vClearCoatUV vMainUV1\\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\\n#define vClearCoatUV vMainUV2\\n#else\\nvarying vec2 vClearCoatUV;\\n#endif\\n#endif\\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)\\n#if CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 1\\n#define vClearCoatRoughnessUV vMainUV1\\n#elif CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 2\\n#define vClearCoatRoughnessUV vMainUV2\\n#else\\nvarying vec2 vClearCoatRoughnessUV;\\n#endif\\n#endif\\n#ifdef CLEARCOAT_TEXTURE\\nuniform sampler2D clearCoatSampler;\\n#endif\\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)\\nuniform sampler2D clearCoatRoughnessSampler;\\n#endif\\n#ifdef CLEARCOAT_BUMP\\n#if CLEARCOAT_BUMPDIRECTUV == 1\\n#define vClearCoatBumpUV vMainUV1\\n#elif CLEARCOAT_BUMPDIRECTUV == 2\\n#define vClearCoatBumpUV vMainUV2\\n#else\\nvarying vec2 vClearCoatBumpUV;\\n#endif\\nuniform sampler2D clearCoatBumpSampler;\\n#endif\\n#ifdef CLEARCOAT_TINT_TEXTURE\\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\\n#define vClearCoatTintUV vMainUV1\\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\\n#define vClearCoatTintUV vMainUV2\\n#else\\nvarying vec2 vClearCoatTintUV;\\n#endif\\nuniform sampler2D clearCoatTintSampler;\\n#endif\\n#endif\\n#ifdef SHEEN\\n#ifdef SHEEN_TEXTURE\\n#if SHEEN_TEXTUREDIRECTUV == 1\\n#define vSheenUV vMainUV1\\n#elif SHEEN_TEXTUREDIRECTUV == 2\\n#define vSheenUV vMainUV2\\n#else\\nvarying vec2 vSheenUV;\\n#endif\\n#endif\\n#ifdef SHEEN_TEXTURE_ROUGHNESS\\n#if SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 1\\n#define vSheenRoughnessUV vMainUV1\\n#elif SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 2\\n#define vSheenRoughnessUV vMainUV2\\n#else\\nvarying vec2 vSheenRoughnessUV;\\n#endif\\n#endif\\n#ifdef SHEEN_TEXTURE\\nuniform sampler2D sheenSampler;\\n#endif\\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)\\nuniform sampler2D sheenRoughnessSampler;\\n#endif\\n#endif\\n#ifdef ANISOTROPIC\\n#ifdef ANISOTROPIC_TEXTURE\\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\\n#define vAnisotropyUV vMainUV1\\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\\n#define vAnisotropyUV vMainUV2\\n#else\\nvarying vec2 vAnisotropyUV;\\n#endif\\nuniform sampler2D anisotropySampler;\\n#endif\\n#endif\\n\\n#ifdef REFLECTION\\n#ifdef REFLECTIONMAP_3D\\n#define sampleReflection(s,c) textureCube(s,c)\\nuniform samplerCube reflectionSampler;\\n#ifdef LODBASEDMICROSFURACE\\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\\n#else\\nuniform samplerCube reflectionSamplerLow;\\nuniform samplerCube reflectionSamplerHigh;\\n#endif\\n#ifdef USEIRRADIANCEMAP\\nuniform samplerCube irradianceSampler;\\n#endif\\n#else\\n#define sampleReflection(s,c) texture2D(s,c)\\nuniform sampler2D reflectionSampler;\\n#ifdef LODBASEDMICROSFURACE\\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\\n#else\\nuniform sampler2D reflectionSamplerLow;\\nuniform sampler2D reflectionSamplerHigh;\\n#endif\\n#ifdef USEIRRADIANCEMAP\\nuniform sampler2D irradianceSampler;\\n#endif\\n#endif\\n#ifdef REFLECTIONMAP_SKYBOX\\nvarying vec3 vPositionUVW;\\n#else\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvarying vec3 vDirectionW;\\n#endif\\n#endif\\n#endif\\n#ifdef ENVIRONMENTBRDF\\nuniform sampler2D environmentBrdfSampler;\\n#endif\\n\\n#ifdef SUBSURFACE\\n#ifdef SS_REFRACTION\\n#ifdef SS_REFRACTIONMAP_3D\\n#define sampleRefraction(s,c) textureCube(s,c)\\nuniform samplerCube refractionSampler;\\n#ifdef LODBASEDMICROSFURACE\\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\\n#else\\nuniform samplerCube refractionSamplerLow;\\nuniform samplerCube refractionSamplerHigh;\\n#endif\\n#else\\n#define sampleRefraction(s,c) texture2D(s,c)\\nuniform sampler2D refractionSampler;\\n#ifdef LODBASEDMICROSFURACE\\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\\n#else\\nuniform sampler2D refractionSamplerLow;\\nuniform sampler2D refractionSamplerHigh;\\n#endif\\n#endif\\n#endif\\n#ifdef SS_THICKNESSANDMASK_TEXTURE\\n#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1\\n#define vThicknessUV vMainUV1\\n#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2\\n#define vThicknessUV vMainUV2\\n#else\\nvarying vec2 vThicknessUV;\\n#endif\\nuniform sampler2D thicknessSampler;\\n#endif\\n#endif\";ai.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=Do;i(116);ai.a.IncludesShadersStore.subSurfaceScatteringFunctions=\"bool testLightingForSSS(float diffusionProfile)\\n{\\nreturn diffusionProfile<1.;\\n}\";var No=\"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nvec3 hemisphereCosSample(vec2 u) {\\n\\nfloat phi=2.*PI*u.x;\\nfloat cosTheta2=1.-u.y;\\nfloat cosTheta=sqrt(cosTheta2);\\nfloat sinTheta=sqrt(1.-cosTheta2);\\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\\n}\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nvec3 hemisphereImportanceSampleDggx(vec2 u,float a) {\\n\\nfloat phi=2.*PI*u.x;\\n\\nfloat cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));\\nfloat cosTheta=sqrt(cosTheta2);\\nfloat sinTheta=sqrt(1.-cosTheta2);\\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\\n}\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nvec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {\\n\\nfloat phi=2.*PI*u.x;\\nfloat sinTheta=pow(u.y,a/(2.*a+1.));\\nfloat cosTheta=sqrt(1.-sinTheta*sinTheta);\\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\\n}\";ai.a.IncludesShadersStore.importanceSampling=No;var Lo=\"\\n#define RECIPROCAL_PI2 0.15915494\\n#define RECIPROCAL_PI 0.31830988618\\n\\n#define MINIMUMVARIANCE 0.0005\\nfloat convertRoughnessToAverageSlope(float roughness)\\n{\\n\\nreturn square(roughness)+MINIMUMVARIANCE;\\n}\\nfloat fresnelGrazingReflectance(float reflectance0) {\\n\\n\\nfloat reflectance90=saturate(reflectance0*25.0);\\nreturn reflectance90;\\n}\\nvec2 getAARoughnessFactors(vec3 normalVector) {\\n#ifdef SPECULARAA\\nvec3 nDfdx=dFdx(normalVector.xyz);\\nvec3 nDfdy=dFdy(normalVector.xyz);\\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\\n\\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\\n\\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\\n\\ngeometricAlphaGFactor*=0.75;\\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\\n#else\\nreturn vec2(0.);\\n#endif\\n}\\n#ifdef ANISOTROPIC\\n\\n\\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\\nreturn vec2(alphaT,alphaB);\\n}\\n\\n\\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\\nreturn anisotropicNormal;\\n\\n}\\n#endif\\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\\n\\n\\n\\nvec3 cocaLambert(vec3 alpha,float distance) {\\nreturn exp(-alpha*distance);\\n}\\n\\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\\n}\\n\\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\\nreturn -log(color)/distance;\\n}\\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\\nvec3 clearCoatAbsorption=mix(vec3(1.0),\\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\\nclearCoatIntensity);\\nreturn clearCoatAbsorption;\\n}\\n#endif\\n\\n\\n\\n\\n#ifdef MICROSURFACEAUTOMATIC\\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\\n{\\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\\nreturn microSurface;\\n}\\n#endif\";ai.a.IncludesShadersStore.pbrHelperFunctions=Lo;var wo=\"#ifdef USESPHERICALFROMREFLECTIONMAP\\n#ifdef SPHERICAL_HARMONICS\\nuniform vec3 vSphericalL00;\\nuniform vec3 vSphericalL1_1;\\nuniform vec3 vSphericalL10;\\nuniform vec3 vSphericalL11;\\nuniform vec3 vSphericalL2_2;\\nuniform vec3 vSphericalL2_1;\\nuniform vec3 vSphericalL20;\\nuniform vec3 vSphericalL21;\\nuniform vec3 vSphericalL22;\\n\\n\\n\\n\\n\\n\\n\\nvec3 computeEnvironmentIrradiance(vec3 normal) {\\nreturn vSphericalL00\\n+vSphericalL1_1*(normal.y)\\n+vSphericalL10*(normal.z)\\n+vSphericalL11*(normal.x)\\n+vSphericalL2_2*(normal.y*normal.x)\\n+vSphericalL2_1*(normal.y*normal.z)\\n+vSphericalL20*((3.0*normal.z*normal.z)-1.0)\\n+vSphericalL21*(normal.z*normal.x)\\n+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\\n}\\n#else\\nuniform vec3 vSphericalX;\\nuniform vec3 vSphericalY;\\nuniform vec3 vSphericalZ;\\nuniform vec3 vSphericalXX_ZZ;\\nuniform vec3 vSphericalYY_ZZ;\\nuniform vec3 vSphericalZZ;\\nuniform vec3 vSphericalXY;\\nuniform vec3 vSphericalYZ;\\nuniform vec3 vSphericalZX;\\n\\nvec3 computeEnvironmentIrradiance(vec3 normal) {\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nfloat Nx=normal.x;\\nfloat Ny=normal.y;\\nfloat Nz=normal.z;\\nvec3 C1=vSphericalZZ.rgb;\\nvec3 Cx=vSphericalX.rgb;\\nvec3 Cy=vSphericalY.rgb;\\nvec3 Cz=vSphericalZ.rgb;\\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\\nvec3 Cxy=vSphericalXY.rgb;\\nvec3 Cyz=vSphericalYZ.rgb;\\nvec3 Czx=vSphericalZX.rgb;\\nvec3 a1=Cyy_zz*Ny+Cy;\\nvec3 a2=Cyz*Nz+a1;\\nvec3 b1=Czx*Nz+Cx;\\nvec3 b2=Cxy*Ny+b1;\\nvec3 b3=Cxx_zz*Nx+b2;\\nvec3 t1=Cz*Nz+C1;\\nvec3 t2=a2*Ny+t1;\\nvec3 t3=b3*Nx+t2;\\nreturn t3;\\n}\\n#endif\\n#endif\";ai.a.IncludesShadersStore.harmonicsFunctions=wo;var Fo=\"\\nstruct preLightingInfo\\n{\\n\\nvec3 lightOffset;\\nfloat lightDistanceSquared;\\nfloat lightDistance;\\n\\nfloat attenuation;\\n\\nvec3 L;\\nvec3 H;\\nfloat NdotV;\\nfloat NdotLUnclamped;\\nfloat NdotL;\\nfloat VdotH;\\nfloat roughness;\\n};\\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\\npreLightingInfo result;\\n\\nresult.lightOffset=lightData.xyz-vPositionW;\\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\\n\\nresult.lightDistance=sqrt(result.lightDistanceSquared);\\n\\nresult.L=normalize(result.lightOffset);\\nresult.H=normalize(V+result.L);\\nresult.VdotH=saturate(dot(V,result.H));\\nresult.NdotLUnclamped=dot(N,result.L);\\nresult.NdotL=saturateEps(result.NdotLUnclamped);\\nreturn result;\\n}\\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\\npreLightingInfo result;\\n\\nresult.lightDistance=length(-lightData.xyz);\\n\\nresult.L=normalize(-lightData.xyz);\\nresult.H=normalize(V+result.L);\\nresult.VdotH=saturate(dot(V,result.H));\\nresult.NdotLUnclamped=dot(N,result.L);\\nresult.NdotL=saturateEps(result.NdotLUnclamped);\\nreturn result;\\n}\\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\\npreLightingInfo result;\\n\\n\\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\\nresult.NdotL=saturateEps(result.NdotL);\\nresult.NdotLUnclamped=result.NdotL;\\n#ifdef SPECULARTERM\\nresult.L=normalize(lightData.xyz);\\nresult.H=normalize(V+result.L);\\nresult.VdotH=saturate(dot(V,result.H));\\n#endif\\nreturn result;\\n}\";ai.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=Fo;var Bo=\"float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\\n{\\nreturn max(0.,1.0-length(lightOffset)/range);\\n}\\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\\n{\\nreturn 1.0/maxEps(lightDistanceSquared);\\n}\\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\\n{\\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\\nfloat factor=lightDistanceSquared*inverseSquaredRange;\\nfloat attenuation=saturate(1.0-factor*factor);\\nattenuation*=attenuation;\\n\\nlightDistanceFalloff*=attenuation;\\nreturn lightDistanceFalloff;\\n}\\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\\n{\\n#ifdef USEPHYSICALLIGHTFALLOFF\\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\\n#elif defined(USEGLTFLIGHTFALLOFF)\\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\\n#else\\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\\n#endif\\n}\\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\\n{\\nfloat falloff=0.0;\\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\\nif (cosAngle>=cosHalfAngle)\\n{\\nfalloff=max(0.,pow(cosAngle,exponent));\\n}\\nreturn falloff;\\n}\\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\\n{\\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\\n\\n\\n\\n\\n\\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\\n\\n\\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\\nreturn falloff;\\n}\\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\\n{\\n\\n\\n\\nfloat cd=dot(-lightDirection,directionToLightCenterW);\\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\\n\\nfalloff*=falloff;\\nreturn falloff;\\n}\\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\\n{\\n#ifdef USEPHYSICALLIGHTFALLOFF\\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\\n#elif defined(USEGLTFLIGHTFALLOFF)\\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\\n#else\\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\\n#endif\\n}\";ai.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=Bo;var Uo=\"\\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\\n\\n\\n\\n\\n#ifdef MS_BRDF_ENERGY_CONSERVATION\\n\\n\\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\\n}\\n#endif\\n#ifdef ENVIRONMENTBRDF\\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness) {\\n\\nvec2 UV=vec2(NdotV,perceptualRoughness);\\n\\nvec4 brdfLookup=texture2D(environmentBrdfSampler,UV);\\n#ifdef ENVIRONMENTBRDF_RGBD\\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\\n#endif\\nreturn brdfLookup.rgb;\\n}\\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {\\n#ifdef BRDF_V_HEIGHT_CORRELATED\\nvec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;\\n\\n#else\\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;\\n#endif\\nreturn reflectance;\\n}\\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\\n#ifdef BRDF_V_HEIGHT_CORRELATED\\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\\n#else\\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\\n#endif\\nreturn reflectance;\\n}\\n#endif\\n\\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\\n{\\n\\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\\n}\\n#endif\\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\\n\\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\\nreturn sheenEnvironmentReflectance;\\n}\\n#endif\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\\n{\\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\\n}\\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\\n{\\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\\n}\\n#ifdef CLEARCOAT\\n\\n\\n\\n\\n\\nvec3 getR0RemappedForClearCoat(vec3 f0) {\\n#ifdef CLEARCOAT_DEFAULTIOR\\n#ifdef MOBILE\\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\\n#else\\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\\n#endif\\n#else\\nvec3 s=sqrt(f0);\\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\\nreturn t*t;\\n#endif\\n}\\n#endif\\n\\n\\n\\n\\n\\n\\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\\n{\\n\\n\\n\\nfloat a2=square(alphaG);\\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\\nreturn a2/(PI*d*d);\\n}\\n#ifdef SHEEN\\n\\n\\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\\n{\\nfloat invR=1./alphaG;\\nfloat cos2h=NdotH*NdotH;\\nfloat sin2h=1.-cos2h;\\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\\n}\\n#endif\\n#ifdef ANISOTROPIC\\n\\n\\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\\nfloat a2=alphaTB.x*alphaTB.y;\\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\\nfloat v2=dot(v,v);\\nfloat w2=a2/v2;\\nreturn a2*w2*w2*RECIPROCAL_PI;\\n}\\n#endif\\n\\n\\n\\n\\n#ifdef BRDF_V_HEIGHT_CORRELATED\\n\\n\\n\\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\\n#ifdef MOBILE\\n\\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\\nreturn 0.5/(GGXV+GGXL);\\n#else\\nfloat a2=alphaG*alphaG;\\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\\nreturn 0.5/(GGXV+GGXL);\\n#endif\\n}\\n#else\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\\n{\\n#ifdef MOBILE\\n\\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\\n#else\\nfloat alphaSquared=alphaG*alphaG;\\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\\n#endif\\n}\\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\\n{\\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\\n\\nreturn visibility;\\n}\\n#endif\\n#ifdef ANISOTROPIC\\n\\n\\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\\nfloat v=0.5/(lambdaV+lambdaL);\\nreturn v;\\n}\\n#endif\\n#ifdef CLEARCOAT\\nfloat visibility_Kelemen(float VdotH) {\\n\\n\\n\\nreturn 0.25/(VdotH*VdotH);\\n}\\n#endif\\n#ifdef SHEEN\\n\\n\\n\\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\\n{\\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\\n}\\n\\n#endif\\n\\n\\n\\n\\n\\n\\n\\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\\n\\n\\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\\nfloat fresnel =\\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\\nreturn fresnel/PI;\\n}\\n#ifdef SS_TRANSLUCENCY\\n\\n\\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\\nvec3 S=1./maxEps(diffusionDistance);\\nvec3 temp=exp((-0.333333333*thickness)*S);\\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\\n}\\n\\n\\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\\nfloat t=1.0+w;\\nfloat invt2=1.0/square(t);\\nreturn saturate((NdotL+w)*invt2);\\n}\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBRDFFunctions=Uo;var Vo=\"#ifdef NUM_SAMPLES\\n#if NUM_SAMPLES>0\\n#ifdef WEBGL2\\n\\n\\nfloat radicalInverse_VdC(uint bits)\\n{\\nbits=(bits << 16u) | (bits >> 16u);\\nbits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\\nbits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\\nbits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\\nbits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\\nreturn float(bits)*2.3283064365386963e-10;\\n}\\nvec2 hammersley(uint i,uint N)\\n{\\nreturn vec2(float(i)/float(N),radicalInverse_VdC(i));\\n}\\n#else\\nfloat vanDerCorpus(int n,int base)\\n{\\nfloat invBase=1.0/float(base);\\nfloat denom=1.0;\\nfloat result=0.0;\\nfor(int i=0; i<32; ++i)\\n{\\nif(n>0)\\n{\\ndenom=mod(float(n),2.0);\\nresult+=denom*invBase;\\ninvBase=invBase/2.0;\\nn=int(float(n)/2.0);\\n}\\n}\\nreturn result;\\n}\\nvec2 hammersley(int i,int N)\\n{\\nreturn vec2(float(i)/float(N),vanDerCorpus(i,2));\\n}\\n#endif\\nfloat log4(float x) {\\nreturn log2(x)/2.;\\n}\\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);\\nconst float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;\\nconst float K=4.;\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n#define inline\\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\\n{\\nvec3 n=normalize(inputN);\\nvec3 result=vec3(0.0);\\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\\ntangent=normalize(cross(tangent,n));\\nvec3 bitangent=cross(n,tangent);\\nmat3 tbn=mat3(tangent,bitangent,n);\\nfloat maxLevel=filteringInfo.y;\\nfloat dim0=filteringInfo.x;\\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\\n#ifdef WEBGL2\\nfor(uint i=0u; i0.) {\\nfloat pdf_inversed=PI/NoL;\\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\\nfloat mipLevel=clamp(l,0.0,maxLevel);\\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\\n#ifdef GAMMA_INPUT\\nc=toLinearSpace(c);\\n#endif\\nresult+=c;\\n}\\n}\\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\\nreturn result;\\n}\\n#define inline\\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\\n{\\nvec3 n=normalize(inputN);\\nif (alphaG == 0.) {\\nvec3 c=textureCube(inputTexture,n).rgb;\\n#ifdef GAMMA_INPUT\\nc=toLinearSpace(c);\\n#endif\\nreturn c;\\n}\\nvec3 result=vec3(0.);\\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\\ntangent=normalize(cross(tangent,n));\\nvec3 bitangent=cross(n,tangent);\\nmat3 tbn=mat3(tangent,bitangent,n);\\nfloat maxLevel=filteringInfo.y;\\nfloat dim0=filteringInfo.x;\\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\\nfloat weight=0.;\\n#ifdef WEBGL2\\nfor(uint i=0u; i0.) {\\nfloat pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);\\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\\nfloat mipLevel=clamp(float(l),0.0,maxLevel);\\nweight+=NoL;\\nvec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\\n#ifdef GAMMA_INPUT\\nc=toLinearSpace(c);\\n#endif\\nresult+=c*NoL;\\n}\\n}\\nresult=result/weight;\\nreturn result;\\n}\\n#endif\\n#endif\";ai.a.IncludesShadersStore.hdrFilteringFunctions=Vo;var ko=\"#define CLEARCOATREFLECTANCE90 1.0\\n\\nstruct lightingInfo\\n{\\nvec3 diffuse;\\n#ifdef SPECULARTERM\\nvec3 specular;\\n#endif\\n#ifdef CLEARCOAT\\n\\n\\nvec4 clearCoat;\\n#endif\\n#ifdef SHEEN\\nvec3 sheen;\\n#endif\\n};\\n\\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\\n\\nfloat lightRoughness=lightRadius/lightDistance;\\n\\nfloat totalRoughness=saturate(lightRoughness+roughness);\\nreturn totalRoughness;\\n#else\\nreturn roughness;\\n#endif\\n}\\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\\nreturn mix(groundColor,lightColor,info.NdotL);\\n}\\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\\n}\\n#define inline\\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\\nstrq/=strq.w;\\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\\nreturn toLinearSpace(textureColor);\\n}\\n#ifdef SS_TRANSLUCENCY\\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\\nfloat NdotL=absEps(info.NdotLUnclamped);\\n\\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\\n\\nfloat trAdapt=step(0.,info.NdotLUnclamped);\\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\\n}\\n#endif\\n#ifdef SPECULARTERM\\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\\nfloat NdotH=saturateEps(dot(N,info.H));\\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\\n#ifdef BRDF_V_HEIGHT_CORRELATED\\nfloat smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\\n#else\\nfloat smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\\n#endif\\nvec3 specTerm=fresnel*distribution*smithVisibility;\\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\\n}\\n#endif\\n#ifdef ANISOTROPIC\\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\\nfloat NdotH=saturateEps(dot(N,info.H));\\nfloat TdotH=dot(T,info.H);\\nfloat BdotH=dot(B,info.H);\\nfloat TdotV=dot(T,V);\\nfloat BdotV=dot(B,V);\\nfloat TdotL=dot(T,info.L);\\nfloat BdotL=dot(B,info.L);\\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\\nfloat smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\\nvec3 specTerm=fresnel*distribution*smithVisibility;\\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\\n}\\n#endif\\n#ifdef CLEARCOAT\\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\\nfresnel*=clearCoatIntensity;\\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\\nfloat kelemenVisibility=visibility_Kelemen(info.VdotH);\\nfloat clearCoatTerm=fresnel*distribution*kelemenVisibility;\\nreturn vec4(\\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\\n1.0-fresnel\\n);\\n}\\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\\nreturn absorption;\\n}\\n#endif\\n#ifdef SHEEN\\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\\nfloat NdotH=saturateEps(dot(N,info.H));\\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\\n\\n\\nfloat fresnel=1.;\\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\\n\\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\\n\\nfloat sheenTerm=fresnel*distribution*visibility;\\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\\n}\\n#endif\\n\";ai.a.IncludesShadersStore.pbrDirectLightingFunctions=ko;var zo=\"#if defined(REFLECTION) || defined(SS_REFRACTION)\\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\\nfloat microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;\\nfloat lod=log2(microsurfaceAverageSlopeTexels);\\nreturn lod;\\n}\\nfloat getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {\\nfloat lod=log2(cubeMapDimensionPixels)*roughness;\\nreturn lod;\\n}\\n#endif\\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\\n\\n\\nfloat temp=NdotVUnclamped+ambientOcclusion;\\nreturn saturate(square(temp)-1.0+ambientOcclusion);\\n}\\n#endif\\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {\\n\\nvec3 reflection=reflect(view,normal);\\nfloat temp=saturate(1.0+1.1*dot(reflection,geometricNormal));\\nreturn square(temp);\\n}\\n#endif\\n\\n\\n\\n\\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\\n\\n\\n#define UNPACK_LOD(x) (1.0-x)*255.0\\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\\nfloat microsurfaceAverageSlope=alphaG;\\n\\n\\n\\n\\n\\n\\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\\n}\\n#endif\";ai.a.IncludesShadersStore.pbrIBLFunctions=zo;i(132),i(133);var Go=\"struct albedoOpacityOutParams\\n{\\nvec3 surfaceAlbedo;\\nfloat alpha;\\n};\\n#define pbr_inline\\nvoid albedoOpacityBlock(\\nconst in vec4 vAlbedoColor,\\n#ifdef ALBEDO\\nconst in vec4 albedoTexture,\\nconst in vec2 albedoInfos,\\n#endif\\n#ifdef OPACITY\\nconst in vec4 opacityMap,\\nconst in vec2 vOpacityInfos,\\n#endif\\n#ifdef DETAIL\\nconst in vec4 detailColor,\\nconst in vec4 vDetailInfos,\\n#endif\\nout albedoOpacityOutParams outParams\\n)\\n{\\n\\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\\nfloat alpha=vAlbedoColor.a;\\n#ifdef ALBEDO\\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\\nalpha*=albedoTexture.a;\\n#endif\\n#ifdef GAMMAALBEDO\\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\\n#else\\nsurfaceAlbedo*=albedoTexture.rgb;\\n#endif\\nsurfaceAlbedo*=albedoInfos.y;\\n#endif\\n#ifdef VERTEXCOLOR\\nsurfaceAlbedo*=vColor.rgb;\\n#endif\\n#ifdef DETAIL\\nfloat detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);\\nsurfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;\\n#endif\\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\\n\\n#ifdef OPACITY\\n#ifdef OPACITYRGB\\nalpha=getLuminance(opacityMap.rgb);\\n#else\\nalpha*=opacityMap.a;\\n#endif\\nalpha*=vOpacityInfos.y;\\n#endif\\n#ifdef VERTEXALPHA\\nalpha*=vColor.a;\\n#endif\\n#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\\n#ifdef ALPHATEST\\nif (alpha0\\nvec4 surfaceMetallicColorMap;\\nvec4 surfaceReflectivityColorMap;\\nvec2 metallicRoughness;\\nvec3 metallicF0;\\n#endif\\n};\\n#define pbr_inline\\nvoid reflectivityBlock(\\nconst in vec4 vReflectivityColor,\\n#ifdef METALLICWORKFLOW\\nconst in vec3 surfaceAlbedo,\\nconst in vec4 metallicReflectanceFactors,\\n#endif\\n#ifdef REFLECTIVITY\\nconst in vec3 reflectivityInfos,\\nconst in vec4 surfaceMetallicOrReflectivityColorMap,\\n#endif\\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\\nconst in vec3 ambientOcclusionColorIn,\\n#endif\\n#ifdef MICROSURFACEMAP\\nconst in vec4 microSurfaceTexel,\\n#endif\\n#ifdef DETAIL\\nconst in vec4 detailColor,\\nconst in vec4 vDetailInfos,\\n#endif\\nout reflectivityOutParams outParams\\n)\\n{\\nfloat microSurface=vReflectivityColor.a;\\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\\n#ifdef METALLICWORKFLOW\\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\\n#ifdef REFLECTIVITY\\n#if DEBUGMODE>0\\noutParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;\\n#endif\\n#ifdef AOSTOREINMETALMAPRED\\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);\\noutParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);\\n#endif\\n#ifdef METALLNESSSTOREINMETALMAPBLUE\\nmetallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;\\n#else\\nmetallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;\\n#endif\\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\\nmetallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;\\n#else\\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\\nmetallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;\\n#endif\\n#endif\\n#endif\\n#ifdef DETAIL\\nfloat detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);\\nfloat loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);\\nfloat hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);\\nmetallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));\\n#endif\\n#ifdef MICROSURFACEMAP\\nmetallicRoughness.g*=microSurfaceTexel.r;\\n#endif\\n#if DEBUGMODE>0\\noutParams.metallicRoughness=metallicRoughness;\\n#endif\\n#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\\n\\nmicroSurface=1.0-metallicRoughness.g;\\n\\nvec3 baseColor=surfaceAlbedo;\\n#ifdef FROSTBITE_REFLECTANCE\\n\\n\\n\\n\\n\\n\\noutParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\\n\\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\\n#else\\nvec3 metallicF0=metallicReflectanceFactors.rgb;\\n#if DEBUGMODE>0\\noutParams.metallicF0=metallicF0;\\n#endif\\n\\noutParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);\\n\\nsurfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);\\n#endif\\n#else\\n#ifdef REFLECTIVITY\\nsurfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;\\n#if DEBUGMODE>0\\noutParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;\\n#endif\\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\\nmicroSurface*=surfaceMetallicOrReflectivityColorMap.a;\\nmicroSurface*=reflectivityInfos.z;\\n#else\\n#ifdef MICROSURFACEAUTOMATIC\\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\\n#endif\\n#ifdef MICROSURFACEMAP\\nmicroSurface*=microSurfaceTexel.r;\\n#endif\\n#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\\n#endif\\n#endif\\n#endif\\n\\nmicroSurface=saturate(microSurface);\\n\\nfloat roughness=1.-microSurface;\\noutParams.microSurface=microSurface;\\noutParams.roughness=roughness;\\noutParams.surfaceReflectivityColor=surfaceReflectivityColor;\\n}\\n\";ai.a.IncludesShadersStore.pbrBlockReflectivity=jo;var Wo=\"struct ambientOcclusionOutParams\\n{\\nvec3 ambientOcclusionColor;\\n#if DEBUGMODE>0\\nvec3 ambientOcclusionColorMap;\\n#endif\\n};\\n#define pbr_inline\\nvoid ambientOcclusionBlock(\\n#ifdef AMBIENT\\nconst in vec3 ambientOcclusionColorMap_,\\nconst in vec4 vAmbientInfos,\\n#endif\\nout ambientOcclusionOutParams outParams\\n)\\n{\\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\\n#ifdef AMBIENT\\nvec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;\\n#ifdef AMBIENTINGRAYSCALE\\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\\n#endif\\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\\n#if DEBUGMODE>0\\noutParams.ambientOcclusionColorMap=ambientOcclusionColorMap;\\n#endif\\n#endif\\noutParams.ambientOcclusionColor=ambientOcclusionColor;\\n}\\n\";ai.a.IncludesShadersStore.pbrBlockAmbientOcclusion=Wo;var Ho=\"#ifdef ALPHAFRESNEL\\n#if defined(ALPHATEST) || defined(ALPHABLEND)\\nstruct alphaFresnelOutParams\\n{\\nfloat alpha;\\n};\\n#define pbr_inline\\nvoid alphaFresnelBlock(\\nconst in vec3 normalW,\\nconst in vec3 viewDirectionW,\\nconst in float alpha,\\nconst in float microSurface,\\nout alphaFresnelOutParams outParams\\n)\\n{\\n\\n\\n\\nfloat opacityPerceptual=alpha;\\n#ifdef LINEARALPHAFRESNEL\\nfloat opacity0=opacityPerceptual;\\n#else\\nfloat opacity0=opacityPerceptual*opacityPerceptual;\\n#endif\\nfloat opacity90=fresnelGrazingReflectance(opacity0);\\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\\n\\noutParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\\n#ifdef ALPHATEST\\nif (outParams.alpha0\\nvec3 anisotropyMapData;\\n#endif\\n};\\n#define pbr_inline\\nvoid anisotropicBlock(\\nconst in vec3 vAnisotropy,\\n#ifdef ANISOTROPIC_TEXTURE\\nconst in vec3 anisotropyMapData,\\n#endif\\nconst in mat3 TBN,\\nconst in vec3 normalW,\\nconst in vec3 viewDirectionW,\\nout anisotropicOutParams outParams\\n)\\n{\\nfloat anisotropy=vAnisotropy.b;\\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\\n#ifdef ANISOTROPIC_TEXTURE\\nanisotropy*=anisotropyMapData.b;\\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\\n#if DEBUGMODE>0\\noutParams.anisotropyMapData=anisotropyMapData;\\n#endif\\n#endif\\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\\noutParams.anisotropy=anisotropy;\\noutParams.anisotropicTangent=anisotropicTangent;\\noutParams.anisotropicBitangent=anisotropicBitangent;\\noutParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\\n}\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockAnisotropic=Xo;var Yo=\"#ifdef REFLECTION\\nstruct reflectionOutParams\\n{\\nvec4 environmentRadiance;\\nvec3 environmentIrradiance;\\n#ifdef REFLECTIONMAP_3D\\nvec3 reflectionCoords;\\n#else\\nvec2 reflectionCoords;\\n#endif\\n#ifdef SS_TRANSLUCENCY\\n#ifdef USESPHERICALFROMREFLECTIONMAP\\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\\nvec3 irradianceVector;\\n#endif\\n#endif\\n#endif\\n};\\n#define pbr_inline\\nvoid createReflectionCoords(\\nconst in vec3 vPositionW,\\nconst in vec3 normalW,\\n#ifdef ANISOTROPIC\\nconst in anisotropicOutParams anisotropicOut,\\n#endif\\n#ifdef REFLECTIONMAP_3D\\nout vec3 reflectionCoords\\n#else\\nout vec2 reflectionCoords\\n#endif\\n)\\n{\\n#ifdef ANISOTROPIC\\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);\\n#else\\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\\n#endif\\n#ifdef REFLECTIONMAP_OPPOSITEZ\\nreflectionVector.z*=-1.0;\\n#endif\\n\\n#ifdef REFLECTIONMAP_3D\\nreflectionCoords=reflectionVector;\\n#else\\nreflectionCoords=reflectionVector.xy;\\n#ifdef REFLECTIONMAP_PROJECTION\\nreflectionCoords/=reflectionVector.z;\\n#endif\\nreflectionCoords.y=1.0-reflectionCoords.y;\\n#endif\\n}\\n#define pbr_inline\\n#define inline\\nvoid sampleReflectionTexture(\\nconst in float alphaG,\\nconst in vec3 vReflectionMicrosurfaceInfos,\\nconst in vec2 vReflectionInfos,\\nconst in vec3 vReflectionColor,\\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\\nconst in float NdotVUnclamped,\\n#endif\\n#ifdef LINEARSPECULARREFLECTION\\nconst in float roughness,\\n#endif\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube reflectionSampler,\\nconst vec3 reflectionCoords,\\n#else\\nconst in sampler2D reflectionSampler,\\nconst vec2 reflectionCoords,\\n#endif\\n#ifndef LODBASEDMICROSFURACE\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube reflectionSamplerLow,\\nconst in samplerCube reflectionSamplerHigh,\\n#else\\nconst in sampler2D reflectionSamplerLow,\\nconst in sampler2D reflectionSamplerHigh,\\n#endif\\n#endif\\n#ifdef REALTIME_FILTERING\\nconst in vec2 vReflectionFilteringInfo,\\n#endif\\nout vec4 environmentRadiance\\n)\\n{\\n\\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\\n#elif defined(LINEARSPECULARREFLECTION)\\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\\n#else\\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\\n#endif\\n#ifdef LODBASEDMICROSFURACE\\n\\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\\n#ifdef LODINREFLECTIONALPHA\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\\n#else\\nfloat requestedReflectionLOD=reflectionLOD;\\n#endif\\n#ifdef REALTIME_FILTERING\\nenvironmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);\\n#else\\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\\n#endif\\n#else\\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\\nvec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);\\nif (lodReflectionNormalizedDoubled<1.0){\\nenvironmentRadiance=mix(\\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\\nenvironmentMid,\\nlodReflectionNormalizedDoubled\\n);\\n} else {\\nenvironmentRadiance=mix(\\nenvironmentMid,\\nsampleReflection(reflectionSamplerLow,reflectionCoords),\\nlodReflectionNormalizedDoubled-1.0\\n);\\n}\\n#endif\\n#ifdef RGBDREFLECTION\\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\\n#endif\\n#ifdef GAMMAREFLECTION\\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\\n#endif\\n\\nenvironmentRadiance.rgb*=vReflectionInfos.x;\\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\\n}\\n#define pbr_inline\\n#define inline\\nvoid reflectionBlock(\\nconst in vec3 vPositionW,\\nconst in vec3 normalW,\\nconst in float alphaG,\\nconst in vec3 vReflectionMicrosurfaceInfos,\\nconst in vec2 vReflectionInfos,\\nconst in vec3 vReflectionColor,\\n#ifdef ANISOTROPIC\\nconst in anisotropicOutParams anisotropicOut,\\n#endif\\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\\nconst in float NdotVUnclamped,\\n#endif\\n#ifdef LINEARSPECULARREFLECTION\\nconst in float roughness,\\n#endif\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube reflectionSampler,\\n#else\\nconst in sampler2D reflectionSampler,\\n#endif\\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\\nconst in vec3 vEnvironmentIrradiance,\\n#endif\\n#ifdef USESPHERICALFROMREFLECTIONMAP\\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\\nconst in mat4 reflectionMatrix,\\n#endif\\n#endif\\n#ifdef USEIRRADIANCEMAP\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube irradianceSampler,\\n#else\\nconst in sampler2D irradianceSampler,\\n#endif\\n#endif\\n#ifndef LODBASEDMICROSFURACE\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube reflectionSamplerLow,\\nconst in samplerCube reflectionSamplerHigh,\\n#else\\nconst in sampler2D reflectionSamplerLow,\\nconst in sampler2D reflectionSamplerHigh,\\n#endif\\n#endif\\n#ifdef REALTIME_FILTERING\\nconst in vec2 vReflectionFilteringInfo,\\n#endif\\nout reflectionOutParams outParams\\n)\\n{\\n\\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\\n#ifdef REFLECTIONMAP_3D\\nvec3 reflectionCoords=vec3(0.);\\n#else\\nvec2 reflectionCoords=vec2(0.);\\n#endif\\ncreateReflectionCoords(\\nvPositionW,\\nnormalW,\\n#ifdef ANISOTROPIC\\nanisotropicOut,\\n#endif\\nreflectionCoords\\n);\\nsampleReflectionTexture(\\nalphaG,\\nvReflectionMicrosurfaceInfos,\\nvReflectionInfos,\\nvReflectionColor,\\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\\nNdotVUnclamped,\\n#endif\\n#ifdef LINEARSPECULARREFLECTION\\nroughness,\\n#endif\\n#ifdef REFLECTIONMAP_3D\\nreflectionSampler,\\nreflectionCoords,\\n#else\\nreflectionSampler,\\nreflectionCoords,\\n#endif\\n#ifndef LODBASEDMICROSFURACE\\nreflectionSamplerLow,\\nreflectionSamplerHigh,\\n#endif\\n#ifdef REALTIME_FILTERING\\nvReflectionFilteringInfo,\\n#endif\\nenvironmentRadiance\\n);\\n\\nvec3 environmentIrradiance=vec3(0.,0.,0.);\\n#ifdef USESPHERICALFROMREFLECTIONMAP\\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\\nenvironmentIrradiance=vEnvironmentIrradiance;\\n#else\\n#ifdef ANISOTROPIC\\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;\\n#else\\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\\n#endif\\n#ifdef REFLECTIONMAP_OPPOSITEZ\\nirradianceVector.z*=-1.0;\\n#endif\\n#ifdef INVERTCUBICMAP\\nirradianceVector.y*=-1.0;\\n#endif\\n#if defined(REALTIME_FILTERING)\\nenvironmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);\\n#else\\nenvironmentIrradiance=computeEnvironmentIrradiance(irradianceVector);\\n#endif\\n#ifdef SS_TRANSLUCENCY\\noutParams.irradianceVector=irradianceVector;\\n#endif\\n#endif\\n#elif defined(USEIRRADIANCEMAP)\\nvec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);\\nenvironmentIrradiance=environmentIrradiance4.rgb;\\n#ifdef RGBDREFLECTION\\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradiance4);\\n#endif\\n#ifdef GAMMAREFLECTION\\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\\n#endif\\n#endif\\nenvironmentIrradiance*=vReflectionColor.rgb;\\noutParams.environmentRadiance=environmentRadiance;\\noutParams.environmentIrradiance=environmentIrradiance;\\noutParams.reflectionCoords=reflectionCoords;\\n}\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockReflection=Yo;var Ko=\"#ifdef SHEEN\\nstruct sheenOutParams\\n{\\nfloat sheenIntensity;\\nvec3 sheenColor;\\nfloat sheenRoughness;\\n#ifdef SHEEN_LINKWITHALBEDO\\nvec3 surfaceAlbedo;\\n#endif\\n#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\\nfloat sheenAlbedoScaling;\\n#endif\\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\\nvec3 finalSheenRadianceScaled;\\n#endif\\n#if DEBUGMODE>0\\nvec4 sheenMapData;\\nvec3 sheenEnvironmentReflectance;\\n#endif\\n};\\n#define pbr_inline\\n#define inline\\nvoid sheenBlock(\\nconst in vec4 vSheenColor,\\n#ifdef SHEEN_ROUGHNESS\\nconst in float vSheenRoughness,\\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\\nconst in vec4 sheenMapRoughnessData,\\n#endif\\n#endif\\nconst in float roughness,\\n#ifdef SHEEN_TEXTURE\\nconst in vec4 sheenMapData,\\n#endif\\nconst in float reflectance,\\n#ifdef SHEEN_LINKWITHALBEDO\\nconst in vec3 baseColor,\\nconst in vec3 surfaceAlbedo,\\n#endif\\n#ifdef ENVIRONMENTBRDF\\nconst in float NdotV,\\nconst in vec3 environmentBrdf,\\n#endif\\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\\nconst in vec2 AARoughnessFactors,\\nconst in vec3 vReflectionMicrosurfaceInfos,\\nconst in vec2 vReflectionInfos,\\nconst in vec3 vReflectionColor,\\nconst in vec4 vLightingIntensity,\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube reflectionSampler,\\nconst in vec3 reflectionCoords,\\n#else\\nconst in sampler2D reflectionSampler,\\nconst in vec2 reflectionCoords,\\n#endif\\nconst in float NdotVUnclamped,\\n#ifndef LODBASEDMICROSFURACE\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube reflectionSamplerLow,\\nconst in samplerCube reflectionSamplerHigh,\\n#else\\nconst in sampler2D reflectionSamplerLow,\\nconst in sampler2D reflectionSamplerHigh,\\n#endif\\n#endif\\n#ifdef REALTIME_FILTERING\\nconst in vec2 vReflectionFilteringInfo,\\n#endif\\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\\nconst in float seo,\\n#endif\\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\\nconst in float eho,\\n#endif\\n#endif\\nout sheenOutParams outParams\\n)\\n{\\nfloat sheenIntensity=vSheenColor.a;\\n#ifdef SHEEN_TEXTURE\\n#if DEBUGMODE>0\\noutParams.sheenMapData=sheenMapData;\\n#endif\\n#endif\\n#ifdef SHEEN_LINKWITHALBEDO\\nfloat sheenFactor=pow5(1.0-sheenIntensity);\\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\\nfloat sheenRoughness=sheenIntensity;\\noutParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;\\n#ifdef SHEEN_TEXTURE\\nsheenIntensity*=sheenMapData.a;\\n#endif\\n#else\\nvec3 sheenColor=vSheenColor.rgb;\\n#ifdef SHEEN_TEXTURE\\nsheenColor.rgb*=sheenMapData.rgb;\\n#endif\\n#ifdef SHEEN_ROUGHNESS\\nfloat sheenRoughness=vSheenRoughness;\\n#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE\\n#if defined(SHEEN_TEXTURE)\\nsheenRoughness*=sheenMapData.a;\\n#endif\\n#elif defined(SHEEN_TEXTURE_ROUGHNESS)\\n#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL\\nsheenRoughness*=sheenMapData.a;\\n#else\\nsheenRoughness*=sheenMapRoughnessData.a;\\n#endif\\n#endif\\n#else\\nfloat sheenRoughness=roughness;\\n#ifdef SHEEN_TEXTURE\\nsheenIntensity*=sheenMapData.a;\\n#endif\\n#endif\\n\\n#if !defined(SHEEN_ALBEDOSCALING)\\nsheenIntensity*=(1.-reflectance);\\n#endif\\n\\nsheenColor*=sheenIntensity;\\n#endif\\n\\n#ifdef ENVIRONMENTBRDF\\n\\n#ifdef SHEEN_ROUGHNESS\\nvec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);\\n#else\\nvec3 environmentSheenBrdf=environmentBrdf;\\n#endif\\n\\n#endif\\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\\n#ifdef SPECULARAA\\n\\nsheenAlphaG+=AARoughnessFactors.y;\\n#endif\\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\\nsampleReflectionTexture(\\nsheenAlphaG,\\nvReflectionMicrosurfaceInfos,\\nvReflectionInfos,\\nvReflectionColor,\\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\\nNdotVUnclamped,\\n#endif\\n#ifdef LINEARSPECULARREFLECTION\\nsheenRoughness,\\n#endif\\nreflectionSampler,\\nreflectionCoords,\\n#ifndef LODBASEDMICROSFURACE\\nreflectionSamplerLow,\\nreflectionSamplerHigh,\\n#endif\\n#ifdef REALTIME_FILTERING\\nvReflectionFilteringInfo,\\n#endif\\nenvironmentSheenRadiance\\n);\\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);\\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\\nsheenEnvironmentReflectance*=seo;\\n#endif\\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\\nsheenEnvironmentReflectance*=eho;\\n#endif\\n#if DEBUGMODE>0\\noutParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;\\n#endif\\noutParams.finalSheenRadianceScaled=\\nenvironmentSheenRadiance.rgb *\\nsheenEnvironmentReflectance *\\nvLightingIntensity.z;\\n\\n\\n\\n\\n\\n#endif\\n#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\\n\\n\\n\\noutParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;\\n#endif\\n\\noutParams.sheenIntensity=sheenIntensity;\\noutParams.sheenColor=sheenColor;\\noutParams.sheenRoughness=sheenRoughness;\\n}\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockSheen=Ko;var Qo=\"struct clearcoatOutParams\\n{\\nvec3 specularEnvironmentR0;\\nfloat conservationFactor;\\nvec3 clearCoatNormalW;\\nvec2 clearCoatAARoughnessFactors;\\nfloat clearCoatIntensity;\\nfloat clearCoatRoughness;\\n#ifdef REFLECTION\\nvec3 finalClearCoatRadianceScaled;\\n#endif\\n#ifdef CLEARCOAT_TINT\\nvec3 absorption;\\nfloat clearCoatNdotVRefract;\\nvec3 clearCoatColor;\\nfloat clearCoatThickness;\\n#endif\\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\\nvec3 energyConservationFactorClearCoat;\\n#endif\\n#if DEBUGMODE>0\\nmat3 TBNClearCoat;\\nvec2 clearCoatMapData;\\nvec4 clearCoatTintMapData;\\nvec4 environmentClearCoatRadiance;\\nfloat clearCoatNdotV;\\nvec3 clearCoatEnvironmentReflectance;\\n#endif\\n};\\n#ifdef CLEARCOAT\\n#define pbr_inline\\n#define inline\\nvoid clearcoatBlock(\\nconst in vec3 vPositionW,\\nconst in vec3 geometricNormalW,\\nconst in vec3 viewDirectionW,\\nconst in vec2 vClearCoatParams,\\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\\nconst in vec4 clearCoatMapRoughnessData,\\n#endif\\nconst in vec3 specularEnvironmentR0,\\n#ifdef CLEARCOAT_TEXTURE\\nconst in vec2 clearCoatMapData,\\n#endif\\n#ifdef CLEARCOAT_TINT\\nconst in vec4 vClearCoatTintParams,\\nconst in float clearCoatColorAtDistance,\\nconst in vec4 vClearCoatRefractionParams,\\n#ifdef CLEARCOAT_TINT_TEXTURE\\nconst in vec4 clearCoatTintMapData,\\n#endif\\n#endif\\n#ifdef CLEARCOAT_BUMP\\nconst in vec2 vClearCoatBumpInfos,\\nconst in vec4 clearCoatBumpMapData,\\nconst in vec2 vClearCoatBumpUV,\\n#if defined(TANGENT) && defined(NORMAL)\\nconst in mat3 vTBN,\\n#else\\nconst in vec2 vClearCoatTangentSpaceParams,\\n#endif\\n#ifdef OBJECTSPACE_NORMALMAP\\nconst in mat4 normalMatrix,\\n#endif\\n#endif\\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\\nconst in vec3 faceNormal,\\n#endif\\n#ifdef REFLECTION\\nconst in vec3 vReflectionMicrosurfaceInfos,\\nconst in vec2 vReflectionInfos,\\nconst in vec3 vReflectionColor,\\nconst in vec4 vLightingIntensity,\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube reflectionSampler,\\n#else\\nconst in sampler2D reflectionSampler,\\n#endif\\n#ifndef LODBASEDMICROSFURACE\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube reflectionSamplerLow,\\nconst in samplerCube reflectionSamplerHigh,\\n#else\\nconst in sampler2D reflectionSamplerLow,\\nconst in sampler2D reflectionSamplerHigh,\\n#endif\\n#endif\\n#ifdef REALTIME_FILTERING\\nconst in vec2 vReflectionFilteringInfo,\\n#endif\\n#endif\\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\\n#ifdef RADIANCEOCCLUSION\\nconst in float ambientMonochrome,\\n#endif\\n#endif\\nout clearcoatOutParams outParams\\n)\\n{\\n\\nfloat clearCoatIntensity=vClearCoatParams.x;\\nfloat clearCoatRoughness=vClearCoatParams.y;\\n#ifdef CLEARCOAT_TEXTURE\\nclearCoatIntensity*=clearCoatMapData.x;\\n#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE\\nclearCoatRoughness*=clearCoatMapData.y;\\n#endif\\n#if DEBUGMODE>0\\noutParams.clearCoatMapData=clearCoatMapData;\\n#endif\\n#endif\\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL\\nclearCoatRoughness*=clearCoatMapData.y;\\n#else\\nclearCoatRoughness*=clearCoatMapRoughnessData.y;\\n#endif\\n#endif\\noutParams.clearCoatIntensity=clearCoatIntensity;\\noutParams.clearCoatRoughness=clearCoatRoughness;\\n#ifdef CLEARCOAT_TINT\\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\\nfloat clearCoatThickness=vClearCoatTintParams.a;\\n#ifdef CLEARCOAT_TINT_TEXTURE\\nclearCoatColor*=clearCoatTintMapData.rgb;\\nclearCoatThickness*=clearCoatTintMapData.a;\\n#if DEBUGMODE>0\\noutParams.clearCoatTintMapData=clearCoatTintMapData;\\n#endif\\n#endif\\noutParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\\noutParams.clearCoatThickness=clearCoatThickness;\\n#endif\\n\\n\\n\\n\\n#ifdef CLEARCOAT_REMAP_F0\\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\\n#else\\nvec3 specularEnvironmentR0Updated=specularEnvironmentR0;\\n#endif\\noutParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\\n\\nvec3 clearCoatNormalW=geometricNormalW;\\n#ifdef CLEARCOAT_BUMP\\n#ifdef NORMALXYSCALE\\nfloat clearCoatNormalScale=1.0;\\n#else\\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\\n#endif\\n#if defined(TANGENT) && defined(NORMAL)\\nmat3 TBNClearCoat=vTBN;\\n#else\\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\\n#endif\\n#if DEBUGMODE>0\\noutParams.TBNClearCoat=TBNClearCoat;\\n#endif\\n#ifdef OBJECTSPACE_NORMALMAP\\nclearCoatNormalW=normalize(clearCoatBumpMapData.xyz*2.0-1.0);\\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\\n#else\\nclearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);\\n#endif\\n#endif\\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\\n#endif\\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\\n#endif\\noutParams.clearCoatNormalW=clearCoatNormalW;\\n\\noutParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\\n\\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\\n\\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\\n#if DEBUGMODE>0\\noutParams.clearCoatNdotV=clearCoatNdotV;\\n#endif\\n#ifdef CLEARCOAT_TINT\\n\\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\\n\\noutParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\\n#endif\\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\\n\\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);\\n#endif\\n\\n#if defined(REFLECTION)\\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\\n#ifdef SPECULARAA\\n\\nclearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;\\n#endif\\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\\n#ifdef REFLECTIONMAP_OPPOSITEZ\\nclearCoatReflectionVector.z*=-1.0;\\n#endif\\n\\n#ifdef REFLECTIONMAP_3D\\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\\n#else\\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\\n#ifdef REFLECTIONMAP_PROJECTION\\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\\n#endif\\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\\n#endif\\nsampleReflectionTexture(\\nclearCoatAlphaG,\\nvReflectionMicrosurfaceInfos,\\nvReflectionInfos,\\nvReflectionColor,\\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\\nclearCoatNdotVUnclamped,\\n#endif\\n#ifdef LINEARSPECULARREFLECTION\\nclearCoatRoughness,\\n#endif\\nreflectionSampler,\\nclearCoatReflectionCoords,\\n#ifndef LODBASEDMICROSFURACE\\nreflectionSamplerLow,\\nreflectionSamplerHigh,\\n#endif\\n#ifdef REALTIME_FILTERING\\nvReflectionFilteringInfo,\\n#endif\\nenvironmentClearCoatRadiance\\n);\\n#if DEBUGMODE>0\\noutParams.environmentClearCoatRadiance=environmentClearCoatRadiance;\\n#endif\\n\\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\\n#ifdef RADIANCEOCCLUSION\\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\\nclearCoatEnvironmentReflectance*=clearCoatSeo;\\n#endif\\n#ifdef HORIZONOCCLUSION\\n#ifdef BUMP\\n#ifdef REFLECTIONMAP_3D\\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);\\nclearCoatEnvironmentReflectance*=clearCoatEho;\\n#endif\\n#endif\\n#endif\\n#else\\n\\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\\n#endif\\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\\n#if DEBUGMODE>0\\noutParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;\\n#endif\\noutParams.finalClearCoatRadianceScaled=\\nenvironmentClearCoatRadiance.rgb *\\nclearCoatEnvironmentReflectance *\\nvLightingIntensity.z;\\n#endif\\n#if defined(CLEARCOAT_TINT)\\n\\noutParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);\\n#endif\\n\\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\\nfresnelIBLClearCoat*=clearCoatIntensity;\\noutParams.conservationFactor=(1.-fresnelIBLClearCoat);\\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\\noutParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);\\n#endif\\n}\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockClearcoat=Qo;var qo=\"struct subSurfaceOutParams\\n{\\nvec3 specularEnvironmentReflectance;\\n#ifdef SS_REFRACTION\\nvec3 finalRefraction;\\nvec3 surfaceAlbedo;\\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\\nfloat alpha;\\n#endif\\n#ifdef REFLECTION\\nfloat refractionFactorForIrradiance;\\n#endif\\n#endif\\n#ifdef SS_TRANSLUCENCY\\nvec3 transmittance;\\nfloat translucencyIntensity;\\n#ifdef REFLECTION\\nvec3 refractionIrradiance;\\n#endif\\n#endif\\n#if DEBUGMODE>0\\nvec4 thicknessMap;\\nvec4 environmentRefraction;\\nvec3 refractionTransmittance;\\n#endif\\n};\\n#ifdef SUBSURFACE\\n#define pbr_inline\\n#define inline\\nvoid subSurfaceBlock(\\nconst in vec3 vSubSurfaceIntensity,\\nconst in vec2 vThicknessParam,\\nconst in vec4 vTintColor,\\nconst in vec3 normalW,\\nconst in vec3 specularEnvironmentReflectance,\\n#ifdef SS_THICKNESSANDMASK_TEXTURE\\nconst in vec4 thicknessMap,\\n#endif\\n#ifdef REFLECTION\\n#ifdef SS_TRANSLUCENCY\\nconst in mat4 reflectionMatrix,\\n#ifdef USESPHERICALFROMREFLECTIONMAP\\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\\nconst in vec3 irradianceVector_,\\n#endif\\n#if defined(REALTIME_FILTERING)\\nconst in samplerCube reflectionSampler,\\nconst in vec2 vReflectionFilteringInfo,\\n#endif\\n#endif\\n#ifdef USEIRRADIANCEMAP\\n#ifdef REFLECTIONMAP_3D\\nconst in samplerCube irradianceSampler,\\n#else\\nconst in sampler2D irradianceSampler,\\n#endif\\n#endif\\n#endif\\n#endif\\n#ifdef SS_REFRACTION\\nconst in vec3 vPositionW,\\nconst in vec3 viewDirectionW,\\nconst in mat4 view,\\nconst in vec3 surfaceAlbedo,\\nconst in vec4 vRefractionInfos,\\nconst in mat4 refractionMatrix,\\nconst in vec3 vRefractionMicrosurfaceInfos,\\nconst in vec4 vLightingIntensity,\\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\\nconst in float alpha,\\n#endif\\n#ifdef SS_LODINREFRACTIONALPHA\\nconst in float NdotVUnclamped,\\n#endif\\n#ifdef SS_LINEARSPECULARREFRACTION\\nconst in float roughness,\\n#else\\nconst in float alphaG,\\n#endif\\n#ifdef SS_REFRACTIONMAP_3D\\nconst in samplerCube refractionSampler,\\n#ifndef LODBASEDMICROSFURACE\\nconst in samplerCube refractionSamplerLow,\\nconst in samplerCube refractionSamplerHigh,\\n#endif\\n#else\\nconst in sampler2D refractionSampler,\\n#ifndef LODBASEDMICROSFURACE\\nconst in sampler2D refractionSamplerLow,\\nconst in sampler2D refractionSamplerHigh,\\n#endif\\n#endif\\n#ifdef ANISOTROPIC\\nconst in anisotropicOutParams anisotropicOut,\\n#endif\\n#ifdef REALTIME_FILTERING\\nconst in vec2 vRefractionFilteringInfo,\\n#endif\\n#endif\\n#ifdef SS_TRANSLUCENCY\\nconst in vec3 vDiffusionDistance,\\n#endif\\nout subSurfaceOutParams outParams\\n)\\n{\\noutParams.specularEnvironmentReflectance=specularEnvironmentReflectance;\\n\\n\\n\\n#ifdef SS_REFRACTION\\nfloat refractionIntensity=vSubSurfaceIntensity.x;\\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\\nrefractionIntensity*=(1.0-alpha);\\n\\noutParams.alpha=1.0;\\n#endif\\n#endif\\n#ifdef SS_TRANSLUCENCY\\nfloat translucencyIntensity=vSubSurfaceIntensity.y;\\n#endif\\n#ifdef SS_THICKNESSANDMASK_TEXTURE\\nfloat thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;\\n#if DEBUGMODE>0\\noutParams.thicknessMap=thicknessMap;\\n#endif\\n#ifdef SS_MASK_FROM_THICKNESS_TEXTURE\\n#ifdef SS_REFRACTION\\nrefractionIntensity*=thicknessMap.g;\\n#endif\\n#ifdef SS_TRANSLUCENCY\\ntranslucencyIntensity*=thicknessMap.b;\\n#endif\\n#elif defined(SS_MASK_FROM_THICKNESS_TEXTURE_GLTF)\\n#ifdef SS_REFRACTION\\nrefractionIntensity*=thicknessMap.r;\\n#elif defined(SS_TRANSLUCENCY)\\ntranslucencyIntensity*=thicknessMap.r;\\n#endif\\nthickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;\\n#endif\\n#else\\nfloat thickness=vThicknessParam.y;\\n#endif\\n\\n\\n\\n#ifdef SS_TRANSLUCENCY\\nthickness=maxEps(thickness);\\nvec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);\\ntransmittance*=translucencyIntensity;\\noutParams.transmittance=transmittance;\\noutParams.translucencyIntensity=translucencyIntensity;\\n#endif\\n\\n\\n\\n#ifdef SS_REFRACTION\\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\\n#ifdef ANISOTROPIC\\nvec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);\\n#else\\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\\n#endif\\n#ifdef SS_REFRACTIONMAP_OPPOSITEZ\\nrefractionVector.z*=-1.0;\\n#endif\\n\\n#ifdef SS_REFRACTIONMAP_3D\\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\\nvec3 refractionCoords=refractionVector;\\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\\n#else\\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\\nrefractionCoords.y=1.0-refractionCoords.y;\\n#endif\\n#ifdef SS_LODINREFRACTIONALPHA\\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\\n#elif defined(SS_LINEARSPECULARREFRACTION)\\nfloat refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,roughness);\\n#else\\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);\\n#endif\\n#ifdef LODBASEDMICROSFURACE\\n\\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\\n#ifdef SS_LODINREFRACTIONALPHA\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\\n#else\\nfloat requestedRefractionLOD=refractionLOD;\\n#endif\\n#ifdef REALTIME_FILTERING\\nenvironmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);\\n#else\\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\\n#endif\\n#else\\nfloat lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\\nif (lodRefractionNormalizedDoubled<1.0){\\nenvironmentRefraction=mix(\\nsampleRefraction(refractionSamplerHigh,refractionCoords),\\nenvironmentRefractionMid,\\nlodRefractionNormalizedDoubled\\n);\\n} else {\\nenvironmentRefraction=mix(\\nenvironmentRefractionMid,\\nsampleRefraction(refractionSamplerLow,refractionCoords),\\nlodRefractionNormalizedDoubled-1.0\\n);\\n}\\n#endif\\n#ifdef SS_RGBDREFRACTION\\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\\n#endif\\n#ifdef SS_GAMMAREFRACTION\\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\\n#endif\\n\\nenvironmentRefraction.rgb*=vRefractionInfos.x;\\n#endif\\n\\n\\n\\n#ifdef SS_REFRACTION\\nvec3 refractionTransmittance=vec3(refractionIntensity);\\n#ifdef SS_THICKNESSANDMASK_TEXTURE\\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\\n\\n\\n\\n\\n\\nrefractionTransmittance*=cocaLambert(volumeAlbedo,thickness);\\n#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)\\n\\nfloat maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);\\nvec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);\\n\\nenvironmentRefraction.rgb*=volumeAlbedo;\\n#else\\n\\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\\nrefractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);\\n#endif\\n#ifdef SS_ALBEDOFORREFRACTIONTINT\\n\\nenvironmentRefraction.rgb*=surfaceAlbedo.rgb;\\n#endif\\n\\noutParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);\\n#ifdef REFLECTION\\n\\noutParams.refractionFactorForIrradiance=(1.-refractionIntensity);\\n\\n#endif\\n\\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\\noutParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);\\n\\nrefractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;\\n#if DEBUGMODE>0\\noutParams.refractionTransmittance=refractionTransmittance;\\n#endif\\noutParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;\\n#if DEBUGMODE>0\\noutParams.environmentRefraction=environmentRefraction;\\n#endif\\n#endif\\n\\n\\n\\n#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)\\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)\\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\\n#ifdef REFLECTIONMAP_OPPOSITEZ\\nirradianceVector.z*=-1.0;\\n#endif\\n#ifdef INVERTCUBICMAP\\nirradianceVector.y*=-1.0;\\n#endif\\n#else\\nvec3 irradianceVector=irradianceVector_;\\n#endif\\n#if defined(USESPHERICALFROMREFLECTIONMAP)\\n#if defined(REALTIME_FILTERING)\\nvec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);\\n#else\\nvec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);\\n#endif\\n#elif defined(USEIRRADIANCEMAP)\\n#ifdef REFLECTIONMAP_3D\\nvec3 irradianceCoords=irradianceVector;\\n#else\\nvec2 irradianceCoords=irradianceVector.xy;\\n#ifdef REFLECTIONMAP_PROJECTION\\nirradianceCoords/=irradianceVector.z;\\n#endif\\nirradianceCoords.y=1.0-irradianceCoords.y;\\n#endif\\nvec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);\\n#ifdef RGBDREFLECTION\\nrefractionIrradiance.rgb=fromRGBD(refractionIrradiance);\\n#endif\\n#ifdef GAMMAREFLECTION\\nrefractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);\\n#endif\\n#else\\nvec4 refractionIrradiance=vec4(0.);\\n#endif\\nrefractionIrradiance.rgb*=transmittance;\\noutParams.refractionIrradiance=refractionIrradiance.rgb;\\n#endif\\n}\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockSubSurface=qo;var Zo=\"vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\\n#ifdef NORMAL\\nvec3 normalW=normalize(vNormalW);\\n#else\\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\\n#endif\\nvec3 geometricNormalW=normalW;\\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\\ngeometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockNormalGeometric=Zo;i(134);var Jo=\"#if defined(FORCENORMALFORWARD) && defined(NORMAL)\\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\\n#if defined(TWOSIDEDLIGHTING)\\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\\n#endif\\nnormalW*=sign(dot(normalW,faceNormal));\\n#endif\\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\\nnormalW=gl_FrontFacing ? normalW : -normalW;\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockNormalFinal=Jo;i(162);var $o=\"#ifdef LIGHTMAP\\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\\n#ifdef RGBDLIGHTMAP\\nlightmapColor.rgb=fromRGBD(lightmapColor);\\n#endif\\n#ifdef GAMMALIGHTMAP\\nlightmapColor.rgb=toLinearSpace(lightmapColor.rgb);\\n#endif\\nlightmapColor.rgb*=vLightmapInfos.y;\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockLightmapInit=$o;var ea=\"float NdotVUnclamped=dot(normalW,viewDirectionW);\\n\\nfloat NdotV=absEps(NdotVUnclamped);\\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\\n#ifdef SPECULARAA\\n\\nalphaG+=AARoughnessFactors.y;\\n#endif\\n#if defined(ENVIRONMENTBRDF)\\n\\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness);\\n#endif\\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\\n#ifdef RADIANCEOCCLUSION\\n#ifdef AMBIENTINGRAYSCALE\\nfloat ambientMonochrome=aoOut.ambientOcclusionColor.r;\\n#else\\nfloat ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);\\n#endif\\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\\n#endif\\n#ifdef HORIZONOCCLUSION\\n#ifdef BUMP\\n#ifdef REFLECTIONMAP_3D\\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);\\n#endif\\n#endif\\n#endif\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockGeometryInfo=ea;var ta=\"float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);\\nvec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;\\n#ifdef METALLICWORKFLOW\\nvec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);\\n#else\\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);\\n#endif\\n\\n#ifdef ALPHAFRESNEL\\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\\nspecularEnvironmentR90=specularEnvironmentR90*reflectance90;\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockReflectance0=ta;var ia=\"#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);\\n#ifdef RADIANCEOCCLUSION\\nspecularEnvironmentReflectance*=seo;\\n#endif\\n#ifdef HORIZONOCCLUSION\\n#ifdef BUMP\\n#ifdef REFLECTIONMAP_3D\\nspecularEnvironmentReflectance*=eho;\\n#endif\\n#endif\\n#endif\\n#else\\n\\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\\n#endif\\n#ifdef CLEARCOAT\\nspecularEnvironmentReflectance*=clearcoatOut.conservationFactor;\\n#if defined(CLEARCOAT_TINT)\\nspecularEnvironmentReflectance*=clearcoatOut.absorption;\\n#endif\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockReflectance=ia;var na=\"vec3 diffuseBase=vec3(0.,0.,0.);\\n#ifdef SPECULARTERM\\nvec3 specularBase=vec3(0.,0.,0.);\\n#endif\\n#ifdef CLEARCOAT\\nvec3 clearCoatBase=vec3(0.,0.,0.);\\n#endif\\n#ifdef SHEEN\\nvec3 sheenBase=vec3(0.,0.,0.);\\n#endif\\n\\npreLightingInfo preInfo;\\nlightingInfo info;\\nfloat shadow=1.;\\n#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\\nvec3 absorption=vec3(0.);\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockDirectLighting=na;var ra=\"\\n\\n\\n\\n#if defined(ENVIRONMENTBRDF)\\n#ifdef MS_BRDF_ENERGY_CONSERVATION\\nvec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);\\n#endif\\n#endif\\n#ifndef METALLICWORKFLOW\\n#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION\\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\\n#endif\\n#endif\\n#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)\\nsurfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;\\n#endif\\n\\n#ifdef REFLECTION\\nvec3 finalIrradiance=reflectionOut.environmentIrradiance;\\n#if defined(CLEARCOAT)\\nfinalIrradiance*=clearcoatOut.conservationFactor;\\n#if defined(CLEARCOAT_TINT)\\nfinalIrradiance*=clearcoatOut.absorption;\\n#endif\\n#endif\\n#if defined(SS_REFRACTION)\\nfinalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;\\n#endif\\n#if defined(SS_TRANSLUCENCY)\\nfinalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);\\nfinalIrradiance+=subSurfaceOut.refractionIrradiance;\\n#endif\\nfinalIrradiance*=surfaceAlbedo.rgb;\\nfinalIrradiance*=vLightingIntensity.z;\\nfinalIrradiance*=aoOut.ambientOcclusionColor;\\n#endif\\n\\n#ifdef SPECULARTERM\\nvec3 finalSpecular=specularBase;\\nfinalSpecular=max(finalSpecular,0.0);\\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\\nfinalSpecularScaled*=energyConservationFactor;\\n#endif\\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\\nfinalSpecularScaled*=sheenOut.sheenAlbedoScaling;\\n#endif\\n#endif\\n\\n#ifdef REFLECTION\\nvec3 finalRadiance=reflectionOut.environmentRadiance.rgb;\\nfinalRadiance*=subSurfaceOut.specularEnvironmentReflectance;\\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\\nfinalRadianceScaled*=energyConservationFactor;\\n#endif\\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\\nfinalRadianceScaled*=sheenOut.sheenAlbedoScaling;\\n#endif\\n#endif\\n\\n#ifdef SHEEN\\nvec3 finalSheen=sheenBase*sheenOut.sheenColor;\\nfinalSheen=max(finalSheen,0.0);\\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\\n#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)\\nsheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;\\n#if defined(CLEARCOAT_TINT)\\nsheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;\\n#endif\\n#endif\\n#endif\\n\\n#ifdef CLEARCOAT\\nvec3 finalClearCoat=clearCoatBase;\\nfinalClearCoat=max(finalClearCoat,0.0);\\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\\nfinalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;\\n#endif\\n#ifdef SS_REFRACTION\\nsubSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;\\n#ifdef CLEARCOAT_TINT\\nsubSurfaceOut.finalRefraction*=clearcoatOut.absorption;\\n#endif\\n#endif\\n#endif\\n\\n#ifdef ALPHABLEND\\nfloat luminanceOverAlpha=0.0;\\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\\n#if defined(CLEARCOAT)\\nluminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);\\n#endif\\n#endif\\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\\n#endif\\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\\n#endif\\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)\\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\\n#endif\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockFinalLitComponents=ra;var oa=\"\\nvec3 finalDiffuse=diffuseBase;\\nfinalDiffuse*=surfaceAlbedo.rgb;\\nfinalDiffuse=max(finalDiffuse,0.0);\\nfinalDiffuse*=vLightingIntensity.x;\\n\\nvec3 finalAmbient=vAmbientColor;\\nfinalAmbient*=surfaceAlbedo.rgb;\\n\\nvec3 finalEmissive=vEmissiveColor;\\n#ifdef EMISSIVE\\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\\nfinalEmissive*=vEmissiveInfos.y;\\n#endif\\nfinalEmissive*=vLightingIntensity.y;\\n\\n#ifdef AMBIENT\\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);\\n#else\\nvec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;\\n#endif\\nfinalAmbient*=aoOut.ambientOcclusionColor;\\nfinalDiffuse*=ambientOcclusionForDirectDiffuse;\\n\";ai.a.IncludesShadersStore.pbrBlockFinalUnlitComponents=oa;var aa=\"vec4 finalColor=vec4(\\nfinalAmbient +\\nfinalDiffuse +\\n#ifndef UNLIT\\n#ifdef REFLECTION\\nfinalIrradiance +\\n#endif\\n#ifdef SPECULARTERM\\nfinalSpecularScaled +\\n#endif\\n#ifdef SHEEN\\nfinalSheenScaled +\\n#endif\\n#ifdef CLEARCOAT\\nfinalClearCoatScaled +\\n#endif\\n#ifdef REFLECTION\\nfinalRadianceScaled +\\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\\nsheenOut.finalSheenRadianceScaled +\\n#endif\\n#ifdef CLEARCOAT\\nclearcoatOut.finalClearCoatRadianceScaled +\\n#endif\\n#endif\\n#ifdef SS_REFRACTION\\nsubSurfaceOut.finalRefraction +\\n#endif\\n#endif\\nfinalEmissive,\\nalpha);\\n\\n#ifdef LIGHTMAP\\n#ifndef LIGHTMAPEXCLUDED\\n#ifdef USELIGHTMAPASSHADOWMAP\\nfinalColor.rgb*=lightmapColor.rgb;\\n#else\\nfinalColor.rgb+=lightmapColor.rgb;\\n#endif\\n#endif\\n#endif\\n#define CUSTOM_FRAGMENT_BEFORE_FOG\\n\\nfinalColor=max(finalColor,0.0);\\n\";ai.a.IncludesShadersStore.pbrBlockFinalColorComposition=aa;i(155);var sa=\"#ifdef IMAGEPROCESSINGPOSTPROCESS\\n\\n\\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\\n#else\\n\\nfinalColor=applyImageProcessing(finalColor);\\n#endif\\nfinalColor.a*=visibility;\\n#ifdef PREMULTIPLYALPHA\\n\\nfinalColor.rgb*=finalColor.a;\\n#endif\\n\";ai.a.IncludesShadersStore.pbrBlockImageProcessing=sa;var ca=\"#if DEBUGMODE>0\\nif (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {\\n\\n#if DEBUGMODE == 1\\ngl_FragColor.rgb=vPositionW.rgb;\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 2 && defined(NORMAL)\\ngl_FragColor.rgb=vNormalW.rgb;\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 3 && defined(BUMP) || DEBUGMODE == 3 && defined(PARALLAX) || DEBUGMODE == 3 && defined(ANISOTROPIC)\\n\\ngl_FragColor.rgb=TBN[0];\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 4 && defined(BUMP) || DEBUGMODE == 4 && defined(PARALLAX) || DEBUGMODE == 4 && defined(ANISOTROPIC)\\n\\ngl_FragColor.rgb=TBN[1];\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 5\\n\\ngl_FragColor.rgb=normalW;\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 6 && defined(MAINUV1)\\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\\n#elif DEBUGMODE == 7 && defined(MAINUV2)\\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\\n#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\\n\\ngl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\\n\\ngl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\\n\\ngl_FragColor.rgb=clearcoatOut.clearCoatNormalW;\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\\ngl_FragColor.rgb=anisotropicOut.anisotropicNormal;\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 12 && defined(ANISOTROPIC)\\ngl_FragColor.rgb=anisotropicOut.anisotropicTangent;\\n#define DEBUGMODE_NORMALIZE\\n#elif DEBUGMODE == 13 && defined(ANISOTROPIC)\\ngl_FragColor.rgb=anisotropicOut.anisotropicBitangent;\\n#define DEBUGMODE_NORMALIZE\\n\\n#elif DEBUGMODE == 20 && defined(ALBEDO)\\ngl_FragColor.rgb=albedoTexture.rgb;\\n#elif DEBUGMODE == 21 && defined(AMBIENT)\\ngl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;\\n#elif DEBUGMODE == 22 && defined(OPACITY)\\ngl_FragColor.rgb=opacityMap.rgb;\\n#elif DEBUGMODE == 23 && defined(EMISSIVE)\\ngl_FragColor.rgb=emissiveColorTex.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 24 && defined(LIGHTMAP)\\ngl_FragColor.rgb=lightmapColor.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\\ngl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;\\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\\ngl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);\\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\\ngl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;\\n#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\\ngl_FragColor.rgb=sheenOut.sheenMapData.rgb;\\n#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\\ngl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;\\n#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)\\ngl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;\\n\\n#elif DEBUGMODE == 40 && defined(SS_REFRACTION)\\n\\ngl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 41 && defined(REFLECTION)\\ngl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\\ngl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;\\n#define DEBUGMODE_GAMMA\\n\\n#elif DEBUGMODE == 50\\ngl_FragColor.rgb=diffuseBase.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\\ngl_FragColor.rgb=specularBase.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\\ngl_FragColor.rgb=clearCoatBase.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 53 && defined(SHEEN)\\ngl_FragColor.rgb=sheenBase.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 54 && defined(REFLECTION)\\ngl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;\\n#define DEBUGMODE_GAMMA\\n\\n#elif DEBUGMODE == 60\\ngl_FragColor.rgb=surfaceAlbedo.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 61\\ngl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 62 && defined(METALLICWORKFLOW)\\ngl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);\\n#elif DEBUGMODE == 71 && defined(METALLICWORKFLOW)\\ngl_FragColor.rgb=reflectivityOut.metallicF0;\\n#elif DEBUGMODE == 63\\ngl_FragColor.rgb=vec3(roughness);\\n#elif DEBUGMODE == 64\\ngl_FragColor.rgb=vec3(alphaG);\\n#elif DEBUGMODE == 65\\ngl_FragColor.rgb=vec3(NdotV);\\n#elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\\ngl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);\\n#elif DEBUGMODE == 68 && defined(CLEARCOAT)\\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);\\n#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)\\ngl_FragColor.rgb=subSurfaceOut.transmittance;\\n#elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)\\ngl_FragColor.rgb=subSurfaceOut.refractionTransmittance;\\n\\n#elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)\\ngl_FragColor.rgb=vec3(seo);\\n#elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)\\ngl_FragColor.rgb=vec3(eho);\\n#elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)\\ngl_FragColor.rgb=vec3(energyConservationFactor);\\n#elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\\ngl_FragColor.rgb=specularEnvironmentReflectance;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\\ngl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)\\ngl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;\\n#define DEBUGMODE_GAMMA\\n#elif DEBUGMODE == 86 && defined(ALPHABLEND)\\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\\n#elif DEBUGMODE == 87\\ngl_FragColor.rgb=vec3(alpha);\\n#endif\\ngl_FragColor.rgb*=vDebugMode.y;\\n#ifdef DEBUGMODE_NORMALIZE\\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\\n#endif\\n#ifdef DEBUGMODE_GAMMA\\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\\n#endif\\ngl_FragColor.a=1.0;\\n#ifdef PREPASS\\ngl_FragData[0]=toLinearSpace(gl_FragColor);\\ngl_FragData[1]=vec4(0.,0.,0.,0.);\\n#endif\\nreturn;\\n}\\n#endif\";ai.a.IncludesShadersStore.pbrDebug=ca;var la=\"#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\\n#extension GL_OES_standard_derivatives : enable\\n#endif\\n#ifdef LODBASEDMICROSFURACE\\n#extension GL_EXT_shader_texture_lod : enable\\n#endif\\n#define CUSTOM_FRAGMENT_BEGIN\\n#ifdef LOGARITHMICDEPTH\\n#extension GL_EXT_frag_depth : enable\\n#endif\\n#include[SCENE_MRT_COUNT]\\nprecision highp float;\\n\\n#ifndef FROMLINEARSPACE\\n#define FROMLINEARSPACE\\n#endif\\n\\n#include<__decl__pbrFragment>\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include\\n#include\\n#include\\n#include\\n\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#ifdef REFLECTION\\n#include\\n#endif\\n#define CUSTOM_FRAGMENT_DEFINITIONS\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n#include\\n\\nvoid main(void) {\\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\\n#include\\n\\n#include\\n#include\\n#include\\n\\nalbedoOpacityOutParams albedoOpacityOut;\\n#ifdef ALBEDO\\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\\n#endif\\n#ifdef OPACITY\\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\\n#endif\\nalbedoOpacityBlock(\\nvAlbedoColor,\\n#ifdef ALBEDO\\nalbedoTexture,\\nvAlbedoInfos,\\n#endif\\n#ifdef OPACITY\\nopacityMap,\\nvOpacityInfos,\\n#endif\\n#ifdef DETAIL\\ndetailColor,\\nvDetailInfos,\\n#endif\\nalbedoOpacityOut\\n);\\nvec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;\\nfloat alpha=albedoOpacityOut.alpha;\\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\\n#include\\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\\n\\nambientOcclusionOutParams aoOut;\\n#ifdef AMBIENT\\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;\\n#endif\\nambientOcclusionBlock(\\n#ifdef AMBIENT\\nambientOcclusionColorMap,\\nvAmbientInfos,\\n#endif\\naoOut\\n);\\n#include\\n#ifdef UNLIT\\nvec3 diffuseBase=vec3(1.,1.,1.);\\n#else\\n\\nvec3 baseColor=surfaceAlbedo;\\nreflectivityOutParams reflectivityOut;\\n#if defined(REFLECTIVITY)\\nvec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\\nvec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;\\n#ifndef METALLICWORKFLOW\\nsurfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);\\nsurfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;\\n#endif\\n#endif\\n#if defined(MICROSURFACEMAP)\\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\\n#endif\\n#ifdef METALLICWORKFLOW\\nvec4 metallicReflectanceFactors=vMetallicReflectanceFactors;\\n#ifdef METALLIC_REFLECTANCE\\nvec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);\\nmetallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);\\nmetallicReflectanceFactors*=metallicReflectanceFactorsMap;\\n#endif\\n#endif\\nreflectivityBlock(\\nvReflectivityColor,\\n#ifdef METALLICWORKFLOW\\nsurfaceAlbedo,\\nmetallicReflectanceFactors,\\n#endif\\n#ifdef REFLECTIVITY\\nvReflectivityInfos,\\nsurfaceMetallicOrReflectivityColorMap,\\n#endif\\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\\naoOut.ambientOcclusionColor,\\n#endif\\n#ifdef MICROSURFACEMAP\\nmicroSurfaceTexel,\\n#endif\\n#ifdef DETAIL\\ndetailColor,\\nvDetailInfos,\\n#endif\\nreflectivityOut\\n);\\nfloat microSurface=reflectivityOut.microSurface;\\nfloat roughness=reflectivityOut.roughness;\\n#ifdef METALLICWORKFLOW\\nsurfaceAlbedo=reflectivityOut.surfaceAlbedo;\\n#endif\\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\\naoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;\\n#endif\\n\\n#ifdef ALPHAFRESNEL\\n#if defined(ALPHATEST) || defined(ALPHABLEND)\\nalphaFresnelOutParams alphaFresnelOut;\\nalphaFresnelBlock(\\nnormalW,\\nviewDirectionW,\\nalpha,\\nmicroSurface,\\nalphaFresnelOut\\n);\\nalpha=alphaFresnelOut.alpha;\\n#endif\\n#endif\\n\\n#include\\n\\n#ifdef ANISOTROPIC\\nanisotropicOutParams anisotropicOut;\\n#ifdef ANISOTROPIC_TEXTURE\\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\\n#endif\\nanisotropicBlock(\\nvAnisotropy,\\n#ifdef ANISOTROPIC_TEXTURE\\nanisotropyMapData,\\n#endif\\nTBN,\\nnormalW,\\nviewDirectionW,\\nanisotropicOut\\n);\\n#endif\\n\\n#ifdef REFLECTION\\nreflectionOutParams reflectionOut;\\nreflectionBlock(\\nvPositionW,\\nnormalW,\\nalphaG,\\nvReflectionMicrosurfaceInfos,\\nvReflectionInfos,\\nvReflectionColor,\\n#ifdef ANISOTROPIC\\nanisotropicOut,\\n#endif\\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\\nNdotVUnclamped,\\n#endif\\n#ifdef LINEARSPECULARREFLECTION\\nroughness,\\n#endif\\nreflectionSampler,\\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\\nvEnvironmentIrradiance,\\n#endif\\n#ifdef USESPHERICALFROMREFLECTIONMAP\\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\\nreflectionMatrix,\\n#endif\\n#endif\\n#ifdef USEIRRADIANCEMAP\\nirradianceSampler,\\n#endif\\n#ifndef LODBASEDMICROSFURACE\\nreflectionSamplerLow,\\nreflectionSamplerHigh,\\n#endif\\n#ifdef REALTIME_FILTERING\\nvReflectionFilteringInfo,\\n#endif\\nreflectionOut\\n);\\n#endif\\n\\n#include\\n\\n#ifdef SHEEN\\nsheenOutParams sheenOut;\\n#ifdef SHEEN_TEXTURE\\nvec4 sheenMapData=toLinearSpace(texture2D(sheenSampler,vSheenUV+uvOffset))*vSheenInfos.y;\\n#endif\\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\\nvec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;\\n#endif\\nsheenBlock(\\nvSheenColor,\\n#ifdef SHEEN_ROUGHNESS\\nvSheenRoughness,\\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\\nsheenMapRoughnessData,\\n#endif\\n#endif\\nroughness,\\n#ifdef SHEEN_TEXTURE\\nsheenMapData,\\n#endif\\nreflectance,\\n#ifdef SHEEN_LINKWITHALBEDO\\nbaseColor,\\nsurfaceAlbedo,\\n#endif\\n#ifdef ENVIRONMENTBRDF\\nNdotV,\\nenvironmentBrdf,\\n#endif\\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\\nAARoughnessFactors,\\nvReflectionMicrosurfaceInfos,\\nvReflectionInfos,\\nvReflectionColor,\\nvLightingIntensity,\\nreflectionSampler,\\nreflectionOut.reflectionCoords,\\nNdotVUnclamped,\\n#ifndef LODBASEDMICROSFURACE\\nreflectionSamplerLow,\\nreflectionSamplerHigh,\\n#endif\\n#ifdef REALTIME_FILTERING\\nvReflectionFilteringInfo,\\n#endif\\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\\nseo,\\n#endif\\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\\neho,\\n#endif\\n#endif\\nsheenOut\\n);\\n#ifdef SHEEN_LINKWITHALBEDO\\nsurfaceAlbedo=sheenOut.surfaceAlbedo;\\n#endif\\n#endif\\n\\nclearcoatOutParams clearcoatOut;\\n#ifdef CLEARCOAT\\n#ifdef CLEARCOAT_TEXTURE\\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\\n#endif\\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\\nvec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;\\n#endif\\n#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\\nvec4 clearCoatTintMapData=toLinearSpace(texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset));\\n#endif\\n#ifdef CLEARCOAT_BUMP\\nvec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);\\n#endif\\nclearcoatBlock(\\nvPositionW,\\ngeometricNormalW,\\nviewDirectionW,\\nvClearCoatParams,\\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\\nclearCoatMapRoughnessData,\\n#endif\\nspecularEnvironmentR0,\\n#ifdef CLEARCOAT_TEXTURE\\nclearCoatMapData,\\n#endif\\n#ifdef CLEARCOAT_TINT\\nvClearCoatTintParams,\\nclearCoatColorAtDistance,\\nvClearCoatRefractionParams,\\n#ifdef CLEARCOAT_TINT_TEXTURE\\nclearCoatTintMapData,\\n#endif\\n#endif\\n#ifdef CLEARCOAT_BUMP\\nvClearCoatBumpInfos,\\nclearCoatBumpMapData,\\nvClearCoatBumpUV,\\n#if defined(TANGENT) && defined(NORMAL)\\nvTBN,\\n#else\\nvClearCoatTangentSpaceParams,\\n#endif\\n#ifdef OBJECTSPACE_NORMALMAP\\nnormalMatrix,\\n#endif\\n#endif\\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\\nfaceNormal,\\n#endif\\n#ifdef REFLECTION\\nvReflectionMicrosurfaceInfos,\\nvReflectionInfos,\\nvReflectionColor,\\nvLightingIntensity,\\nreflectionSampler,\\n#ifndef LODBASEDMICROSFURACE\\nreflectionSamplerLow,\\nreflectionSamplerHigh,\\n#endif\\n#ifdef REALTIME_FILTERING\\nvReflectionFilteringInfo,\\n#endif\\n#endif\\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\\n#ifdef RADIANCEOCCLUSION\\nambientMonochrome,\\n#endif\\n#endif\\nclearcoatOut\\n);\\n#else\\nclearcoatOut.specularEnvironmentR0=specularEnvironmentR0;\\n#endif\\n\\n#include\\n\\nsubSurfaceOutParams subSurfaceOut;\\n#ifdef SUBSURFACE\\n#ifdef SS_THICKNESSANDMASK_TEXTURE\\nvec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);\\n#endif\\nsubSurfaceBlock(\\nvSubSurfaceIntensity,\\nvThicknessParam,\\nvTintColor,\\nnormalW,\\nspecularEnvironmentReflectance,\\n#ifdef SS_THICKNESSANDMASK_TEXTURE\\nthicknessMap,\\n#endif\\n#ifdef REFLECTION\\n#ifdef SS_TRANSLUCENCY\\nreflectionMatrix,\\n#ifdef USESPHERICALFROMREFLECTIONMAP\\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\\nreflectionOut.irradianceVector,\\n#endif\\n#if defined(REALTIME_FILTERING)\\nreflectionSampler,\\nvReflectionFilteringInfo,\\n#endif\\n#endif\\n#ifdef USEIRRADIANCEMAP\\nirradianceSampler,\\n#endif\\n#endif\\n#endif\\n#ifdef SS_REFRACTION\\nvPositionW,\\nviewDirectionW,\\nview,\\nsurfaceAlbedo,\\nvRefractionInfos,\\nrefractionMatrix,\\nvRefractionMicrosurfaceInfos,\\nvLightingIntensity,\\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\\nalpha,\\n#endif\\n#ifdef SS_LODINREFRACTIONALPHA\\nNdotVUnclamped,\\n#endif\\n#ifdef SS_LINEARSPECULARREFRACTION\\nroughness,\\n#else\\nalphaG,\\n#endif\\nrefractionSampler,\\n#ifndef LODBASEDMICROSFURACE\\nrefractionSamplerLow,\\nrefractionSamplerHigh,\\n#endif\\n#ifdef ANISOTROPIC\\nanisotropicOut,\\n#endif\\n#ifdef REALTIME_FILTERING\\nvRefractionFilteringInfo,\\n#endif\\n#endif\\n#ifdef SS_TRANSLUCENCY\\nvDiffusionDistance,\\n#endif\\nsubSurfaceOut\\n);\\n#ifdef SS_REFRACTION\\nsurfaceAlbedo=subSurfaceOut.surfaceAlbedo;\\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\\nalpha=subSurfaceOut.alpha;\\n#endif\\n#endif\\n#else\\nsubSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;\\n#endif\\n\\n#include\\n#include[0..maxSimultaneousLights]\\n\\n#include\\n#endif\\n#include\\n#include\\n#include\\n#include(color,finalColor)\\n#include\\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\\n#ifdef PREPASS\\n#ifdef PREPASS_POSITION\\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);\\n#endif\\n#ifdef PREPASS_VELOCITY\\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\\nvec2 velocity=abs(a-b);\\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\\n#endif\\n#ifdef PREPASS_IRRADIANCE\\nvec3 irradiance=finalDiffuse;\\n#ifndef UNLIT\\n#ifdef REFLECTION\\nirradiance+=finalIrradiance;\\n#endif\\n#endif\\nvec3 sqAlbedo=sqrt(surfaceAlbedo);\\n#ifdef SS_SCATTERING\\ngl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a);\\nirradiance/=sqAlbedo;\\n#else\\ngl_FragData[0]=finalColor;\\nfloat scatteringDiffusionProfile=255.;\\n#endif\\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,scatteringDiffusionProfile/255.);\\n#else\\ngl_FragData[0]=vec4(finalColor.rgb,finalColor.a);\\n#endif\\n#ifdef PREPASS_DEPTHNORMAL\\ngl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);\\n#endif\\n#ifdef PREPASS_ALBEDO\\ngl_FragData[PREPASS_ALBEDO_INDEX]=vec4(sqAlbedo,1.0);\\n#endif\\n#ifdef PREPASS_REFLECTIVITY\\n#if defined(REFLECTIVITY)\\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,1.0);\\n#else\\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);\\n#endif\\n#endif\\n#endif\\n#if !defined(PREPASS) || defined(WEBGL2)\\ngl_FragColor=finalColor;\\n#endif\\n#include\\n}\\n\";ai.a.ShadersStore.pbrPixelShader=la;var ua=\"uniform mat4 view;\\nuniform mat4 viewProjection;\\n#ifdef ALBEDO\\nuniform mat4 albedoMatrix;\\nuniform vec2 vAlbedoInfos;\\n#endif\\n#ifdef AMBIENT\\nuniform mat4 ambientMatrix;\\nuniform vec4 vAmbientInfos;\\n#endif\\n#ifdef OPACITY\\nuniform mat4 opacityMatrix;\\nuniform vec2 vOpacityInfos;\\n#endif\\n#ifdef EMISSIVE\\nuniform vec2 vEmissiveInfos;\\nuniform mat4 emissiveMatrix;\\n#endif\\n#ifdef LIGHTMAP\\nuniform vec2 vLightmapInfos;\\nuniform mat4 lightmapMatrix;\\n#endif\\n#ifdef REFLECTIVITY\\nuniform vec3 vReflectivityInfos;\\nuniform mat4 reflectivityMatrix;\\n#endif\\n#ifdef METALLIC_REFLECTANCE\\nuniform vec2 vMetallicReflectanceInfos;\\nuniform mat4 metallicReflectanceMatrix;\\n#endif\\n#ifdef MICROSURFACEMAP\\nuniform vec2 vMicroSurfaceSamplerInfos;\\nuniform mat4 microSurfaceSamplerMatrix;\\n#endif\\n#ifdef BUMP\\nuniform vec3 vBumpInfos;\\nuniform mat4 bumpMatrix;\\n#endif\\n#ifdef POINTSIZE\\nuniform float pointSize;\\n#endif\\n\\n#ifdef REFLECTION\\nuniform vec2 vReflectionInfos;\\nuniform mat4 reflectionMatrix;\\n#endif\\n\\n#ifdef CLEARCOAT\\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\\nuniform vec4 vClearCoatInfos;\\n#endif\\n#ifdef CLEARCOAT_TEXTURE\\nuniform mat4 clearCoatMatrix;\\n#endif\\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\\nuniform mat4 clearCoatRoughnessMatrix;\\n#endif\\n#ifdef CLEARCOAT_BUMP\\nuniform vec2 vClearCoatBumpInfos;\\nuniform mat4 clearCoatBumpMatrix;\\n#endif\\n#ifdef CLEARCOAT_TINT_TEXTURE\\nuniform vec2 vClearCoatTintInfos;\\nuniform mat4 clearCoatTintMatrix;\\n#endif\\n#endif\\n\\n#ifdef ANISOTROPIC\\n#ifdef ANISOTROPIC_TEXTURE\\nuniform vec2 vAnisotropyInfos;\\nuniform mat4 anisotropyMatrix;\\n#endif\\n#endif\\n\\n#ifdef SHEEN\\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\\nuniform vec4 vSheenInfos;\\n#endif\\n#ifdef SHEEN_TEXTURE\\nuniform mat4 sheenMatrix;\\n#endif\\n#ifdef SHEEN_TEXTURE_ROUGHNESS\\nuniform mat4 sheenRoughnessMatrix;\\n#endif\\n#endif\\n\\n#ifdef SUBSURFACE\\n#ifdef SS_REFRACTION\\nuniform vec4 vRefractionInfos;\\nuniform mat4 refractionMatrix;\\n#endif\\n#ifdef SS_THICKNESSANDMASK_TEXTURE\\nuniform vec2 vThicknessInfos;\\nuniform mat4 thicknessMatrix;\\n#endif\\n#endif\\n\";ai.a.IncludesShadersStore.pbrVertexDeclaration=ua;i(163),i(164),i(93),i(94),i(100),i(165),i(156),i(158);var ha=\"precision highp float;\\n#include<__decl__pbrVertex>\\n#define CUSTOM_VERTEX_BEGIN\\n\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#ifdef TANGENT\\nattribute vec4 tangent;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef MAINUV1\\nvarying vec2 vMainUV1;\\n#endif\\n#ifdef MAINUV2\\nvarying vec2 vMainUV2;\\n#endif\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n#include\\n\\n#include\\n#include\\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\\nvarying vec2 vAlbedoUV;\\n#endif\\n#if defined(DETAIL) && DETAILDIRECTUV == 0\\nvarying vec2 vDetailUV;\\n#endif\\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\\nvarying vec2 vAmbientUV;\\n#endif\\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\\nvarying vec2 vOpacityUV;\\n#endif\\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\\nvarying vec2 vEmissiveUV;\\n#endif\\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\\nvarying vec2 vLightmapUV;\\n#endif\\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\\nvarying vec2 vReflectivityUV;\\n#endif\\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\\nvarying vec2 vMicroSurfaceSamplerUV;\\n#endif\\n#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0\\nvarying vec2 vMetallicReflectanceUV;\\n#endif\\n#if defined(BUMP) && BUMPDIRECTUV == 0\\nvarying vec2 vBumpUV;\\n#endif\\n#ifdef CLEARCOAT\\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\\nvarying vec2 vClearCoatUV;\\n#endif\\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0\\nvarying vec2 vClearCoatRoughnessUV;\\n#endif\\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\\nvarying vec2 vClearCoatBumpUV;\\n#endif\\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\\nvarying vec2 vClearCoatTintUV;\\n#endif\\n#endif\\n#ifdef SHEEN\\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\\nvarying vec2 vSheenUV;\\n#endif\\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0\\nvarying vec2 vSheenRoughnessUV;\\n#endif\\n#endif\\n#ifdef ANISOTROPIC\\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\\nvarying vec2 vAnisotropyUV;\\n#endif\\n#endif\\n#ifdef SUBSURFACE\\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\\nvarying vec2 vThicknessUV;\\n#endif\\n#endif\\n\\nvarying vec3 vPositionW;\\n#if DEBUGMODE>0\\nvarying vec4 vClipSpacePosition;\\n#endif\\n#ifdef NORMAL\\nvarying vec3 vNormalW;\\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\\nvarying vec3 vEnvironmentIrradiance;\\n#include\\n#endif\\n#endif\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\n#include\\n#include\\n#include\\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\\n#include\\n#include[0..maxSimultaneousMorphTargets]\\n#ifdef REFLECTIONMAP_SKYBOX\\nvarying vec3 vPositionUVW;\\n#endif\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvarying vec3 vDirectionW;\\n#endif\\n#include\\n#define CUSTOM_VERTEX_DEFINITIONS\\nvoid main(void) {\\n#define CUSTOM_VERTEX_MAIN_BEGIN\\nvec3 positionUpdated=position;\\n#ifdef NORMAL\\nvec3 normalUpdated=normal;\\n#endif\\n#ifdef TANGENT\\nvec4 tangentUpdated=tangent;\\n#endif\\n#ifdef UV1\\nvec2 uvUpdated=uv;\\n#endif\\n#include[0..maxSimultaneousMorphTargets]\\n#ifdef REFLECTIONMAP_SKYBOX\\nvPositionUVW=positionUpdated;\\n#endif\\n#define CUSTOM_VERTEX_UPDATE_POSITION\\n#define CUSTOM_VERTEX_UPDATE_NORMAL\\n#include\\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\\n\\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\\n#endif\\n#include\\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\\nvPositionW=vec3(worldPos);\\n#include\\n#ifdef NORMAL\\nmat3 normalWorld=mat3(finalWorld);\\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\\nvNormalW=normalize(normalWorld*vNormalW);\\n#else\\n#ifdef NONUNIFORMSCALING\\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\\n#endif\\nvNormalW=normalize(normalWorld*normalUpdated);\\n#endif\\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\\n#ifdef REFLECTIONMAP_OPPOSITEZ\\nreflectionVector.z*=-1.0;\\n#endif\\nvEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);\\n#endif\\n#endif\\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\\n#ifdef MULTIVIEW\\nif (gl_ViewID_OVR == 0u) {\\ngl_Position=viewProjection*worldPos;\\n} else {\\ngl_Position=viewProjectionR*worldPos;\\n}\\n#else\\ngl_Position=viewProjection*worldPos;\\n#endif\\n#if DEBUGMODE>0\\nvClipSpacePosition=gl_Position;\\n#endif\\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\\n#endif\\n\\n#ifndef UV1\\nvec2 uvUpdated=vec2(0.,0.);\\n#endif\\n#ifndef UV2\\nvec2 uv2=vec2(0.,0.);\\n#endif\\n#ifdef MAINUV1\\nvMainUV1=uvUpdated;\\n#endif\\n#ifdef MAINUV2\\nvMainUV2=uv2;\\n#endif\\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\\nif (vAlbedoInfos.x == 0.)\\n{\\nvAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(DETAIL) && DETAILDIRECTUV == 0\\nif (vDetailInfos.x == 0.)\\n{\\nvDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\\nif (vAmbientInfos.x == 0.)\\n{\\nvAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\\nif (vOpacityInfos.x == 0.)\\n{\\nvOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\\nif (vEmissiveInfos.x == 0.)\\n{\\nvEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\\nif (vLightmapInfos.x == 0.)\\n{\\nvLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\\nif (vReflectivityInfos.x == 0.)\\n{\\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\\nif (vMicroSurfaceSamplerInfos.x == 0.)\\n{\\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0\\nif (vMetallicReflectanceInfos.x == 0.)\\n{\\nvMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(BUMP) && BUMPDIRECTUV == 0\\nif (vBumpInfos.x == 0.)\\n{\\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#ifdef CLEARCOAT\\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\\nif (vClearCoatInfos.x == 0.)\\n{\\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0\\nif (vClearCoatInfos.z == 0.)\\n{\\nvClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\\nif (vClearCoatBumpInfos.x == 0.)\\n{\\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\\nif (vClearCoatTintInfos.x == 0.)\\n{\\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#endif\\n#ifdef SHEEN\\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\\nif (vSheenInfos.x == 0.)\\n{\\nvSheenUV=vec2(sheenMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0\\nif (vSheenInfos.z == 0.)\\n{\\nvSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#endif\\n#ifdef ANISOTROPIC\\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\\nif (vAnisotropyInfos.x == 0.)\\n{\\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#endif\\n#ifdef SUBSURFACE\\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\\nif (vThicknessInfos.x == 0.)\\n{\\nvThicknessUV=vec2(thicknessMatrix*vec4(uvUpdated,1.0,0.0));\\n}\\nelse\\n{\\nvThicknessUV=vec2(thicknessMatrix*vec4(uv2,1.0,0.0));\\n}\\n#endif\\n#endif\\n\\n#include\\n\\n#include\\n\\n#include\\n\\n#include[0..maxSimultaneousLights]\\n\\n#ifdef VERTEXCOLOR\\nvColor=color;\\n#endif\\n\\n#ifdef POINTSIZE\\ngl_PointSize=pointSize;\\n#endif\\n\\n#include\\n#define CUSTOM_VERTEX_MAIN_END\\n}\";ai.a.ShadersStore.pbrVertexShader=ha;var da=i(92),fa={effect:null,subMesh:null},pa=function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.NUM_SAMPLES=\"0\",t.REALTIME_FILTERING=!1,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.GAMMAALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.DETAIL=!1,t.DETAILDIRECTUV=0,t.DETAIL_NORMALBLENDMETHOD=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=\"0.5\",t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.LINEARALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.METALLIC_REFLECTANCE=!1,t.METALLIC_REFLECTANCEDIRECTUV=0,t.ENVIRONMENTBRDF=!1,t.ENVIRONMENTBRDF_RGBD=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.OBJECTSPACE_NORMALMAP=!1,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.GAMMALIGHTMAP=!1,t.RGBDLIGHTMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USEIRRADIANCEMAP=!1,t.SPHERICAL_HARMONICS=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.LINEARSPECULARREFLECTION=!1,t.RADIANCEOCCLUSION=!1,t.HORIZONOCCLUSION=!1,t.INSTANCES=!1,t.THIN_INSTANCES=!1,t.PREPASS=!1,t.PREPASS_IRRADIANCE=!1,t.PREPASS_IRRADIANCE_INDEX=-1,t.PREPASS_ALBEDO=!1,t.PREPASS_ALBEDO_INDEX=-1,t.PREPASS_DEPTHNORMAL=!1,t.PREPASS_DEPTHNORMAL_INDEX=-1,t.PREPASS_POSITION=!1,t.PREPASS_POSITION_INDEX=-1,t.PREPASS_VELOCITY=!1,t.PREPASS_VELOCITY_INDEX=-1,t.PREPASS_REFLECTIVITY=!1,t.PREPASS_REFLECTIVITY_INDEX=-1,t.SCENE_MRT_COUNT=0,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.BONETEXTURE=!1,t.BONES_VELOCITY_ENABLED=!1,t.NONUNIFORMSCALING=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_UV=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.MULTIVIEW=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.SPECULARAA=!1,t.CLEARCOAT=!1,t.CLEARCOAT_DEFAULTIOR=!1,t.CLEARCOAT_TEXTURE=!1,t.CLEARCOAT_TEXTURE_ROUGHNESS=!1,t.CLEARCOAT_TEXTUREDIRECTUV=0,t.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL=!1,t.CLEARCOAT_BUMP=!1,t.CLEARCOAT_BUMPDIRECTUV=0,t.CLEARCOAT_REMAP_F0=!0,t.CLEARCOAT_TINT=!1,t.CLEARCOAT_TINT_TEXTURE=!1,t.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,t.ANISOTROPIC=!1,t.ANISOTROPIC_TEXTURE=!1,t.ANISOTROPIC_TEXTUREDIRECTUV=0,t.BRDF_V_HEIGHT_CORRELATED=!1,t.MS_BRDF_ENERGY_CONSERVATION=!1,t.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!1,t.SHEEN=!1,t.SHEEN_TEXTURE=!1,t.SHEEN_TEXTURE_ROUGHNESS=!1,t.SHEEN_TEXTUREDIRECTUV=0,t.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0,t.SHEEN_LINKWITHALBEDO=!1,t.SHEEN_ROUGHNESS=!1,t.SHEEN_ALBEDOSCALING=!1,t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,t.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=!1,t.SUBSURFACE=!1,t.SS_REFRACTION=!1,t.SS_TRANSLUCENCY=!1,t.SS_SCATTERING=!1,t.SS_THICKNESSANDMASK_TEXTURE=!1,t.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,t.SS_REFRACTIONMAP_3D=!1,t.SS_REFRACTIONMAP_OPPOSITEZ=!1,t.SS_LODINREFRACTIONALPHA=!1,t.SS_GAMMAREFRACTION=!1,t.SS_RGBDREFRACTION=!1,t.SS_LINEARSPECULARREFRACTION=!1,t.SS_LINKREFRACTIONTOTRANSPARENCY=!1,t.SS_ALBEDOFORREFRACTIONTINT=!1,t.SS_MASK_FROM_THICKNESS_TEXTURE=!1,t.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=!1,t.UNLIT=!1,t.DEBUGMODE=0,t.rebuild(),t}return Object(h.d)(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=\"0.5\",this.PBR=!0},t}(oo.a),_a=function(e){function t(i,n){var r=e.call(this,i,n)||this;return r._directIntensity=1,r._emissiveIntensity=1,r._environmentIntensity=1,r._specularIntensity=1,r._lightingInfos=new a.f(r._directIntensity,r._emissiveIntensity,r._environmentIntensity,r._specularIntensity),r._disableBumpMap=!1,r._albedoTexture=null,r._ambientTexture=null,r._ambientTextureStrength=1,r._ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,r._opacityTexture=null,r._reflectionTexture=null,r._emissiveTexture=null,r._reflectivityTexture=null,r._metallicTexture=null,r._metallic=null,r._roughness=null,r._metallicF0Factor=1,r._metallicReflectanceColor=s.a.White(),r._metallicReflectanceTexture=null,r._microSurfaceTexture=null,r._bumpTexture=null,r._lightmapTexture=null,r._ambientColor=new s.a(0,0,0),r._albedoColor=new s.a(1,1,1),r._reflectivityColor=new s.a(1,1,1),r._reflectionColor=new s.a(1,1,1),r._emissiveColor=new s.a(0,0,0),r._microSurface=.9,r._useLightmapAsShadowmap=!1,r._useHorizonOcclusion=!0,r._useRadianceOcclusion=!0,r._useAlphaFromAlbedoTexture=!1,r._useSpecularOverAlpha=!0,r._useMicroSurfaceFromReflectivityMapAlpha=!1,r._useRoughnessFromMetallicTextureAlpha=!0,r._useRoughnessFromMetallicTextureGreen=!1,r._useMetallnessFromMetallicTextureBlue=!1,r._useAmbientOcclusionFromMetallicTextureRed=!1,r._useAmbientInGrayScale=!1,r._useAutoMicroSurfaceFromReflectivityMap=!1,r._lightFalloff=t.LIGHTFALLOFF_PHYSICAL,r._useRadianceOverAlpha=!0,r._useObjectSpaceNormalMap=!1,r._useParallax=!1,r._useParallaxOcclusion=!1,r._parallaxScaleBias=.05,r._disableLighting=!1,r._maxSimultaneousLights=4,r._invertNormalMapX=!1,r._invertNormalMapY=!1,r._twoSidedLighting=!1,r._alphaCutOff=.4,r._forceAlphaTest=!1,r._useAlphaFresnel=!1,r._useLinearAlphaFresnel=!1,r._environmentBRDFTexture=null,r._forceIrradianceInFragment=!1,r._realTimeFiltering=!1,r._realTimeFilteringQuality=g.a.TEXTURE_FILTERING_QUALITY_LOW,r._forceNormalForward=!1,r._enableSpecularAntiAliasing=!1,r._imageProcessingObserver=null,r._renderTargets=new oi.a(16),r._globalAmbientColor=new s.a(0,0,0),r._useLogarithmicDepth=!1,r._unlit=!1,r._debugMode=0,r.debugMode=0,r.debugLimit=-1,r.debugFactor=1,r.clearCoat=new Eo(r._markAllSubMeshesAsTexturesDirty.bind(r)),r.anisotropy=new So(r._markAllSubMeshesAsTexturesDirty.bind(r)),r.brdf=new Ao(r._markAllSubMeshesAsMiscDirty.bind(r)),r.sheen=new Po(r._markAllSubMeshesAsTexturesDirty.bind(r)),r.detailMap=new da.a(r._markAllSubMeshesAsTexturesDirty.bind(r)),r._rebuildInParallel=!1,r._attachImageProcessingConfiguration(null),r.getRenderTargetTextures=function(){return r._renderTargets.reset(),so.a.ReflectionTextureEnabled&&r._reflectionTexture&&r._reflectionTexture.isRenderTarget&&r._renderTargets.push(r._reflectionTexture),r.subSurface.fillRenderTargetTextures(r._renderTargets),r._renderTargets},r._environmentBRDFTexture=To.GetEnvironmentBRDFTexture(n),r.subSurface=new Co(r._markAllSubMeshesAsTexturesDirty.bind(r),r._markScenePrePassDirty.bind(r),n),r.prePassConfiguration=new Ro.a,r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"realTimeFiltering\",{get:function(){return this._realTimeFiltering},set:function(e){this._realTimeFiltering=e,this.markAsDirty(g.a.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"realTimeFilteringQuality\",{get:function(){return this._realTimeFilteringQuality},set:function(e){this._realTimeFilteringQuality=e,this.markAsDirty(g.a.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"canRenderToMRT\",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){t._markAllSubMeshesAsImageProcessingDirty()}))))},Object.defineProperty(t.prototype,\"hasRenderTargetTextures\",{get:function(){return!!(so.a.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||this.subSurface.hasRenderTargetTextures()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"PBRBaseMaterial\"},Object.defineProperty(t.prototype,\"useLogarithmicDepth\",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"_disableAlphaBlending\",{get:function(){return this.subSurface.disableAlphaBlending||this._transparencyMode===t.PBRMATERIAL_OPAQUE||this._transparencyMode===t.PBRMATERIAL_ALPHATEST},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this.subSurface.disableAlphaBlending&&(this._hasAlphaChannel()&&(null==this._transparencyMode||this._transparencyMode===t.PBRMATERIAL_ALPHATEST))},t.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==t.PBRMATERIAL_OPAQUE},t.prototype._hasAlphaChannel=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha||null!=this._opacityTexture},t.prototype.getAlphaTestTexture=function(){return this._albedoTexture},t.prototype.isReadyForSubMesh=function(e,t,i){if(t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new pa);var n=t._materialDefines;if(this._isReadyForSubMesh(t))return!0;var r=this.getScene(),o=r.getEngine();if(n._areTexturesDirty&&r.texturesEnabled){if(this._albedoTexture&&so.a.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&so.a.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&so.a.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var a=this._getReflectionTexture();if(a&&so.a.ReflectionTextureEnabled){if(!a.isReadyOrNotBlocking())return!1;if(a.irradianceTexture&&!a.irradianceTexture.isReadyOrNotBlocking())return!1}if(this._lightmapTexture&&so.a.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&so.a.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(so.a.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._metallicReflectanceTexture&&!this._metallicReflectanceTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&so.a.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&so.a.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(!(this.subSurface.isReadyForSubMesh(n,r)&&this.clearCoat.isReadyForSubMesh(n,r,o,this._disableBumpMap)&&this.sheen.isReadyForSubMesh(n,r)&&this.anisotropy.isReadyForSubMesh(n,r)&&this.detailMap.isReadyForSubMesh(n,r)))return!1;if(n._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;o.getCaps().standardDerivatives||e.isVerticesDataPresent(Qi.b.NormalKind)||(e.createNormals(!0),m.a.Warn(\"PBRMaterial: Normals have been created for the mesh: \"+e.name));var s=t.effect,c=n._areLightsDisposed,l=this._prepareEffect(e,n,this.onCompiled,this.onError,i,null,t.getRenderingMesh().hasThinInstances);if(l)if(this._onEffectCreatedObservable&&(fa.effect=l,fa.subMesh=t,this._onEffectCreatedObservable.notifyObservers(fa)),this.allowShaderHotSwapping&&s&&!l.isReady()){if(l=s,this._rebuildInParallel=!0,n.markAsUnprocessed(),c)return n._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,r.resetCachedMaterial(),t.setEffect(l,n),this.buildUniformLayout();return!(!t.effect||!t.effect.isReady())&&(n._renderId=r.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.isMetallicWorkflow=function(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)},t.prototype._prepareEffect=function(e,t,i,n,r,o,a){if(void 0===i&&(i=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),this._prepareDefines(e,t,r,o,a),!t.isDirty)return null;t.markAsProcessed();var s=this.getScene().getEngine(),c=new po.a,l=0;t.USESPHERICALINVERTEX&&c.addFallback(l++,\"USESPHERICALINVERTEX\"),t.FOG&&c.addFallback(l,\"FOG\"),t.SPECULARAA&&c.addFallback(l,\"SPECULARAA\"),t.POINTSIZE&&c.addFallback(l,\"POINTSIZE\"),t.LOGARITHMICDEPTH&&c.addFallback(l,\"LOGARITHMICDEPTH\"),t.PARALLAX&&c.addFallback(l,\"PARALLAX\"),t.PARALLAXOCCLUSION&&c.addFallback(l++,\"PARALLAXOCCLUSION\"),l=So.AddFallbacks(t,c,l),l=So.AddFallbacks(t,c,l),l=Co.AddFallbacks(t,c,l),l=Po.AddFallbacks(t,c,l),t.ENVIRONMENTBRDF&&c.addFallback(l++,\"ENVIRONMENTBRDF\"),t.TANGENT&&c.addFallback(l++,\"TANGENT\"),t.BUMP&&c.addFallback(l++,\"BUMP\"),l=ro.a.HandleFallbacksForShadows(t,c,this._maxSimultaneousLights,l++),t.SPECULARTERM&&c.addFallback(l++,\"SPECULARTERM\"),t.USESPHERICALFROMREFLECTIONMAP&&c.addFallback(l++,\"USESPHERICALFROMREFLECTIONMAP\"),t.USEIRRADIANCEMAP&&c.addFallback(l++,\"USEIRRADIANCEMAP\"),t.LIGHTMAP&&c.addFallback(l++,\"LIGHTMAP\"),t.NORMAL&&c.addFallback(l++,\"NORMAL\"),t.AMBIENT&&c.addFallback(l++,\"AMBIENT\"),t.EMISSIVE&&c.addFallback(l++,\"EMISSIVE\"),t.VERTEXCOLOR&&c.addFallback(l++,\"VERTEXCOLOR\"),t.MORPHTARGETS&&c.addFallback(l++,\"MORPHTARGETS\"),t.MULTIVIEW&&c.addFallback(0,\"MULTIVIEW\");var u=[Qi.b.PositionKind];t.NORMAL&&u.push(Qi.b.NormalKind),t.TANGENT&&u.push(Qi.b.TangentKind),t.UV1&&u.push(Qi.b.UVKind),t.UV2&&u.push(Qi.b.UV2Kind),t.VERTEXCOLOR&&u.push(Qi.b.ColorKind),ro.a.PrepareAttributesForBones(u,e,t,c),ro.a.PrepareAttributesForInstances(u,t),ro.a.PrepareAttributesForMorphTargets(u,e,t);var h=\"pbr\",d=[\"world\",\"view\",\"viewProjection\",\"vEyePosition\",\"vLightsType\",\"vAmbientColor\",\"vAlbedoColor\",\"vReflectivityColor\",\"vMetallicReflectanceFactors\",\"vEmissiveColor\",\"visibility\",\"vReflectionColor\",\"vFogInfos\",\"vFogColor\",\"pointSize\",\"vAlbedoInfos\",\"vAmbientInfos\",\"vOpacityInfos\",\"vReflectionInfos\",\"vReflectionPosition\",\"vReflectionSize\",\"vEmissiveInfos\",\"vReflectivityInfos\",\"vReflectionFilteringInfo\",\"vMetallicReflectanceInfos\",\"vMicroSurfaceSamplerInfos\",\"vBumpInfos\",\"vLightmapInfos\",\"mBones\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"albedoMatrix\",\"ambientMatrix\",\"opacityMatrix\",\"reflectionMatrix\",\"emissiveMatrix\",\"reflectivityMatrix\",\"normalMatrix\",\"microSurfaceSamplerMatrix\",\"bumpMatrix\",\"lightmapMatrix\",\"metallicReflectanceMatrix\",\"vLightingIntensity\",\"logarithmicDepthConstant\",\"vSphericalX\",\"vSphericalY\",\"vSphericalZ\",\"vSphericalXX_ZZ\",\"vSphericalYY_ZZ\",\"vSphericalZZ\",\"vSphericalXY\",\"vSphericalYZ\",\"vSphericalZX\",\"vSphericalL00\",\"vSphericalL1_1\",\"vSphericalL10\",\"vSphericalL11\",\"vSphericalL2_2\",\"vSphericalL2_1\",\"vSphericalL20\",\"vSphericalL21\",\"vSphericalL22\",\"vReflectionMicrosurfaceInfos\",\"vTangentSpaceParams\",\"boneTextureWidth\",\"vDebugMode\"],f=[\"albedoSampler\",\"reflectivitySampler\",\"ambientSampler\",\"emissiveSampler\",\"bumpSampler\",\"lightmapSampler\",\"opacitySampler\",\"reflectionSampler\",\"reflectionSamplerLow\",\"reflectionSamplerHigh\",\"irradianceSampler\",\"microSurfaceSampler\",\"environmentBrdfSampler\",\"boneSampler\",\"metallicReflectanceSampler\"],p=[\"Material\",\"Scene\"];da.a.AddUniforms(d),da.a.AddSamplers(f),Co.AddUniforms(d),Co.AddSamplers(f),Eo.AddUniforms(d),Eo.AddSamplers(f),So.AddUniforms(d),So.AddSamplers(f),Po.AddUniforms(d),Po.AddSamplers(f),Ro.a.AddUniforms(d),Ro.a.AddSamplers(d),ji.a&&(ji.a.PrepareUniforms(d,t),ji.a.PrepareSamplers(f,t)),ro.a.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:f,defines:t,maxSimultaneousLights:this._maxSimultaneousLights});var _={};this.customShaderNameResolve&&(h=this.customShaderNameResolve(h,d,p,f,t,u,_));var m=t.toString();return s.createEffect(h,{attributes:u,uniformsNames:d,uniformBuffersNames:p,samplers:f,defines:m,fallbacks:c,onCompiled:i,onError:n,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS},processFinalCode:_.processFinalCode,multiTarget:t.PREPASS},s)},t.prototype._prepareDefines=function(e,i,n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=!1);var a=this.getScene(),s=a.getEngine();if(ro.a.PrepareDefinesForLights(a,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,ro.a.PrepareDefinesForMultiview(a,i),ro.a.PrepareDefinesForPrePass(a,i,this.canRenderToMRT),i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){if(i._needUVs=!1,a.texturesEnabled){a.getEngine().getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&so.a.DiffuseTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._albedoTexture,i,\"ALBEDO\"),i.GAMMAALBEDO=this._albedoTexture.gammaSpace):i.ALBEDO=!1,this._ambientTexture&&so.a.AmbientTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._ambientTexture,i,\"AMBIENT\"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&so.a.OpacityTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._opacityTexture,i,\"OPACITY\"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;var c=this._getReflectionTexture();if(c&&so.a.ReflectionTextureEnabled){switch(i.REFLECTION=!0,i.GAMMAREFLECTION=c.gammaSpace,i.RGBDREFLECTION=c.isRGBD,i.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!c.invertZ:c.invertZ,i.LODINREFLECTIONALPHA=c.lodLevelInAlpha,i.LINEARSPECULARREFLECTION=c.linearSpecularLOD,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(i.NUM_SAMPLES=\"\"+this.realTimeFilteringQuality,s.webGLVersion>1&&(i.NUM_SAMPLES=i.NUM_SAMPLES+\"u\"),i.REALTIME_FILTERING=!0):i.REALTIME_FILTERING=!1,c.coordinatesMode===Ke.a.INVCUBIC_MODE&&(i.INVERTCUBICMAP=!0),i.REFLECTIONMAP_3D=c.isCube,i.REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,c.coordinatesMode){case Ke.a.EXPLICIT_MODE:i.REFLECTIONMAP_EXPLICIT=!0;break;case Ke.a.PLANAR_MODE:i.REFLECTIONMAP_PLANAR=!0;break;case Ke.a.PROJECTION_MODE:i.REFLECTIONMAP_PROJECTION=!0;break;case Ke.a.SKYBOX_MODE:i.REFLECTIONMAP_SKYBOX=!0;break;case Ke.a.SPHERICAL_MODE:i.REFLECTIONMAP_SPHERICAL=!0;break;case Ke.a.EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ke.a.CUBIC_MODE:case Ke.a.INVCUBIC_MODE:default:i.REFLECTIONMAP_CUBIC=!0,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!!c.boundingBoxSize}c.coordinatesMode!==Ke.a.SKYBOX_MODE&&(c.irradianceTexture?(i.USEIRRADIANCEMAP=!0,i.USESPHERICALFROMREFLECTIONMAP=!1):c.isCube&&(i.USESPHERICALFROMREFLECTIONMAP=!0,i.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||a.getEngine().getCaps().maxVaryingVectors<=8?i.USESPHERICALINVERTEX=!1:i.USESPHERICALINVERTEX=!0))}else i.REFLECTION=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.USESPHERICALFROMREFLECTIONMAP=!1,i.USEIRRADIANCEMAP=!1,i.USESPHERICALINVERTEX=!1,i.REFLECTIONMAP_OPPOSITEZ=!1,i.LODINREFLECTIONALPHA=!1,i.GAMMAREFLECTION=!1,i.RGBDREFLECTION=!1,i.LINEARSPECULARREFLECTION=!1;this._lightmapTexture&&so.a.LightmapTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._lightmapTexture,i,\"LIGHTMAP\"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,i.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):i.LIGHTMAP=!1,this._emissiveTexture&&so.a.EmissiveTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._emissiveTexture,i,\"EMISSIVE\"):i.EMISSIVE=!1,so.a.SpecularTextureEnabled?(this._metallicTexture?(ro.a.PrepareDefinesForMergedUV(this._metallicTexture,i,\"REFLECTIVITY\"),i.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,i.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,i.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed):this._reflectivityTexture?(ro.a.PrepareDefinesForMergedUV(this._reflectivityTexture,i,\"REFLECTIVITY\"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):i.REFLECTIVITY=!1,this._metallicReflectanceTexture?ro.a.PrepareDefinesForMergedUV(this._metallicReflectanceTexture,i,\"METALLIC_REFLECTANCE\"):i.METALLIC_REFLECTANCE=!1,this._microSurfaceTexture?ro.a.PrepareDefinesForMergedUV(this._microSurfaceTexture,i,\"MICROSURFACEMAP\"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),a.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&so.a.BumpTextureEnabled&&!this._disableBumpMap?(ro.a.PrepareDefinesForMergedUV(this._bumpTexture,i,\"BUMP\"),this._useParallax&&this._albedoTexture&&so.a.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):i.BUMP=!1,this._environmentBRDFTexture&&so.a.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?i.ALPHAFROMALBEDO=!0:i.ALPHAFROMALBEDO=!1}i.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===t.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===t.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.SPECULARAA=a.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?\".\":\"\"),i.PREMULTIPLYALPHA=this.alphaMode===g.a.ALPHA_PREMULTIPLIED||this.alphaMode===g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,i.ALPHABLEND=this.needAlphaBlendingForMesh(e),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(ro.a.PrepareDefinesForMisc(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,i),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(Qi.b.NormalKind),i.DEBUGMODE=this._debugMode),this.detailMap.prepareDefines(i,a),this.subSurface.prepareDefines(i,a),this.clearCoat.prepareDefines(i,a),this.anisotropy.prepareDefines(i,e,a),this.brdf.prepareDefines(i),this.sheen.prepareDefines(i,a),ro.a.PrepareDefinesForFrameBoundValues(a,s,i,!!n,r,o),ro.a.PrepareDefinesForAttributes(e,i,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,t,i){var n=this,r=Object(h.a)({clipPlane:!1,useInstances:!1},i),o=new pa,a=this._prepareEffect(e,o,void 0,void 0,r.useInstances,r.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(fa.effect=a,fa.subMesh=null,this._onEffectCreatedObservable.notifyObservers(fa)),a.isReady()?t&&t(this):a.onCompileObservable.add((function(){t&&t(n)}))},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform(\"vAlbedoInfos\",2),e.addUniform(\"vAmbientInfos\",4),e.addUniform(\"vOpacityInfos\",2),e.addUniform(\"vEmissiveInfos\",2),e.addUniform(\"vLightmapInfos\",2),e.addUniform(\"vReflectivityInfos\",3),e.addUniform(\"vMicroSurfaceSamplerInfos\",2),e.addUniform(\"vReflectionInfos\",2),e.addUniform(\"vReflectionFilteringInfo\",2),e.addUniform(\"vReflectionPosition\",3),e.addUniform(\"vReflectionSize\",3),e.addUniform(\"vBumpInfos\",3),e.addUniform(\"albedoMatrix\",16),e.addUniform(\"ambientMatrix\",16),e.addUniform(\"opacityMatrix\",16),e.addUniform(\"emissiveMatrix\",16),e.addUniform(\"lightmapMatrix\",16),e.addUniform(\"reflectivityMatrix\",16),e.addUniform(\"microSurfaceSamplerMatrix\",16),e.addUniform(\"bumpMatrix\",16),e.addUniform(\"vTangentSpaceParams\",2),e.addUniform(\"reflectionMatrix\",16),e.addUniform(\"vReflectionColor\",3),e.addUniform(\"vAlbedoColor\",4),e.addUniform(\"vLightingIntensity\",4),e.addUniform(\"vReflectionMicrosurfaceInfos\",3),e.addUniform(\"pointSize\",1),e.addUniform(\"vReflectivityColor\",4),e.addUniform(\"vEmissiveColor\",3),e.addUniform(\"visibility\",1),e.addUniform(\"vMetallicReflectanceFactors\",4),e.addUniform(\"vMetallicReflectanceInfos\",2),e.addUniform(\"metallicReflectanceMatrix\",16),Eo.PrepareUniformBuffer(e),So.PrepareUniformBuffer(e),Po.PrepareUniformBuffer(e),Co.PrepareUniformBuffer(e),da.a.PrepareUniformBuffer(e),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture(\"reflection2DSampler\",null),t=!0),this.subSurface.unbind(this._activeEffect)&&(t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),r=i._materialDefines;if(r){var o=i.effect;if(o){this._activeEffect=o,r.INSTANCES&&!r.THIN_INSTANCES||this.bindOnlyWorldMatrix(e),this.prePassConfiguration.bindForSubMesh(this._activeEffect,n,t,e,this.isFrozen),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var a=this._mustRebind(n,o,t.visibility);ro.a.BindBonesParameters(t,this._activeEffect,this.prePassConfiguration);var c=null,l=this._uniformBuffer;if(a){var u=n.getEngine();if(l.bindToEffect(o,\"Material\"),this.bindViewProjection(o),c=this._getReflectionTexture(),!l.useUbo||!this.isFrozen||!l.isSync){if(n.texturesEnabled){if(this._albedoTexture&&so.a.DiffuseTextureEnabled&&(l.updateFloat2(\"vAlbedoInfos\",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),ro.a.BindTextureMatrix(this._albedoTexture,l,\"albedo\")),this._ambientTexture&&so.a.AmbientTextureEnabled&&(l.updateFloat4(\"vAmbientInfos\",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),ro.a.BindTextureMatrix(this._ambientTexture,l,\"ambient\")),this._opacityTexture&&so.a.OpacityTextureEnabled&&(l.updateFloat2(\"vOpacityInfos\",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),ro.a.BindTextureMatrix(this._opacityTexture,l,\"opacity\")),c&&so.a.ReflectionTextureEnabled){if(l.updateMatrix(\"reflectionMatrix\",c.getReflectionTextureMatrix()),l.updateFloat2(\"vReflectionInfos\",c.level,0),c.boundingBoxSize){var h=c;l.updateVector3(\"vReflectionPosition\",h.boundingBoxPosition),l.updateVector3(\"vReflectionSize\",h.boundingBoxSize)}if(this.realTimeFiltering){var d=c.getSize().width;l.updateFloat2(\"vReflectionFilteringInfo\",d,L.a.Log2(d))}if(!r.USEIRRADIANCEMAP){var f=c.sphericalPolynomial;if(r.USESPHERICALFROMREFLECTIONMAP&&f)if(r.SPHERICAL_HARMONICS){var p=f.preScaledHarmonics;this._activeEffect.setVector3(\"vSphericalL00\",p.l00),this._activeEffect.setVector3(\"vSphericalL1_1\",p.l1_1),this._activeEffect.setVector3(\"vSphericalL10\",p.l10),this._activeEffect.setVector3(\"vSphericalL11\",p.l11),this._activeEffect.setVector3(\"vSphericalL2_2\",p.l2_2),this._activeEffect.setVector3(\"vSphericalL2_1\",p.l2_1),this._activeEffect.setVector3(\"vSphericalL20\",p.l20),this._activeEffect.setVector3(\"vSphericalL21\",p.l21),this._activeEffect.setVector3(\"vSphericalL22\",p.l22)}else this._activeEffect.setFloat3(\"vSphericalX\",f.x.x,f.x.y,f.x.z),this._activeEffect.setFloat3(\"vSphericalY\",f.y.x,f.y.y,f.y.z),this._activeEffect.setFloat3(\"vSphericalZ\",f.z.x,f.z.y,f.z.z),this._activeEffect.setFloat3(\"vSphericalXX_ZZ\",f.xx.x-f.zz.x,f.xx.y-f.zz.y,f.xx.z-f.zz.z),this._activeEffect.setFloat3(\"vSphericalYY_ZZ\",f.yy.x-f.zz.x,f.yy.y-f.zz.y,f.yy.z-f.zz.z),this._activeEffect.setFloat3(\"vSphericalZZ\",f.zz.x,f.zz.y,f.zz.z),this._activeEffect.setFloat3(\"vSphericalXY\",f.xy.x,f.xy.y,f.xy.z),this._activeEffect.setFloat3(\"vSphericalYZ\",f.yz.x,f.yz.y,f.yz.z),this._activeEffect.setFloat3(\"vSphericalZX\",f.zx.x,f.zx.y,f.zx.z)}l.updateFloat3(\"vReflectionMicrosurfaceInfos\",c.getSize().width,c.lodGenerationScale,c.lodGenerationOffset)}this._emissiveTexture&&so.a.EmissiveTextureEnabled&&(l.updateFloat2(\"vEmissiveInfos\",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),ro.a.BindTextureMatrix(this._emissiveTexture,l,\"emissive\")),this._lightmapTexture&&so.a.LightmapTextureEnabled&&(l.updateFloat2(\"vLightmapInfos\",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),ro.a.BindTextureMatrix(this._lightmapTexture,l,\"lightmap\")),so.a.SpecularTextureEnabled&&(this._metallicTexture?(l.updateFloat3(\"vReflectivityInfos\",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),ro.a.BindTextureMatrix(this._metallicTexture,l,\"reflectivity\")):this._reflectivityTexture&&(l.updateFloat3(\"vReflectivityInfos\",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),ro.a.BindTextureMatrix(this._reflectivityTexture,l,\"reflectivity\")),this._metallicReflectanceTexture&&(l.updateFloat2(\"vMetallicReflectanceInfos\",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),ro.a.BindTextureMatrix(this._metallicReflectanceTexture,l,\"metallicReflectance\")),this._microSurfaceTexture&&(l.updateFloat2(\"vMicroSurfaceSamplerInfos\",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),ro.a.BindTextureMatrix(this._microSurfaceTexture,l,\"microSurfaceSampler\"))),this._bumpTexture&&u.getCaps().standardDerivatives&&so.a.BumpTextureEnabled&&!this._disableBumpMap&&(l.updateFloat3(\"vBumpInfos\",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),ro.a.BindTextureMatrix(this._bumpTexture,l,\"bump\"),n._mirroredCameraPosition?l.updateFloat2(\"vTangentSpaceParams\",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2(\"vTangentSpaceParams\",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&l.updateFloat(\"pointSize\",this.pointSize),r.METALLICWORKFLOW){s.c.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,s.c.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness,l.updateColor4(\"vReflectivityColor\",s.c.Color3[0],1);var _=this.subSurface.indexOfRefraction,m=Math.pow((_-1)/(_+1),2);this._metallicReflectanceColor.scaleToRef(m*this._metallicF0Factor,s.c.Color3[0]);var g=this._metallicF0Factor;l.updateColor4(\"vMetallicReflectanceFactors\",s.c.Color3[0],g)}else l.updateColor4(\"vReflectivityColor\",this._reflectivityColor,this._microSurface);l.updateColor3(\"vEmissiveColor\",so.a.EmissiveTextureEnabled?this._emissiveColor:s.a.BlackReadOnly),l.updateColor3(\"vReflectionColor\",this._reflectionColor),!r.SS_REFRACTION&&this.subSurface.linkRefractionWithTransparency?l.updateColor4(\"vAlbedoColor\",this._albedoColor,1):l.updateColor4(\"vAlbedoColor\",this._albedoColor,this.alpha),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*n.environmentIntensity,this._lightingInfos.w=this._specularIntensity,l.updateVector4(\"vLightingIntensity\",this._lightingInfos)}l.updateFloat(\"visibility\",t.visibility),n.texturesEnabled&&(this._albedoTexture&&so.a.DiffuseTextureEnabled&&l.setTexture(\"albedoSampler\",this._albedoTexture),this._ambientTexture&&so.a.AmbientTextureEnabled&&l.setTexture(\"ambientSampler\",this._ambientTexture),this._opacityTexture&&so.a.OpacityTextureEnabled&&l.setTexture(\"opacitySampler\",this._opacityTexture),c&&so.a.ReflectionTextureEnabled&&(r.LODBASEDMICROSFURACE?l.setTexture(\"reflectionSampler\",c):(l.setTexture(\"reflectionSampler\",c._lodTextureMid||c),l.setTexture(\"reflectionSamplerLow\",c._lodTextureLow||c),l.setTexture(\"reflectionSamplerHigh\",c._lodTextureHigh||c)),r.USEIRRADIANCEMAP&&l.setTexture(\"irradianceSampler\",c.irradianceTexture)),r.ENVIRONMENTBRDF&&l.setTexture(\"environmentBrdfSampler\",this._environmentBRDFTexture),this._emissiveTexture&&so.a.EmissiveTextureEnabled&&l.setTexture(\"emissiveSampler\",this._emissiveTexture),this._lightmapTexture&&so.a.LightmapTextureEnabled&&l.setTexture(\"lightmapSampler\",this._lightmapTexture),so.a.SpecularTextureEnabled&&(this._metallicTexture?l.setTexture(\"reflectivitySampler\",this._metallicTexture):this._reflectivityTexture&&l.setTexture(\"reflectivitySampler\",this._reflectivityTexture),this._metallicReflectanceTexture&&l.setTexture(\"metallicReflectanceSampler\",this._metallicReflectanceTexture),this._microSurfaceTexture&&l.setTexture(\"microSurfaceSampler\",this._microSurfaceTexture)),this._bumpTexture&&u.getCaps().standardDerivatives&&so.a.BumpTextureEnabled&&!this._disableBumpMap&&l.setTexture(\"bumpSampler\",this._bumpTexture)),this.detailMap.bindForSubMesh(l,n,this.isFrozen),this.subSurface.bindForSubMesh(l,n,u,this.isFrozen,r.LODBASEDMICROSFURACE,this.realTimeFiltering),this.clearCoat.bindForSubMesh(l,n,u,this._disableBumpMap,this.isFrozen,this._invertNormalMapX,this._invertNormalMapY,i),this.anisotropy.bindForSubMesh(l,n,this.isFrozen),this.sheen.bindForSubMesh(l,n,this.isFrozen,i),ro.a.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var v=n._forcedViewPosition?n._forcedViewPosition:n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition,b=n.useRightHandedSystem===(null!=n._mirroredCameraPosition);o.setFloat4(\"vEyePosition\",v.x,v.y,v.z,b?-1:1),o.setColor3(\"vAmbientColor\",this._globalAmbientColor),o.setFloat2(\"vDebugMode\",this.debugLimit,this.debugFactor)}!a&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&ro.a.BindLights(n,t,this._activeEffect,r,this._maxSimultaneousLights,this._rebuildInParallel),(n.fogEnabled&&t.applyFog&&n.fogMode!==Q.a.FOGMODE_NONE||c)&&this.bindView(o),ro.a.BindFogParameters(n,t,this._activeEffect,!0),r.NUM_MORPH_INFLUENCERS&&ro.a.BindMorphTargetParameters(t,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),ro.a.BindLogDepth(r,this._activeEffect,n)),l.update(),this._afterBind(t,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this.detailMap.getAnimatables(e),this.subSurface.getAnimatables(e),this.clearCoat.getAnimatables(e),this.sheen.getAnimatables(e),this.anisotropy.getAnimatables(e),e},t.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._albedoTexture&&t.push(this._albedoTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._reflectivityTexture&&t.push(this._reflectivityTexture),this._metallicTexture&&t.push(this._metallicTexture),this._metallicReflectanceTexture&&t.push(this._metallicReflectanceTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this.detailMap.getActiveTextures(t),this.subSurface.getActiveTextures(t),this.clearCoat.getActiveTextures(t),this.sheen.getActiveTextures(t),this.anisotropy.getActiveTextures(t),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._albedoTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._reflectivityTexture===t||(this._metallicTexture===t||(this._metallicReflectanceTexture===t||(this._microSurfaceTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||(this.detailMap.hasTexture(t)||this.subSurface.hasTexture(t)||this.clearCoat.hasTexture(t)||this.sheen.hasTexture(t)||this.anisotropy.hasTexture(t))))))))))))},t.prototype.setPrePassRenderer=function(e){if(this.subSurface.isScatteringEnabled){var t=this.getScene().enableSubSurfaceForPrePass();return t&&(t.enabled=!0),!0}return!1},t.prototype.dispose=function(t,i){var n,r,o,a,s,c,l,u,h,d,f;i&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),null===(n=this._albedoTexture)||void 0===n||n.dispose(),null===(r=this._ambientTexture)||void 0===r||r.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(a=this._reflectionTexture)||void 0===a||a.dispose(),null===(s=this._emissiveTexture)||void 0===s||s.dispose(),null===(c=this._metallicTexture)||void 0===c||c.dispose(),null===(l=this._reflectivityTexture)||void 0===l||l.dispose(),null===(u=this._bumpTexture)||void 0===u||u.dispose(),null===(h=this._lightmapTexture)||void 0===h||h.dispose(),null===(d=this._metallicReflectanceTexture)||void 0===d||d.dispose(),null===(f=this._microSurfaceTexture)||void 0===f||f.dispose()),this.detailMap.dispose(i),this.subSurface.dispose(i),this.clearCoat.dispose(i),this.sheen.dispose(i),this.anisotropy.dispose(i),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.PBRMATERIAL_OPAQUE=xo.a.MATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=xo.a.MATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=xo.a.MATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=xo.a.MATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,Object(h.c)([Object(w.i)()],t.prototype,\"_imageProcessingConfiguration\",void 0),Object(h.c)([Object(w.b)(\"_markAllSubMeshesAsMiscDirty\")],t.prototype,\"debugMode\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"useLogarithmicDepth\",null),t}(ao.a),ma=function(e){function t(i,n){var r=e.call(this,i,n)||this;return r.directIntensity=1,r.emissiveIntensity=1,r.environmentIntensity=1,r.specularIntensity=1,r.disableBumpMap=!1,r.ambientTextureStrength=1,r.ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,r.metallicF0Factor=1,r.metallicReflectanceColor=s.a.White(),r.ambientColor=new s.a(0,0,0),r.albedoColor=new s.a(1,1,1),r.reflectivityColor=new s.a(1,1,1),r.reflectionColor=new s.a(1,1,1),r.emissiveColor=new s.a(0,0,0),r.microSurface=1,r.useLightmapAsShadowmap=!1,r.useAlphaFromAlbedoTexture=!1,r.forceAlphaTest=!1,r.alphaCutOff=.4,r.useSpecularOverAlpha=!0,r.useMicroSurfaceFromReflectivityMapAlpha=!1,r.useRoughnessFromMetallicTextureAlpha=!0,r.useRoughnessFromMetallicTextureGreen=!1,r.useMetallnessFromMetallicTextureBlue=!1,r.useAmbientOcclusionFromMetallicTextureRed=!1,r.useAmbientInGrayScale=!1,r.useAutoMicroSurfaceFromReflectivityMap=!1,r.useRadianceOverAlpha=!0,r.useObjectSpaceNormalMap=!1,r.useParallax=!1,r.useParallaxOcclusion=!1,r.parallaxScaleBias=.05,r.disableLighting=!1,r.forceIrradianceInFragment=!1,r.maxSimultaneousLights=4,r.invertNormalMapX=!1,r.invertNormalMapY=!1,r.twoSidedLighting=!1,r.useAlphaFresnel=!1,r.useLinearAlphaFresnel=!1,r.environmentBRDFTexture=null,r.forceNormalForward=!1,r.enableSpecularAntiAliasing=!1,r.useHorizonOcclusion=!0,r.useRadianceOcclusion=!0,r.unlit=!1,r._environmentBRDFTexture=To.GetEnvironmentBRDFTexture(n),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"refractionTexture\",{get:function(){return this.subSurface.refractionTexture},set:function(e){this.subSurface.refractionTexture=e,e?this.subSurface.isRefractionEnabled=!0:this.subSurface.linkRefractionWithTransparency||(this.subSurface.isRefractionEnabled=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"indexOfRefraction\",{get:function(){return this.subSurface.indexOfRefraction},set:function(e){this.subSurface.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"invertRefractionY\",{get:function(){return this.subSurface.invertRefractionY},set:function(e){this.subSurface.invertRefractionY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"linkRefractionWithTransparency\",{get:function(){return this.subSurface.linkRefractionWithTransparency},set:function(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"usePhysicalLightFalloff\",{get:function(){return this._lightFalloff===_a.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?_a.LIGHTFALLOFF_PHYSICAL:_a.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"useGLTFLightFalloff\",{get:function(){return this._lightFalloff===_a.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?_a.LIGHTFALLOFF_GLTF:_a.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"imageProcessingConfiguration\",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraColorCurvesEnabled\",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraColorGradingEnabled\",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraToneMappingEnabled\",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraExposure\",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraContrast\",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraColorGradingTexture\",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cameraColorCurves\",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"PBRMaterial\"},t.prototype.clone=function(e){var i=this,n=w.a.Clone((function(){return new t(e,i.getScene())}),this);return n.id=e,n.name=e,this.clearCoat.copyTo(n.clearCoat),this.anisotropy.copyTo(n.anisotropy),this.brdf.copyTo(n.brdf),this.sheen.copyTo(n.sheen),this.subSurface.copyTo(n.subSurface),n},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType=\"BABYLON.PBRMaterial\",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e},t.Parse=function(e,i,n){var r=w.a.Parse((function(){return new t(e.name,i)}),e,i,n);return e.clearCoat&&r.clearCoat.parse(e.clearCoat,i,n),e.anisotropy&&r.anisotropy.parse(e.anisotropy,i,n),e.brdf&&r.brdf.parse(e.brdf,i,n),e.sheen&&r.sheen.parse(e.sheen,i,n),e.subSurface&&r.subSurface.parse(e.subSurface,i,n),r},t.PBRMATERIAL_OPAQUE=_a.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=_a.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=_a.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=_a.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=_a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"directIntensity\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"emissiveIntensity\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"environmentIntensity\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"specularIntensity\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"disableBumpMap\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"albedoTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"ambientTexture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"ambientTextureStrength\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"ambientTextureImpactOnAnalyticalLights\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesAndMiscDirty\")],t.prototype,\"opacityTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"emissiveTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectivityTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"metallicTexture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"metallic\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"roughness\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"metallicF0Factor\",void 0),Object(h.c)([Object(w.e)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"metallicReflectanceColor\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"metallicReflectanceTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"microSurfaceTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"bumpTexture\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\",null)],t.prototype,\"lightmapTexture\",void 0),Object(h.c)([Object(w.e)(\"ambient\"),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"ambientColor\",void 0),Object(h.c)([Object(w.e)(\"albedo\"),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"albedoColor\",void 0),Object(h.c)([Object(w.e)(\"reflectivity\"),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectivityColor\",void 0),Object(h.c)([Object(w.e)(\"reflection\"),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"reflectionColor\",void 0),Object(h.c)([Object(w.e)(\"emissive\"),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"emissiveColor\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"microSurface\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useLightmapAsShadowmap\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesAndMiscDirty\")],t.prototype,\"useAlphaFromAlbedoTexture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesAndMiscDirty\")],t.prototype,\"forceAlphaTest\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesAndMiscDirty\")],t.prototype,\"alphaCutOff\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useSpecularOverAlpha\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useMicroSurfaceFromReflectivityMapAlpha\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useRoughnessFromMetallicTextureAlpha\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useRoughnessFromMetallicTextureGreen\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useMetallnessFromMetallicTextureBlue\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useAmbientOcclusionFromMetallicTextureRed\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useAmbientInGrayScale\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useAutoMicroSurfaceFromReflectivityMap\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"usePhysicalLightFalloff\",null),Object(h.c)([Object(w.c)()],t.prototype,\"useGLTFLightFalloff\",null),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useRadianceOverAlpha\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useObjectSpaceNormalMap\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useParallax\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useParallaxOcclusion\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"parallaxScaleBias\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"disableLighting\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"forceIrradianceInFragment\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsLightsDirty\")],t.prototype,\"maxSimultaneousLights\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"invertNormalMapX\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"invertNormalMapY\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"twoSidedLighting\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useAlphaFresnel\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useLinearAlphaFresnel\",void 0),Object(h.c)([Object(w.m)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"environmentBRDFTexture\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"forceNormalForward\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"enableSpecularAntiAliasing\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useHorizonOcclusion\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsTexturesDirty\")],t.prototype,\"useRadianceOcclusion\",void 0),Object(h.c)([Object(w.c)(),Object(w.b)(\"_markAllSubMeshesAsMiscDirty\")],t.prototype,\"unlit\",void 0),t}(_a);c.a.RegisteredTypes[\"BABYLON.PBRMaterial\"]=ma;function ga(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var va=ga(\"DXT1\"),ba=ga(\"DXT3\"),ya=ga(\"DXT5\"),Ta=ga(\"DX10\"),Ea=function(){function e(){}return e.GetDDSInfo=function(e){var t=new Int32Array(e.buffer,e.byteOffset,31),i=new Int32Array(e.buffer,e.byteOffset,35),n=1;131072&t[2]&&(n=Math.max(1,t[7]));var r=t[21],o=r===Ta?i[32]:0,a=g.a.TEXTURETYPE_UNSIGNED_INT;switch(r){case 113:a=g.a.TEXTURETYPE_HALF_FLOAT;break;case 116:a=g.a.TEXTURETYPE_FLOAT;break;case Ta:if(10===o){a=g.a.TEXTURETYPE_HALF_FLOAT;break}if(2===o){a=g.a.TEXTURETYPE_FLOAT;break}}return{width:t[4],height:t[3],mipmapCount:n,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28]),isCompressed:r===va||r===ba||r===ya,dxgiFormat:o,textureType:a}},e._ToHalfFloat=function(t){e._FloatView||(e._FloatView=new Float32Array(1),e._Int32View=new Int32Array(e._FloatView.buffer)),e._FloatView[0]=t;var i=e._Int32View[0],n=i>>16&32768,r=i>>12&2047,o=i>>23&255;return o<103?n:o>142?(n|=31744,n|=(255==o?0:1)&&8388607&i):o<113?n|=((r|=2048)>>114-o)+(r>>113-o&1):(n|=o-112<<10|r>>1,n+=1&r)},e._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,n=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(n/Math.pow(2,10)):31==i?n?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+n/Math.pow(2,10))},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,i,n,r,o,a){for(var s=new Float32Array(r),c=new Uint16Array(o,n),l=0,u=0;u>8)},e._GetRGBArrayBuffer=function(e,t,i,n,r,o,a,s){for(var c=new Uint8Array(n),l=new Uint8Array(r,i),u=0,h=0;h>8&255,P>>16&255,P>>24&255)))}var x=e._ExtractLongWordOrder(y[23]),O=e._ExtractLongWordOrder(y[24]),M=e._ExtractLongWordOrder(y[25]),I=e._ExtractLongWordOrder(y[26]);C&&(E=t._getRGBABufferInternalSizedFormat(r.textureType)),_=1,131072&y[2]&&!1!==o&&(_=Math.max(1,y[7]));for(var D=c||0;D0?r.sphericalPolynomial=$n.ConvertCubeMapToSphericalPolynomial({size:y[4],right:l[0],left:l[1],up:l[2],down:l[3],front:l[4],back:l[5],format:g.a.TEXTUREFORMAT_RGBA,type:g.a.TEXTURETYPE_FLOAT,gammaSpace:!1}):r.sphericalPolynomial=void 0}else m.a.Error(\"Compressed textures are not supported on this platform.\");else m.a.Error(\"Unsupported format, must contain a FourCC, RGB or LUMINANCE code\");else m.a.Error(\"Invalid magic number in DDS header\")},e.StoreLODInAlphaChannel=!1,e}();qe.a.prototype.createPrefilteredCubeTexture=function(e,t,i,n,r,o,a,s,c){var l=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=!0);return this.createCubeTexture(e,t,null,!1,(function(e){if(e){var o=e.texture;if(c?e.info.sphericalPolynomial&&(o._sphericalPolynomial=e.info.sphericalPolynomial):o._sphericalPolynomial=new qn,o._source=Qe.b.CubePrefiltered,l.getCaps().textureLOD)r&&r(o);else{var a=l._gl,s=e.width;if(s){for(var u=[],h=0;h<3;h++){var d=1-h/2,f=n,p=L.a.Log2(s)*i+n,_=f+(p-f)*d,v=Math.round(Math.min(Math.max(_,0),p)),b=new Qe.a(l,Qe.b.Temp);if(b.type=o.type,b.format=o.format,b.width=Math.pow(2,Math.max(L.a.Log2(s)-v,0)),b.height=b.width,b.isCube=!0,l._bindTextureDirectly(a.TEXTURE_CUBE_MAP,b,!0),b.samplingMode=g.a.TEXTURE_LINEAR_LINEAR,a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),e.isDDS){var y=e.info,T=e.data;l._unpackFlipY(y.isCompressed),Ea.UploadDDSLevels(l,b,T,y,!0,6,v)}else m.a.Warn(\"DDS is the only prefiltered cube map supported so far.\");l._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var E=new Zn.a(t);E.isCube=!0,E._texture=b,b.isReady=!0,u.push(E)}o._lodTextureHigh=u[2],o._lodTextureMid=u[1],o._lodTextureLow=u[0],r&&r(o)}}}else r&&r(null)}),o,a,s,c,i,n)};var Sa=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,\".dds\")},e.prototype.loadCubeData=function(e,t,i,n,r){var o,a=t.getEngine(),s=!1;if(Array.isArray(e))for(var c=0;c1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Ea.UploadDDSLevels(a,t,l,o,s,6,-1,c),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t)}else{var u=e;o=Ea.GetDDSInfo(u),t.width=o.width,t.height=o.height,i&&(o.sphericalPolynomial=new qn),s=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Ea.UploadDDSLevels(a,t,u,o,s,6),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t,!1)}a._setCubeMapTextureParams(t,s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,i){var n=Ea.GetDDSInfo(e),r=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps&&n.width>>n.mipmapCount-1==1;i(n.width,n.height,r,n.isFourCC,(function(){Ea.UploadDDSLevels(t.getEngine(),t,e,n,r,1)}))},e}();Se.a._TextureLoaders.push(new Sa);var Aa=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,\".env\")},e.prototype.loadCubeData=function(e,t,i,n,r){if(!Array.isArray(e)){var o=ir.GetEnvInfo(e);o?(t.width=o.width,t.height=o.width,ir.UploadEnvSpherical(t,o),ir.UploadEnvLevelsAsync(t,e,o).then((function(){t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()}))):r&&r(\"Can not parse the environment file\",null)}},e.prototype.loadData=function(e,t,i){throw\".env not supported in 2d.\"},e}();Se.a._TextureLoaders.push(new Aa);var Pa=function(){function e(t,i,n,r){if(this.data=t,this.isInvalid=!1,!e.IsValid(t))return this.isInvalid=!0,void m.a.Error(\"texture missing KTX identifier\");var o=Uint32Array.BYTES_PER_ELEMENT,a=new DataView(this.data.buffer,this.data.byteOffset+12,13*o),s=67305985===a.getUint32(0,!0);this.glType=a.getUint32(1*o,s),this.glTypeSize=a.getUint32(2*o,s),this.glFormat=a.getUint32(3*o,s),this.glInternalFormat=a.getUint32(4*o,s),this.glBaseInternalFormat=a.getUint32(5*o,s),this.pixelWidth=a.getUint32(6*o,s),this.pixelHeight=a.getUint32(7*o,s),this.pixelDepth=a.getUint32(8*o,s),this.numberOfArrayElements=a.getUint32(9*o,s),this.numberOfFaces=a.getUint32(10*o,s),this.numberOfMipmapLevels=a.getUint32(11*o,s),this.bytesOfKeyValueData=a.getUint32(12*o,s),0===this.glType?(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0!==this.pixelHeight&&0===this.pixelDepth?0===this.numberOfArrayElements?this.numberOfFaces===i?this.loadType=e.COMPRESSED_2D:m.a.Error(\"number of faces expected\"+i+\", but found \"+this.numberOfFaces):m.a.Error(\"texture arrays not currently supported\"):m.a.Error(\"only 2D textures currently supported\")):m.a.Error(\"only compressed formats currently supported\")}return e.prototype.uploadLevels=function(t,i){switch(this.loadType){case e.COMPRESSED_2D:this._upload2DCompressedLevels(t,i);break;case e.TEX_2D:case e.COMPRESSED_3D:case e.TEX_3D:}},e.prototype._upload2DCompressedLevels=function(t,i){for(var n=e.HEADER_LEN+this.bytesOfKeyValueData,r=this.pixelWidth,o=this.pixelHeight,a=i?this.numberOfMipmapLevels:1,s=0;s=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e.HEADER_LEN=64,e.COMPRESSED_2D=0,e.COMPRESSED_3D=1,e.TEX_2D=2,e.TEX_3D=3,e}(),Ca=function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map((function(e){return{worker:e,active:!1}}))}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;e1,t.isReady=!0,this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D,null)},e.IsValid=function(e){if(e.byteLength>=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&50===t[5]&&48===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e.URLConfig={jsDecoderModule:\"https://preview.babylonjs.com/babylon.ktx2Decoder.js\",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,jsMSCTranscoder:null,wasmMSCTranscoder:null},e.DefaultNumWorkers=e.GetDefaultNumWorkers(),e}();function xa(){var e;onmessage=function(t){switch(t.data.action){case\"init\":var i=t.data.urls;importScripts(i.jsDecoderModule),null!==i.wasmUASTCToASTC&&(KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL=i.wasmUASTCToASTC),null!==i.wasmUASTCToBC7&&(KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL=i.wasmUASTCToBC7),null!==i.wasmUASTCToRGBA_UNORM&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=i.wasmUASTCToRGBA_UNORM),null!==i.wasmUASTCToRGBA_SRGB&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=i.wasmUASTCToRGBA_SRGB),null!==i.jsMSCTranscoder&&(KTX2DECODER.MSCTranscoder.JSModuleURL=i.jsMSCTranscoder),null!==i.wasmMSCTranscoder&&(KTX2DECODER.MSCTranscoder.WasmModuleURL=i.wasmMSCTranscoder),e=new KTX2DECODER.KTX2Decoder,postMessage({action:\"init\"});break;case\"decode\":e.decode(t.data.data,t.data.caps,t.data.options).then((function(e){for(var t=[],i=0;i1&&t.generateMipMaps;o._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,o._setCubeMapTextureParams(t,s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()}},e.prototype.loadData=function(e,t,i,n){if(Pa.IsValid(e)){t._invertVScale=!t.invertY;var r=new Pa(e,1);i(r.pixelWidth,r.pixelHeight,t.generateMipMaps,!0,(function(){r.uploadLevels(t,t.generateMipMaps)}),r.isInvalid)}else if(Ra.IsValid(e)){new Ra(t.getEngine()).uploadAsync(e,t,n).then((function(){i(t.width,t.height,t.generateMipMaps,!0,(function(){}),!1)}),(function(e){m.a.Warn(\"Failed to load KTX2 texture data: \"+e.message),i(0,0,!1,!1,(function(){}),!0)}))}else m.a.Error(\"texture missing KTX identifier\"),i(0,0,!1,!1,(function(){}),!0)},e}();Se.a._TextureLoaders.unshift(new Oa);var Ma=function(e){function t(t,i,n){var r=e.call(this,t,a.e.Zero(),i)||this;return r._xrSessionManager=n,r._firstFrame=!1,r._referenceQuaternion=a.b.Identity(),r._referencedPosition=new a.e,r._xrInvPositionCache=new a.e,r._xrInvQuaternionCache=a.b.Identity(),r._trackingState=en.NOT_TRACKING,r.onBeforeCameraTeleport=new o.c,r.onAfterCameraTeleport=new o.c,r.onTrackingStateChanged=new o.c,r.compensateOnFirstFrame=!0,r._rotate180=new a.b(0,1,0,0),r.minZ=.1,r.rotationQuaternion=new a.b,r.cameraRigMode=je.a.RIG_MODE_CUSTOM,r.updateUpVectorFromRotation=!0,r._updateNumberOfRigCameras(1),r.freezeProjectionMatrix(),r._xrSessionManager.onXRSessionInit.add((function(){r._referencedPosition.copyFromFloats(0,0,0),r._referenceQuaternion.copyFromFloats(0,0,0,1),r._firstFrame=r.compensateOnFirstFrame})),r._xrSessionManager.onXRFrameObservable.add((function(e){r._firstFrame&&r._updateFromXRSession(),r._updateReferenceSpace(),r._updateFromXRSession()}),void 0,!0),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"trackingState\",{get:function(){return this._trackingState},enumerable:!1,configurable:!0}),t.prototype._setTrackingState=function(e){this._trackingState!==e&&(this._trackingState=e,this.onTrackingStateChanged.notifyObservers(e))},Object.defineProperty(t.prototype,\"realWorldHeight\",{get:function(){var e=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);return e&&e.transform?e.transform.position.y:0},enumerable:!1,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new yi.a(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new yi.a(.5,0,.5,1),this.rigCameras[1].outputRenderTarget=null},t.prototype.setTransformationFromNonVRCamera=function(e,t){(void 0===e&&(e=this.getScene().activeCamera),void 0===t&&(t=!0),e&&e!==this)&&(e.computeWorldMatrix().decompose(void 0,this.rotationQuaternion,this.position),this.position.y=0,a.b.FromEulerAnglesToRef(0,this.rotationQuaternion.toEulerAngles().y,0,this.rotationQuaternion),this._firstFrame=!0,t&&this._xrSessionManager.resetReferenceSpace())},t.prototype.getClassName=function(){return\"WebXRCamera\"},t.prototype._updateFromXRSession=function(){var e=this,t=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);if(t){var i=t.emulatedPosition?en.TRACKING_LOST:en.TRACKING;if(this._setTrackingState(i),t.transform){var n=t.transform.position;this._referencedPosition.set(n.x,n.y,n.z);var r=t.transform.orientation;this._referenceQuaternion.set(r.x,r.y,r.z,r.w),this._scene.useRightHandedSystem||(this._referencedPosition.z*=-1,this._referenceQuaternion.z*=-1,this._referenceQuaternion.w*=-1),this._firstFrame?(this._firstFrame=!1,this.position.y+=this._referencedPosition.y,this._referenceQuaternion.copyFromFloats(0,0,0,1)):(this.rotationQuaternion.copyFrom(this._referenceQuaternion),this.position.copyFrom(this._referencedPosition))}this.rigCameras.length!==t.views.length&&this._updateNumberOfRigCameras(t.views.length),t.views.forEach((function(t,i){var n=e.rigCameras[i];n.isLeftCamera||n.isRightCamera||(\"right\"===t.eye?n._isRightCamera=!0:\"left\"===t.eye&&(n._isLeftCamera=!0));var r=t.transform.position,o=t.transform.orientation;if(n.position.set(r.x,r.y,r.z),n.rotationQuaternion.set(o.x,o.y,o.z,o.w),e._scene.useRightHandedSystem?n.rotationQuaternion.multiplyInPlace(e._rotate180):(n.position.z*=-1,n.rotationQuaternion.z*=-1,n.rotationQuaternion.w*=-1),a.a.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,n._projectionMatrix),e._scene.useRightHandedSystem||n._projectionMatrix.toggleProjectionMatrixHandInPlace(),0===i&&e._projectionMatrix.copyFrom(n._projectionMatrix),e._xrSessionManager.session.renderState.baseLayer){var s=e._xrSessionManager.session.renderState.baseLayer.getViewport(t),c=e._xrSessionManager.session.renderState.baseLayer.framebufferWidth,l=e._xrSessionManager.session.renderState.baseLayer.framebufferHeight;n.viewport.width=s.width/c,n.viewport.height=s.height/l,n.viewport.x=s.x/c,n.viewport.y=s.y/l}n.outputRenderTarget=e._xrSessionManager.getRenderTargetTextureForEye(t.eye)}))}else this._setTrackingState(en.NOT_TRACKING)},t.prototype._updateNumberOfRigCameras=function(e){for(void 0===e&&(e=1);this.rigCameras.lengthe;){var i=this.rigCameras.pop();i&&i.dispose()}},t.prototype._updateReferenceSpace=function(){this.position.equals(this._referencedPosition)&&this.rotationQuaternion.equals(this._referenceQuaternion)||(this.position.subtractToRef(this._referencedPosition,this._referencedPosition),this._referenceQuaternion.conjugateInPlace(),this._referenceQuaternion.multiplyToRef(this.rotationQuaternion,this._referenceQuaternion),this._updateReferenceSpaceOffset(this._referencedPosition,this._referenceQuaternion.normalize()))},t.prototype._updateReferenceSpaceOffset=function(e,t,i){if(void 0===i&&(i=!1),this._xrSessionManager.referenceSpace&&this._xrSessionManager.currentFrame){this._xrInvPositionCache.copyFrom(e),t?this._xrInvQuaternionCache.copyFrom(t):this._xrInvQuaternionCache.copyFromFloats(0,0,0,1),this._scene.useRightHandedSystem||(this._xrInvPositionCache.z*=-1,this._xrInvQuaternionCache.z*=-1,this._xrInvQuaternionCache.w*=-1),this._xrInvPositionCache.negateInPlace(),this._xrInvQuaternionCache.conjugateInPlace(),this._xrInvPositionCache.rotateByQuaternionToRef(this._xrInvQuaternionCache,this._xrInvPositionCache),i&&(this._xrInvPositionCache.y=0);var n=new XRRigidTransform({x:this._xrInvPositionCache.x,y:this._xrInvPositionCache.y,z:this._xrInvPositionCache.z},{x:this._xrInvQuaternionCache.x,y:this._xrInvQuaternionCache.y,z:this._xrInvQuaternionCache.z,w:this._xrInvQuaternionCache.w}),r=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(n),o=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(r);if(o){var s=new a.e(o.transform.position.x,o.transform.position.y,o.transform.position.z);this._scene.useRightHandedSystem||(s.z*=-1),this.position.subtractToRef(s,s),this._scene.useRightHandedSystem||(s.z*=-1),s.negateInPlace();var c=new XRRigidTransform({x:s.x,y:s.y,z:s.z});this._xrSessionManager.referenceSpace=r.getOffsetReferenceSpace(c)}}},t}(wt),Ia=function(){function e(){}return e.ANCHOR_SYSTEM=\"xr-anchor-system\",e.BACKGROUND_REMOVER=\"xr-background-remover\",e.HIT_TEST=\"xr-hit-test\",e.PHYSICS_CONTROLLERS=\"xr-physics-controller\",e.PLANE_DETECTION=\"xr-plane-detection\",e.POINTER_SELECTION=\"xr-controller-pointer-selection\",e.TELEPORTATION=\"xr-controller-teleportation\",e.FEATURE_POINTS=\"xr-feature-points\",e.HAND_TRACKING=\"xr-hand-tracking\",e}(),Da=function(){function e(e){var t=this;this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];!i.enabled||i.featureImplementation.attached||i.featureImplementation.disableAutoAttach||t.attachFeature(e)}))})),this._xrSessionManager.onXRSessionEnded.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];i.enabled&&i.featureImplementation.attached&&t.detachFeature(e)}))}))}return e.AddWebXRFeature=function(e,t,i,n){void 0===i&&(i=1),void 0===n&&(n=!1),this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:i},i>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=i),n&&(this._AvailableFeatures[e].stable=i),this._AvailableFeatures[e][i]=t},e.ConstructFeature=function(e,t,i,n){void 0===t&&(t=1);var r=this._AvailableFeatures[e][t];if(!r)throw new Error(\"feature not found\");return r(i,n)},e.GetAvailableFeatures=function(){return Object.keys(this._AvailableFeatures)},e.GetAvailableVersions=function(e){return Object.keys(this._AvailableFeatures[e])},e.GetLatestVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].latest||-1},e.GetStableVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].stable||-1},e.prototype.attachFeature=function(e){var t=this._features[e];t&&t.enabled&&!t.featureImplementation.attached&&t.featureImplementation.attach()},e.prototype.detachFeature=function(e){var t=this._features[e];t&&t.featureImplementation.attached&&t.featureImplementation.detach()},e.prototype.disableFeature=function(e){var t=\"string\"==typeof e?e:e.Name,i=this._features[t];return!(!i||!i.enabled)&&(i.enabled=!1,this.detachFeature(t),i.featureImplementation.dispose(),!0)},e.prototype.dispose=function(){var e=this;this.getEnabledFeatures().forEach((function(t){e.disableFeature(t),e._features[t].featureImplementation.dispose()}))},e.prototype.enableFeature=function(t,i,n,r,o){var a=this;void 0===i&&(i=\"latest\"),void 0===n&&(n={}),void 0===r&&(r=!0),void 0===o&&(o=!0);var s=\"string\"==typeof t?t:t.Name,c=0;if(\"string\"==typeof i){if(!i)throw new Error(\"Error in provided version - \"+s+\" (\"+i+\")\");if(-1===(c=\"stable\"===i?e.GetStableVersionOfFeature(s):\"latest\"===i?e.GetLatestVersionOfFeature(s):+i)||isNaN(c))throw new Error(\"feature not found - \"+s+\" (\"+i+\")\")}else c=i;var l=this._features[s],u=e.ConstructFeature(s,c,this._xrSessionManager,n);if(!u)throw new Error(\"feature not found - \"+s);l&&this.disableFeature(s);var h=u();if(h.dependsOn&&!h.dependsOn.every((function(e){return!!a._features[e]})))throw new Error(\"Dependant features missing. Make sure the following features are enabled - \"+h.dependsOn.join(\", \"));if(h.isCompatible())return this._features[s]={featureImplementation:h,enabled:!0,version:c,required:o},r?this._xrSessionManager.session&&!this._features[s].featureImplementation.attached&&this.attachFeature(s):this._features[s].featureImplementation.disableAutoAttach=!0,this._features[s].featureImplementation;if(o)throw new Error(\"required feature not compatible\");return Ce.b.Warn(\"Feature \"+s+\" not compatible with the current environment/browser and was not enabled.\"),h},e.prototype.getEnabledFeature=function(e){return this._features[e]&&this._features[e].featureImplementation},e.prototype.getEnabledFeatures=function(){return Object.keys(this._features)},e.prototype.extendXRSessionInitObject=function(e){var t=this;return this.getEnabledFeatures().forEach((function(i){var n=t._features[i],r=n.featureImplementation.xrNativeFeatureName;r&&(n.required?(e.requiredFeatures=e.requiredFeatures||[],-1===e.requiredFeatures.indexOf(r)&&e.requiredFeatures.push(r)):(e.optionalFeatures=e.optionalFeatures||[],-1===e.optionalFeatures.indexOf(r)&&e.optionalFeatures.push(r)))})),e},e._AvailableFeatures={},e}(),Na=function(){function e(e){var t=this;this.scene=e,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.onInitialXRPoseSetObservable=new o.c,this.onStateChangedObservable=new o.c,this.state=$i.NOT_IN_XR,this.sessionManager=new an(e),this.camera=new Ma(\"\",e,this.sessionManager),this.featuresManager=new Da(this.sessionManager),e.onDisposeObservable.add((function(){t.exitXRAsync()}))}return e.CreateAsync=function(t){var i=new e(t);return i.sessionManager.initializeAsync().then((function(){return i._supported=!0,i})).catch((function(e){throw i._setState($i.NOT_IN_XR),i.dispose(),e}))},e.prototype.dispose=function(){this.camera.dispose(),this.onStateChangedObservable.clear(),this.onInitialXRPoseSetObservable.clear(),this.sessionManager.dispose(),this._nonVRCamera&&(this.scene.activeCamera=this._nonVRCamera)},e.prototype.enterXRAsync=function(e,t,i,n){var r=this;if(void 0===i&&(i=this.sessionManager.getWebXRRenderTarget()),void 0===n&&(n={}),!this._supported)throw\"WebXR not supported in this browser or environment\";return this._setState($i.ENTERING_XR),\"viewer\"!==t&&\"local\"!==t&&(n.optionalFeatures=n.optionalFeatures||[],n.optionalFeatures.push(t)),this.featuresManager.extendXRSessionInitObject(n),\"immersive-ar\"===e&&\"unbounded\"!==t&&m.a.Warn(\"We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode\"),this.sessionManager.initializeSessionAsync(e,n).then((function(){return r.sessionManager.setReferenceSpaceTypeAsync(t)})).then((function(){return i.initializeXRLayerAsync(r.sessionManager.session)})).then((function(){return r.sessionManager.updateRenderStateAsync({depthFar:r.camera.maxZ,depthNear:r.camera.minZ,baseLayer:i.xrLayer})})).then((function(){return r.sessionManager.runXRRenderLoop(),r._originalSceneAutoClear=r.scene.autoClear,r._nonVRCamera=r.scene.activeCamera,r.scene.activeCamera=r.camera,\"immersive-ar\"!==e?r._nonXRToXRCamera():(r.scene.autoClear=!1,r.camera.compensateOnFirstFrame=!1),r.sessionManager.onXRSessionEnded.addOnce((function(){r.camera.rigCameras.forEach((function(e){e.outputRenderTarget=null})),r.scene.autoClear=r._originalSceneAutoClear,r.scene.activeCamera=r._nonVRCamera,\"immersive-ar\"!==e&&r.camera.compensateOnFirstFrame&&(r._nonVRCamera.setPosition?r._nonVRCamera.setPosition(r.camera.position):r._nonVRCamera.position.copyFrom(r.camera.position)),r._setState($i.NOT_IN_XR)})),r.sessionManager.onXRFrameObservable.addOnce((function(){r._setState($i.IN_XR)})),r.sessionManager})).catch((function(e){throw console.log(e),console.log(e.message),r._setState($i.NOT_IN_XR),e}))},e.prototype.exitXRAsync=function(){return this.state!==$i.IN_XR?Promise.resolve():(this._setState($i.EXITING_XR),this.sessionManager.exitXRAsync())},e.prototype._nonXRToXRCamera=function(){this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),this.onInitialXRPoseSetObservable.notifyObservers(this.camera)},e.prototype._setState=function(e){this.state!==e&&(this.state=e,this.onStateChangedObservable.notifyObservers(this.state))},e}(),La=function(){function e(e,t,i,n){void 0===i&&(i=-1),void 0===n&&(n=[]),this.id=e,this.type=t,this._buttonIndex=i,this._axesIndices=n,this._axes={x:0,y:0},this._changes={},this._currentValue=0,this._hasChanges=!1,this._pressed=!1,this._touched=!1,this.onAxisValueChangedObservable=new o.c,this.onButtonStateChangedObservable=new o.c}return Object.defineProperty(e.prototype,\"axes\",{get:function(){return this._axes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"changes\",{get:function(){return this._changes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"hasChanges\",{get:function(){return this._hasChanges},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"pressed\",{get:function(){return this._pressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"touched\",{get:function(){return this._touched},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"value\",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.onAxisValueChangedObservable.clear(),this.onButtonStateChangedObservable.clear()},e.prototype.isAxes=function(){return 0!==this._axesIndices.length},e.prototype.isButton=function(){return-1!==this._buttonIndex},e.prototype.update=function(e){var t=!1,i=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var n=e.buttons[this._buttonIndex];if(!n)return;this._currentValue!==n.value&&(this.changes.value={current:n.value,previous:this._currentValue},t=!0,this._currentValue=n.value),this._touched!==n.touched&&(this.changes.touched={current:n.touched,previous:this._touched},t=!0,this._touched=n.touched),this._pressed!==n.pressed&&(this.changes.pressed={current:n.pressed,previous:this._pressed},t=!0,this._pressed=n.pressed)}this.isAxes()&&(this._axes.x!==e.axes[this._axesIndices[0]]&&(this.changes.axes={current:{x:e.axes[this._axesIndices[0]],y:this._axes.y},previous:{x:this._axes.x,y:this._axes.y}},this._axes.x=e.axes[this._axesIndices[0]],i=!0),this._axes.y!==e.axes[this._axesIndices[1]]&&(this.changes.axes?this.changes.axes.current.y=e.axes[this._axesIndices[1]]:this.changes.axes={current:{x:this._axes.x,y:e.axes[this._axesIndices[1]]},previous:{x:this._axes.x,y:this._axes.y}},this._axes.y=e.axes[this._axesIndices[1]],i=!0)),t&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),i&&(this._hasChanges=!0,this.onAxisValueChangedObservable.notifyObservers(this._axes))},e.BUTTON_TYPE=\"button\",e.SQUEEZE_TYPE=\"squeeze\",e.THUMBSTICK_TYPE=\"thumbstick\",e.TOUCHPAD_TYPE=\"touchpad\",e.TRIGGER_TYPE=\"trigger\",e}(),wa=function(){function e(e,t,i,n,r){var a=this;void 0===r&&(r=!1),this.scene=e,this.layout=t,this.gamepadObject=i,this.handedness=n,this._initComponent=function(e){if(e){var t=a.layout.components[e],i=t.type,n=t.gamepadIndices.button,r=[];void 0!==t.gamepadIndices.xAxis&&void 0!==t.gamepadIndices.yAxis&&r.push(t.gamepadIndices.xAxis,t.gamepadIndices.yAxis),a.components[e]=new La(e,i,n,r)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new o.c,t.components&&Object.keys(t.components).forEach(this._initComponent)}return e.prototype.dispose=function(){var e=this;this.getComponentIds().forEach((function(t){return e.getComponent(t).dispose()})),this.rootMesh&&this.rootMesh.dispose()},e.prototype.getAllComponentsOfType=function(e){var t=this;return this.getComponentIds().map((function(e){return t.components[e]})).filter((function(t){return t.type===e}))},e.prototype.getComponent=function(e){return this.components[e]},e.prototype.getComponentIds=function(){return Object.keys(this.components)},e.prototype.getComponentOfType=function(e){return this.getAllComponentsOfType(e)[0]||null},e.prototype.getMainComponent=function(){return this.getComponent(this.layout.selectComponentId)},e.prototype.loadModel=function(){return Object(h.b)(this,void 0,void 0,(function(){var e,t,i=this;return Object(h.e)(this,(function(n){return e=!this._getModelLoadingConstraints(),t=this._getGenericFilenameAndPath(),e?m.a.Warn(\"Falling back to generic models\"):t=this._getFilenameAndPath(),[2,new Promise((function(n,r){pr.ImportMesh(\"\",t.path,t.filename,i.scene,(function(t){e?i._getGenericParentMesh(t):i._setRootMesh(t),i._processLoadedModel(t),i._modelReady=!0,i.onModelLoadedObservable.notifyObservers(i),n(!0)}),null,(function(e,n){m.a.Log(n),m.a.Warn(\"Failed to retrieve controller model of type \"+i.profileId+\" from the remote server: \"+t.path+t.filename),r(n)}))}))]}))}))},e.prototype.updateFromXRFrame=function(e){var t=this;this.getComponentIds().forEach((function(e){return t.getComponent(e).update(t.gamepadObject)})),this.updateModel(e)},Object.defineProperty(e.prototype,\"handness\",{get:function(){return this.handedness},enumerable:!1,configurable:!0}),e.prototype.pulse=function(e,t,i){return void 0===i&&(i=0),this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[i]?this.gamepadObject.hapticActuators[i].pulse(e,t):Promise.resolve(!1)},e.prototype._getChildByName=function(e,t){return e.getChildren((function(e){return e.name===t}),!1)[0]},e.prototype._getImmediateChildByName=function(e,t){return e.getChildren((function(e){return e.name==t}),!0)[0]},e.prototype._lerpTransform=function(e,t,i){if(e.minMesh&&e.maxMesh&&e.valueMesh&&e.minMesh.rotationQuaternion&&e.maxMesh.rotationQuaternion&&e.valueMesh.rotationQuaternion){var n=i?.5*t+.5:t;a.b.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,n,e.valueMesh.rotationQuaternion),a.e.LerpToRef(e.minMesh.position,e.maxMesh.position,n,e.valueMesh.position)}},e.prototype.updateModel=function(e){this._modelReady&&this._updateModel(e)},e.prototype._getGenericFilenameAndPath=function(){return{filename:\"generic.babylon\",path:\"https://controllers.babylonjs.com/generic/\"}},e.prototype._getGenericParentMesh=function(e){var t=this;this.rootMesh=new be.a(this.profileId+\" \"+this.handedness,this.scene),e.forEach((function(e){e.parent||(e.isPickable=!1,e.setParent(t.rootMesh))})),this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0)},e}(),Fa=function(e){function t(i,n,r){var o=e.call(this,i,Ba[r],n,r)||this;return o.profileId=t.ProfileId,o}return Object(h.d)(t,e),t.prototype._getFilenameAndPath=function(){return{filename:\"generic.babylon\",path:\"https://controllers.babylonjs.com/generic/\"}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){},t.prototype._setRootMesh=function(e){var t=this;this.rootMesh=new be.a(this.profileId+\" \"+this.handedness,this.scene),e.forEach((function(e){e.isPickable=!1,e.parent||e.setParent(t.rootMesh)})),this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId=\"generic-trigger\",t}(wa),Ba={left:{selectComponentId:\"xr-standard-trigger\",components:{\"xr-standard-trigger\":{type:\"trigger\",gamepadIndices:{button:0},rootNodeName:\"xr_standard_trigger\",visualResponses:{}}},gamepadMapping:\"xr-standard\",rootNodeName:\"generic-trigger-left\",assetPath:\"left.glb\"},right:{selectComponentId:\"xr-standard-trigger\",components:{\"xr-standard-trigger\":{type:\"trigger\",gamepadIndices:{button:0},rootNodeName:\"xr_standard_trigger\",visualResponses:{}}},gamepadMapping:\"xr-standard\",rootNodeName:\"generic-trigger-right\",assetPath:\"right.glb\"},none:{selectComponentId:\"xr-standard-trigger\",components:{\"xr-standard-trigger\":{type:\"trigger\",gamepadIndices:{button:0},rootNodeName:\"xr_standard_trigger\",visualResponses:{}}},gamepadMapping:\"xr-standard\",rootNodeName:\"generic-trigger-none\",assetPath:\"none.glb\"}},Ua=function(e){function t(t,i,n,r){var o=e.call(this,t,n.layouts[i.handedness||\"none\"],i.gamepad,i.handedness)||this;return o._repositoryUrl=r,o._buttonMeshMapping={},o._touchDots={},o.profileId=n.profileId,o}return Object(h.d)(t,e),t.prototype.dispose=function(){var t=this;e.prototype.dispose.call(this),Object.keys(this._touchDots).forEach((function(e){t._touchDots[e].dispose()}))},t.prototype._getFilenameAndPath=function(){return{filename:this.layout.assetPath,path:this._repositoryUrl+\"/profiles/\"+this.profileId+\"/\"}},t.prototype._getModelLoadingConstraints=function(){var e=pr.IsPluginForExtensionAvailable(\".glb\");return e||m.a.Warn(\"glTF / glb loaded was not registered, using generic controller instead\"),e},t.prototype._processLoadedModel=function(e){var t=this;this.getComponentIds().forEach((function(e){var i=t.layout.components[e];t._buttonMeshMapping[e]={mainMesh:t._getChildByName(t.rootMesh,i.rootNodeName),states:{}},Object.keys(i.visualResponses).forEach((function(n){var r=i.visualResponses[n];if(\"transform\"===r.valueNodeProperty)t._buttonMeshMapping[e].states[n]={valueMesh:t._getChildByName(t.rootMesh,r.valueNodeName),minMesh:t._getChildByName(t.rootMesh,r.minNodeName),maxMesh:t._getChildByName(t.rootMesh,r.maxNodeName)};else{var o=i.type===La.TOUCHPAD_TYPE&&i.touchPointNodeName?i.touchPointNodeName:r.valueNodeName;if(t._buttonMeshMapping[e].states[n]={valueMesh:t._getChildByName(t.rootMesh,o)},i.type===La.TOUCHPAD_TYPE&&!t._touchDots[n]){var a=xr.a.CreateSphere(n+\"dot\",{diameter:.0015,segments:8},t.scene);a.material=new Wi.a(n+\"mat\",t.scene),a.material.diffuseColor=s.a.Red(),a.parent=t._buttonMeshMapping[e].states[n].valueMesh||null,a.isVisible=!1,t._touchDots[n]=a}}}))}))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new be.a(this.profileId+\"-\"+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;in/10&&(a.isVisible=!0),(s+=t._scene.getEngine().getDeltaTime())>=n)t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),c=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),a.isVisible=!1;else{var e=1-s/n;a.scaling.set(e,e,e)}else c=!1,s=0;t._scene.simulatePointerMove(i.pick,{pointerId:i.id}),o=i.pick}})),void 0!==this._options.renderingGroupId&&(a.renderingGroupId=this._options.renderingGroupId),e&&e.onDisposeObservable.addOnce((function(){i.pick&&!t._options.disablePointerUpOnTouchOut&&c&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),a.dispose()}))},t.prototype._attachScreenRayMode=function(e){var t=this,i=this._controllers[e.uniqueId],n=!1;i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){!i.pick||t._options.disablePointerUpOnTouchOut&&n||(n?t._scene.simulatePointerMove(i.pick,{pointerId:i.id}):(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),n=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id})))})),e.onDisposeObservable.addOnce((function(){i.pick&&n&&!t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id})}))},t.prototype._attachTrackedPointerRayMode=function(e){var t=this,i=this._controllers[e.uniqueId];if(this._options.forceGazeMode)return this._attachGazeMode(e);if(i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){i.laserPointer.material.disableLighting=t.disablePointerLighting,i.selectionMesh.material.disableLighting=t.disableSelectionMeshLighting,i.pick&&t._scene.simulatePointerMove(i.pick,{pointerId:i.id})})),e.inputSource.gamepad){var n=function(n){t._options.overrideButtonId&&(i.selectionComponent=n.getComponent(t._options.overrideButtonId)),i.selectionComponent||(i.selectionComponent=n.getMainComponent()),i.onButtonChangedObserver=i.selectionComponent.onButtonStateChangedObservable.add((function(n){if(n.changes.pressed){var r=n.changes.pressed.current;i.pick?(t._options.enablePointerSelectionOnAllControllers||e.uniqueId===t._attachedController)&&(r?(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=t.laserPointerPickedColor):(t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)):!r||t._options.enablePointerSelectionOnAllControllers||t._options.disableSwitchOnClick||(t._attachedController=e.uniqueId)}}))};e.motionController?n(e.motionController):e.onMotionControllerInitObservable.add(n)}else{var r=function(e){i.xrController&&e.inputSource===i.xrController.inputSource&&i.pick&&(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=t.laserPointerPickedColor)},o=function(e){i.xrController&&e.inputSource===i.xrController.inputSource&&i.pick&&(t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)};i.eventListeners={selectend:o,selectstart:r},this._xrSessionManager.session.addEventListener(\"selectstart\",r),this._xrSessionManager.session.addEventListener(\"selectend\",o)}},t.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(a.e.Dot(e,t.direction))n},t.prototype._updatePointerDistance=function(e,t){void 0===t&&(t=100),e.scaling.y=t,this._scene.useRightHandedSystem&&(t*=-1),e.position.z=t/2+.05},Object.defineProperty(t.prototype,\"lasterPointerDefaultColor\",{get:function(){return this.laserPointerDefaultColor},enumerable:!1,configurable:!0}),t._idCounter=200,t.Name=Ia.POINTER_SELECTION,t.Version=1,t}(ja);Da.AddWebXRFeature(Wa.Name,(function(e,t){return function(){return new Wa(e,t)}}),Wa.Version,!0);var Ha,Xa=function(){function e(e,t,i){this.element=e,this.sessionMode=t,this.referenceSpaceType=i}return e.prototype.update=function(e){},e}(),Ya=function(){},Ka=function(){function e(e,t){var i=this;if(this.scene=e,this.options=t,this._activeButton=null,this._buttons=[],this.activeButtonChangedObservable=new o.c,this.overlay=document.createElement(\"div\"),this.overlay.classList.add(\"xr-button-overlay\"),this.overlay.style.cssText=\"z-index:11;position: absolute; right: 20px;bottom: 50px;\",\"undefined\"!=typeof window&&window.location&&\"http:\"===window.location.protocol&&Ce.b.Warn(\"WebXR can only be served over HTTPS\"),t.customButtons)this._buttons=t.customButtons;else{var n=t.sessionMode||\"immersive-vr\",r=t.referenceSpaceType||\"local-floor\",a=\".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(\"+(\"undefined\"==typeof SVGSVGElement?\"https://cdn.babylonjs.com/Assets/vrButton.png\":\"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A\")+\"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }\";a+='.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: \"EXIT\"} .xr-error::after { content: \"ERROR\"}';var s=document.createElement(\"style\");s.appendChild(document.createTextNode(a)),document.getElementsByTagName(\"head\")[0].appendChild(s);var c=document.createElement(\"button\");c.className=\"babylonVRicon\",c.title=n+\" - \"+r,this._buttons.push(new Xa(c,n,r)),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?\"\":\"none\",c.className=\"babylonVRicon\"+(e===this?\" vrdisplaypresenting\":\"\")},this._updateButtons(null)}var l=e.getEngine().getInputElement();l&&l.parentNode&&(l.parentNode.appendChild(this.overlay),e.onDisposeObservable.addOnce((function(){i.dispose()})))}return e.CreateAsync=function(t,i,n){var r=this,o=new e(t,n),a=o._buttons.map((function(e){return i.sessionManager.isSessionSupportedAsync(e.sessionMode)}));return i.onStateChangedObservable.add((function(e){e==$i.NOT_IN_XR&&o._updateButtons(null)})),Promise.all(a).then((function(e){return e.forEach((function(e,t){e?(o.overlay.appendChild(o._buttons[t].element),o._buttons[t].element.onclick=function(){return Object(h.b)(r,void 0,void 0,(function(){var e,r,a;return Object(h.e)(this,(function(s){switch(s.label){case 0:return i.state!=$i.IN_XR?[3,2]:[4,i.exitXRAsync()];case 1:return s.sent(),o._updateButtons(null),[3,6];case 2:if(i.state!=$i.NOT_IN_XR)return[3,6];if(!n.renderTarget)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,i.enterXRAsync(o._buttons[t].sessionMode,o._buttons[t].referenceSpaceType,n.renderTarget,{optionalFeatures:n.optionalFeatures,requiredFeatures:n.requiredFeatures})];case 4:return s.sent(),o._updateButtons(o._buttons[t]),[3,6];case 5:return e=s.sent(),o._updateButtons(null),r=o._buttons[t].element,a=r.title,r.title=\"Error entering XR session : \"+a,r.classList.add(\"xr-error\"),n.onError&&n.onError(e),[3,6];case 6:return[2]}}))}))}):Ce.b.Warn('Session mode \"'+o._buttons[t].sessionMode+'\" not supported in browser')})),o}))},e.prototype.dispose=function(){var e=this.scene.getEngine().getInputElement();e&&e.parentNode&&e.parentNode.contains(this.overlay)&&e.parentNode.removeChild(this.overlay),this.activeButtonChangedObservable.clear()},e.prototype._updateButtons=function(e){var t=this;this._activeButton=e,this._buttons.forEach((function(e){e.update(t._activeButton)})),this.activeButtonChangedObservable.notifyObservers(this._activeButton)},e}();function Qa(e){var t,i=0,n=Date.now();e.observableParameters=null!==(t=e.observableParameters)&&void 0!==t?t:{};var r=e.contextObservable.add((function(t){var o=Date.now(),a={startTime:n,currentTime:o,deltaTime:i=o-n,completeRate:i/e.timeout,payload:t};e.onTick&&e.onTick(a),e.breakCondition&&e.breakCondition()&&(e.contextObservable.remove(r),e.onAborted&&e.onAborted(a)),i>=e.timeout&&(e.contextObservable.remove(r),e.onEnded&&e.onEnded(a))}),e.observableParameters.mask,e.observableParameters.insertFirst,e.observableParameters.scope);return r}!function(e){e[e.INIT=0]=\"INIT\",e[e.STARTED=1]=\"STARTED\",e[e.ENDED=2]=\"ENDED\"}(Ha||(Ha={}));var qa=function(){function e(e){var t,i,n=this;this.onEachCountObservable=new o.c,this.onTimerAbortedObservable=new o.c,this.onTimerEndedObservable=new o.c,this.onStateChangedObservable=new o.c,this._observer=null,this._breakOnNextTick=!1,this._tick=function(e){var t=Date.now();n._timer=t-n._startTime;var i={startTime:n._startTime,currentTime:t,deltaTime:n._timer,completeRate:n._timer/n._timeToEnd,payload:e},r=n._breakOnNextTick||n._breakCondition(i);r||n._timer>=n._timeToEnd?n._stop(i,r):n.onEachCountObservable.notifyObservers(i)},this._setState(Ha.INIT),this._contextObservable=e.contextObservable,this._observableParameters=null!==(t=e.observableParameters)&&void 0!==t?t:{},this._breakCondition=null!==(i=e.breakCondition)&&void 0!==i?i:function(){return!1},e.onEnded&&this.onTimerEndedObservable.add(e.onEnded),e.onTick&&this.onEachCountObservable.add(e.onTick),e.onAborted&&this.onTimerAbortedObservable.add(e.onAborted)}return Object.defineProperty(e.prototype,\"breakCondition\",{set:function(e){this._breakCondition=e},enumerable:!1,configurable:!0}),e.prototype.clearObservables=function(){this.onEachCountObservable.clear(),this.onTimerAbortedObservable.clear(),this.onTimerEndedObservable.clear(),this.onStateChangedObservable.clear()},e.prototype.start=function(e){if(void 0===e&&(e=this._timeToEnd),this._state===Ha.STARTED)throw new Error(\"Timer already started. Please stop it before starting again\");this._timeToEnd=e,this._startTime=Date.now(),this._timer=0,this._observer=this._contextObservable.add(this._tick,this._observableParameters.mask,this._observableParameters.insertFirst,this._observableParameters.scope),this._setState(Ha.STARTED)},e.prototype.stop=function(){this._state===Ha.STARTED&&(this._breakOnNextTick=!0)},e.prototype.dispose=function(){this._observer&&this._contextObservable.remove(this._observer),this.clearObservables()},e.prototype._setState=function(e){this._state=e,this.onStateChangedObservable.notifyObservers(this._state)},e.prototype._stop=function(e,t){void 0===t&&(t=!1),this._contextObservable.remove(this._observer),this._setState(Ha.ENDED),t?this.onTimerAbortedObservable.notifyObservers(e):this.onTimerEndedObservable.notifyObservers(e)},e}(),Za=function(e){function t(t,i){var n=e.call(this,t)||this;return n._options=i,n._controllers={},n._snappedToPoint=!1,n._tmpRay=new Xt.a(new a.e,new a.e),n._tmpVector=new a.e,n._tmpQuaternion=new a.b,n.backwardsMovementEnabled=!0,n.backwardsTeleportationDistance=.7,n.parabolicCheckRadius=5,n.parabolicRayEnabled=!0,n.straightRayEnabled=!0,n.rotationAngle=Math.PI/8,n._rotationEnabled=!0,n._attachController=function(e){if(!(n._controllers[e.uniqueId]||n._options.forceHandedness&&e.inputSource.handedness!==n._options.forceHandedness)){n._controllers[e.uniqueId]={xrController:e,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0}};var t=n._controllers[e.uniqueId];if(\"tracked-pointer\"===t.xrController.inputSource.targetRayMode&&t.xrController.inputSource.gamepad){var i=function(){if(e.motionController){var i=e.motionController.getComponentOfType(La.THUMBSTICK_TYPE)||e.motionController.getComponentOfType(La.TOUCHPAD_TYPE);if(!i||n._options.useMainComponentOnly){var r=e.motionController.getMainComponent();if(!r)return;t.teleportationComponent=r,t.onButtonChangedObserver=r.onButtonStateChangedObservable.add((function(){r.changes.pressed&&(r.changes.pressed.current?(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Qa({timeout:n._options.timeToTeleport||3e3,contextObservable:n._xrSessionManager.onXRFrameObservable,breakCondition:function(){return!r.pressed},onEnded:function(){n._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}})):(t.teleportationState.forward=!1,n._currentTeleportationControllerId=\"\"))}))}else t.teleportationComponent=i,t.onAxisChangedObserver=i.onAxisValueChangedObservable.add((function(i){if(i.y<=.7&&t.teleportationState.backwards&&(t.teleportationState.backwards=!1),i.y>.7&&!t.teleportationState.forward&&n.backwardsMovementEnabled&&!n.snapPointsOnly&&!t.teleportationState.backwards){t.teleportationState.backwards=!0,n._tmpQuaternion.copyFrom(n._options.xrInput.xrCamera.rotationQuaternion),n._tmpQuaternion.toEulerAnglesToRef(n._tmpVector),n._tmpVector.x=0,n._tmpVector.z=0,a.b.FromEulerVectorToRef(n._tmpVector,n._tmpQuaternion),n._tmpVector.set(0,0,n.backwardsTeleportationDistance*(n._xrSessionManager.scene.useRightHandedSystem?1:-1)),n._tmpVector.rotateByQuaternionToRef(n._tmpQuaternion,n._tmpVector),n._tmpVector.addInPlace(n._options.xrInput.xrCamera.position),n._tmpRay.origin.copyFrom(n._tmpVector),n._tmpRay.length=n._options.xrInput.xrCamera.realWorldHeight+.1,n._tmpRay.direction.set(0,-1,0);var r=n._xrSessionManager.scene.pickWithRay(n._tmpRay,(function(e){return-1!==n._floorMeshes.indexOf(e)}));r&&r.pickedPoint&&(n._options.xrInput.xrCamera.position.x=r.pickedPoint.x,n._options.xrInput.xrCamera.position.z=r.pickedPoint.z)}if(i.y<-.7&&!n._currentTeleportationControllerId&&!t.teleportationState.rotating&&(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),i.x){if(t.teleportationState.forward)n._currentTeleportationControllerId===t.xrController.uniqueId&&(n.rotationEnabled?setTimeout((function(){t.teleportationState.currentRotation=Math.atan2(i.x,i.y*(n._xrSessionManager.scene.useRightHandedSystem?1:-1))})):t.teleportationState.currentRotation=0);else if(!t.teleportationState.rotating&&Math.abs(i.x)>.7){t.teleportationState.rotating=!0;var o=n.rotationAngle*(i.x>0?1:-1)*(n._xrSessionManager.scene.useRightHandedSystem?-1:1);n._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(a.b.FromEulerAngles(0,o,0))}}else t.teleportationState.rotating=!1;0===i.x&&0===i.y&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}))}};e.motionController?i():e.onMotionControllerInitObservable.addOnce((function(){i()}))}else n._xrSessionManager.scene.onPointerObservable.add((function(i){i.type===Ne.a.POINTERDOWN?(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Qa({timeout:n._options.timeToTeleport||3e3,contextObservable:n._xrSessionManager.onXRFrameObservable,onEnded:function(){n._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}})):i.type===Ne.a.POINTERUP&&(t.teleportationState.forward=!1,n._currentTeleportationControllerId=\"\")}))}},n._options.teleportationTargetMesh||n._createDefaultTargetMesh(),n._floorMeshes=n._options.floorMeshes||[],n._snapToPositions=n._options.snapPositions||[],n._setTargetMeshVisibility(!1),n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"rotationEnabled\",{get:function(){return this._rotationEnabled},set:function(e){if(this._rotationEnabled=e,this._options.teleportationTargetMesh){var t=this._options.teleportationTargetMesh.getChildMeshes(!1,(function(e){return\"rotationCone\"===e.name}));t[0]&&t[0].setEnabled(e)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"teleportationTargetMesh\",{get:function(){return this._options.teleportationTargetMesh||null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"snapPointsOnly\",{get:function(){return!!this._options.snapPointsOnly},set:function(e){this._options.snapPointsOnly=e},enumerable:!1,configurable:!0}),t.prototype.addFloorMesh=function(e){this._floorMeshes.push(e)},t.prototype.addSnapPoint=function(e){this._snapToPositions.push(e)},t.prototype.attach=function(){var t=this;return!!e.prototype.attach.call(this)&&(this._currentTeleportationControllerId=\"\",this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,(function(e){t._detachController(e.uniqueId)})),!0)},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach((function(e){t._detachController(e)})),this._setTargetMeshVisibility(!1),this._currentTeleportationControllerId=\"\",this._controllers={},!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.dispose(!1,!0)},t.prototype.removeFloorMesh=function(e){var t=this._floorMeshes.indexOf(e);-1!==t&&this._floorMeshes.splice(t,1)},t.prototype.removeFloorMeshByName=function(e){var t=this._xrSessionManager.scene.getMeshByName(e);t&&this.removeFloorMesh(t)},t.prototype.removeSnapPoint=function(e){var t=this._snapToPositions.indexOf(e);if(-1===t)for(var i=0;i=c.video.HAVE_CURRENT_DATA;return!s.poster||s.autoPlay&&l?l&&c._createInternalTexture():(c._texture=c._getEngine().createTexture(s.poster,!1,!c.invertY,n),c._displayingPosterTexture=!0),c}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"onUserActionRequestedObservable\",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new o.c),this._onUserActionRequestedObservable},enumerable:!1,configurable:!0}),t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:\"object\"==typeof e?e.toString():e},t.prototype._getVideo=function(e){if(e instanceof HTMLVideoElement)return Ce.b.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement(\"video\");return\"string\"==typeof e?(Ce.b.SetCorsBehavior(e,t),t.src=e):(Ce.b.SetCorsBehavior(e[0],t),e.forEach((function(e){var i=document.createElement(\"source\");i.src=e,t.appendChild(i)}))),t},t.prototype._rebuild=function(){this.update()},t.prototype.update=function(){this.autoUpdateTexture&&this.updateTexture(!0)},t.prototype.updateTexture=function(e){e&&(this.video.paused&&this._stillImageCaptured||(this._stillImageCaptured=!0,this._updateInternalTexture()))},t.prototype.updateURL=function(e){this.video.src=e,this._currentSrc=e},t.prototype.clone=function(){return new t(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._currentSrc=null,this._onUserActionRequestedObservable&&(this._onUserActionRequestedObservable.clear(),this._onUserActionRequestedObservable=null),this.video.removeEventListener(this._createInternalTextureOnEvent,this._createInternalTexture),this.video.removeEventListener(\"paused\",this._updateInternalTexture),this.video.removeEventListener(\"seeked\",this._updateInternalTexture),this.video.removeEventListener(\"emptied\",this.reset),this.video.pause()},t.CreateFromStreamAsync=function(e,i){var n=document.createElement(\"video\");return e.getEngine()._badOS&&(document.body.appendChild(n),n.style.transform=\"scale(0.0001, 0.0001)\",n.style.opacity=\"0\",n.style.position=\"fixed\",n.style.bottom=\"0px\",n.style.right=\"0px\"),n.setAttribute(\"autoplay\",\"\"),n.setAttribute(\"muted\",\"true\"),n.setAttribute(\"playsinline\",\"\"),n.muted=!0,void 0!==n.mozSrcObject?n.mozSrcObject=i:\"object\"==typeof n.srcObject?n.srcObject=i:(window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,n.src=window.URL&&window.URL.createObjectURL(i)),new Promise((function(i){var r=function(){i(new t(\"video\",n,e,!0,!0)),n.removeEventListener(\"playing\",r)};n.addEventListener(\"playing\",r),n.play()}))},t.CreateFromWebCamAsync=function(e,t,i){var n,r=this;return void 0===i&&(i=!1),t&&t.deviceId&&(n={exact:t.deviceId}),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:t,audio:i}).then((function(t){return r.CreateFromStreamAsync(e,t)})):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:t&&t.minWidth||256,max:t&&t.maxWidth||640},height:{min:t&&t.minHeight||256,max:t&&t.maxHeight||480}},audio:i},(function(t){return r.CreateFromStreamAsync(e,t)}),(function(e){m.a.Error(e.name)})),Promise.reject(\"No support for userMedia on this device\"))},t.CreateFromWebCam=function(e,t,i,n){void 0===n&&(n=!1),this.CreateFromWebCamAsync(e,i,n).then((function(e){t&&t(e)})).catch((function(e){m.a.Error(e.name)}))},t}(Ke.a),is=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"videoTexture\",{get:function(){return this._texture},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"videoMode\",{get:function(){return this.textureMode},set:function(e){this.textureMode=e},enumerable:!1,configurable:!0}),t.prototype._initTexture=function(e,t,i){var n=this,r={loop:i.loop,autoPlay:i.autoPlay,autoUpdateTexture:!0,poster:i.poster},o=new ts((this.name||\"videoDome\")+\"_texture\",e,t,i.generateMipMaps,this._useDirectMapping,Ke.a.TRILINEAR_SAMPLINGMODE,r);return i.clickToPlay&&(t.onPointerUp=function(){n._texture.video.play()}),o},t.MODE_MONOSCOPIC=vo.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=vo.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=vo.MODE_SIDEBYSIDE,t}(vo),ns=i(55),rs=function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._gpuFrameTime=new ns.a,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new ns.a,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(e.prototype,\"gpuFrameTimeCounter\",{get:function(){return this._gpuFrameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureGPUFrameTime\",{get:function(){return this._captureGPUFrameTime},set:function(e){var t=this;e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,e?(this._onBeginFrameObserver=this.engine.onBeginFrameObservable.add((function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.engine.startTimeQuery())})),this._onEndFrameObserver=this.engine.onEndFrameObservable.add((function(){if(t._gpuFrameTimeToken){var e=t.engine.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}}))):(this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"shaderCompilationTimeCounter\",{get:function(){return this._shaderCompilationTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureShaderCompilationTime\",{get:function(){return this._captureShaderCompilationTime},set:function(e){var t=this;e!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=e,e?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add((function(){t._shaderCompilationTime.fetchNewFrame(),t._shaderCompilationTime.beginMonitoring()})),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add((function(){t._shaderCompilationTime.endMonitoring()}))):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null,this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null,this.engine=null},e}(),os=function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new ns.a,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new ns.a,this._captureFrameTime=!1,this._frameTime=new ns.a,this._captureRenderTime=!1,this._renderTime=new ns.a,this._captureInterFrameTime=!1,this._interFrameTime=new ns.a,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new ns.a,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new ns.a,this._capturePhysicsTime=!1,this._physicsTime=new ns.a,this._captureAnimationsTime=!1,this._animationsTime=new ns.a,this._captureCameraRenderTime=!1,this._cameraRenderTime=new ns.a,this._onBeforeActiveMeshesEvaluationObserver=null,this._onAfterActiveMeshesEvaluationObserver=null,this._onBeforeRenderTargetsRenderObserver=null,this._onAfterRenderTargetsRenderObserver=null,this._onAfterRenderObserver=null,this._onBeforeDrawPhaseObserver=null,this._onAfterDrawPhaseObserver=null,this._onBeforeAnimationsObserver=null,this._onBeforeParticlesRenderingObserver=null,this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver=null,this._onAfterSpritesRenderingObserver=null,this._onBeforePhysicsObserver=null,this._onAfterPhysicsObserver=null,this._onAfterAnimationsObserver=null,this._onBeforeCameraRenderObserver=null,this._onAfterCameraRenderObserver=null,this._onBeforeAnimationsObserver=e.onBeforeAnimationsObservable.add((function(){t._captureActiveMeshesEvaluationTime&&t._activeMeshesEvaluationTime.fetchNewFrame(),t._captureRenderTargetsRenderTime&&t._renderTargetsRenderTime.fetchNewFrame(),t._captureFrameTime&&(Ce.b.StartPerformanceCounter(\"Scene rendering\"),t._frameTime.beginMonitoring()),t._captureInterFrameTime&&t._interFrameTime.endMonitoring(),t._captureParticlesRenderTime&&t._particlesRenderTime.fetchNewFrame(),t._captureSpritesRenderTime&&t._spritesRenderTime.fetchNewFrame(),t._captureAnimationsTime&&t._animationsTime.beginMonitoring(),t.scene.getEngine()._drawCalls.fetchNewFrame()})),this._onAfterRenderObserver=e.onAfterRenderObservable.add((function(){t._captureFrameTime&&(Ce.b.EndPerformanceCounter(\"Scene rendering\"),t._frameTime.endMonitoring()),t._captureRenderTime&&t._renderTime.endMonitoring(!1),t._captureInterFrameTime&&t._interFrameTime.beginMonitoring()}))}return Object.defineProperty(e.prototype,\"activeMeshesEvaluationTimeCounter\",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureActiveMeshesEvaluationTime\",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(e){var t=this;e!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=e,e?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add((function(){Ce.b.StartPerformanceCounter(\"Active meshes evaluation\"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){Ce.b.EndPerformanceCounter(\"Active meshes evaluation\"),t._activeMeshesEvaluationTime.endMonitoring()}))):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"renderTargetsRenderTimeCounter\",{get:function(){return this._renderTargetsRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureRenderTargetsRenderTime\",{get:function(){return this._captureRenderTargetsRenderTime},set:function(e){var t=this;e!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=e,e?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add((function(){Ce.b.StartPerformanceCounter(\"Render targets rendering\"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){Ce.b.EndPerformanceCounter(\"Render targets rendering\"),t._renderTargetsRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"particlesRenderTimeCounter\",{get:function(){return this._particlesRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureParticlesRenderTime\",{get:function(){return this._captureParticlesRenderTime},set:function(e){var t=this;e!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=e,e?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add((function(){Ce.b.StartPerformanceCounter(\"Particles\"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){Ce.b.EndPerformanceCounter(\"Particles\"),t._particlesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"spritesRenderTimeCounter\",{get:function(){return this._spritesRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureSpritesRenderTime\",{get:function(){return this._captureSpritesRenderTime},set:function(e){var t=this;e!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=e,this.scene.spriteManagers&&(e?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add((function(){Ce.b.StartPerformanceCounter(\"Sprites\"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){Ce.b.EndPerformanceCounter(\"Sprites\"),t._spritesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"physicsTimeCounter\",{get:function(){return this._physicsTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"capturePhysicsTime\",{get:function(){return this._capturePhysicsTime},set:function(e){var t=this;e!==this._capturePhysicsTime&&this.scene.onBeforePhysicsObservable&&(this._capturePhysicsTime=e,e?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add((function(){Ce.b.StartPerformanceCounter(\"Physics\"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){Ce.b.EndPerformanceCounter(\"Physics\"),t._physicsTime.endMonitoring()}))):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"animationsTimeCounter\",{get:function(){return this._animationsTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureAnimationsTime\",{get:function(){return this._captureAnimationsTime},set:function(e){var t=this;e!==this._captureAnimationsTime&&(this._captureAnimationsTime=e,e?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add((function(){t._animationsTime.endMonitoring()})):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"frameTimeCounter\",{get:function(){return this._frameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureFrameTime\",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"interFrameTimeCounter\",{get:function(){return this._interFrameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureInterFrameTime\",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"renderTimeCounter\",{get:function(){return this._renderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureRenderTime\",{get:function(){return this._captureRenderTime},set:function(e){var t=this;e!==this._captureRenderTime&&(this._captureRenderTime=e,e?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add((function(){t._renderTime.beginMonitoring(),Ce.b.StartPerformanceCounter(\"Main render\")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),Ce.b.EndPerformanceCounter(\"Main render\")}))):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"cameraRenderTimeCounter\",{get:function(){return this._cameraRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"captureCameraRenderTime\",{get:function(){return this._captureCameraRenderTime},set:function(e){var t=this;e!==this._captureCameraRenderTime&&(this._captureCameraRenderTime=e,e?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add((function(e){t._cameraRenderTime.beginMonitoring(),Ce.b.StartPerformanceCounter(\"Rendering camera \"+e.name)})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),Ce.b.EndPerformanceCounter(\"Rendering camera \"+e.name)}))):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"drawCallsCounter\",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=null,this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null,this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null,this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null,this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver&&(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null),this._onAfterSpritesRenderingObserver&&(this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null),this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null,this._onBeforePhysicsObserver&&(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null),this._onAfterPhysicsObserver&&(this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null),this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null,this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null,this.scene=null},e}(),as=\"#ifdef DIFFUSE\\nvarying vec2 vUVDiffuse;\\nuniform sampler2D diffuseSampler;\\n#endif\\n#ifdef OPACITY\\nvarying vec2 vUVOpacity;\\nuniform sampler2D opacitySampler;\\nuniform float opacityIntensity;\\n#endif\\n#ifdef EMISSIVE\\nvarying vec2 vUVEmissive;\\nuniform sampler2D emissiveSampler;\\n#endif\\n#ifdef VERTEXALPHA\\nvarying vec4 vColor;\\n#endif\\nuniform vec4 glowColor;\\nvoid main(void)\\n{\\nvec4 finalColor=glowColor;\\n\\n#ifdef DIFFUSE\\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\\n#ifdef GLOW\\n\\nfinalColor.a*=albedoTexture.a;\\n#endif\\n#ifdef HIGHLIGHT\\n\\nfinalColor.a=albedoTexture.a;\\n#endif\\n#endif\\n#ifdef OPACITY\\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\\n#ifdef OPACITYRGB\\nfinalColor.a*=getLuminance(opacityMap.rgb);\\n#else\\nfinalColor.a*=opacityMap.a;\\n#endif\\nfinalColor.a*=opacityIntensity;\\n#endif\\n#ifdef VERTEXALPHA\\nfinalColor.a*=vColor.a;\\n#endif\\n#ifdef ALPHATEST\\nif (finalColor.a\\n#include\\n#include[0..maxSimultaneousMorphTargets]\\n\\n#include\\nuniform mat4 viewProjection;\\nvarying vec4 vPosition;\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#ifdef DIFFUSE\\nvarying vec2 vUVDiffuse;\\nuniform mat4 diffuseMatrix;\\n#endif\\n#ifdef OPACITY\\nvarying vec2 vUVOpacity;\\nuniform mat4 opacityMatrix;\\n#endif\\n#ifdef EMISSIVE\\nvarying vec2 vUVEmissive;\\nuniform mat4 emissiveMatrix;\\n#endif\\n#ifdef VERTEXALPHA\\nattribute vec4 color;\\nvarying vec4 vColor;\\n#endif\\nvoid main(void)\\n{\\nvec3 positionUpdated=position;\\n#ifdef UV1\\nvec2 uvUpdated=uv;\\n#endif\\n#include[0..maxSimultaneousMorphTargets]\\n#include\\n#include\\n#ifdef CUBEMAP\\nvPosition=finalWorld*vec4(positionUpdated,1.0);\\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\\n#else\\nvPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\\ngl_Position=vPosition;\\n#endif\\n#ifdef DIFFUSE\\n#ifdef DIFFUSEUV1\\nvUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#ifdef DIFFUSEUV2\\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#endif\\n#ifdef OPACITY\\n#ifdef OPACITYUV1\\nvUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#ifdef OPACITYUV2\\nvUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#endif\\n#ifdef EMISSIVE\\n#ifdef EMISSIVEUV1\\nvUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#ifdef EMISSIVEUV2\\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#endif\\n#ifdef VERTEXALPHA\\nvColor=color;\\n#endif\\n}\";ai.a.ShadersStore.glowMapGenerationVertexShader=ss;var cs=function(){function e(t,i){this._vertexBuffers={},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._shouldRender=!0,this._postProcesses=[],this._textures=[],this._emissiveTextureAndColor={texture:null,color:new s.b},this.neutralColor=new s.b,this.isEnabled=!0,this.disableBoundingBoxesFromEffectLayer=!1,this.onDisposeObservable=new o.c,this.onBeforeRenderMainTextureObservable=new o.c,this.onBeforeComposeObservable=new o.c,this.onBeforeRenderMeshToEffect=new o.c,this.onAfterRenderMeshToEffect=new o.c,this.onAfterComposeObservable=new o.c,this.onSizeChangedObservable=new o.c,this.name=t,this._scene=i||x.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.effectLayers.push(this),this._generateIndexBuffer(),this._generateVertexBuffer()}return Object.defineProperty(e.prototype,\"camera\",{get:function(){return this._effectLayerOptions.camera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"renderingGroupId\",{get:function(){return this._effectLayerOptions.renderingGroupId},set:function(e){this._effectLayerOptions.renderingGroupId=e},enumerable:!1,configurable:!0}),e.prototype._init=function(e){this._effectLayerOptions=Object(h.a)({mainTextureRatio:.5,alphaBlendingMode:g.a.ALPHA_COMBINE,camera:null,renderingGroupId:-1},e),this._setMainTextureSize(),this._createMainTexture(),this._createTextureAndPostProcesses(),this._mergeEffect=this._createMergeEffect()},e.prototype._generateIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._engine.createIndexBuffer(e)},e.prototype._generateVertexBuffer=function(){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1);var t=new Qi.b(this._engine,e,Qi.b.PositionKind,!1,!1,2);this._vertexBuffers[Qi.b.PositionKind]=t},e.prototype._setMainTextureSize=function(){this._effectLayerOptions.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._effectLayerOptions.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._effectLayerOptions.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderWidth()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderHeight()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?Se.a.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?Se.a.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height),this._mainTextureDesiredSize.width=Math.floor(this._mainTextureDesiredSize.width),this._mainTextureDesiredSize.height=Math.floor(this._mainTextureDesiredSize.height)},e.prototype._createMainTexture=function(){var e=this;this._mainTexture=new Ni(\"HighlightLayerMainRTT\",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,!1,!0,g.a.TEXTURETYPE_UNSIGNED_INT),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._mainTexture.customRenderFunction=function(t,i,n,r){var o;e.onBeforeRenderMainTextureObservable.notifyObservers(e);var a=e._scene.getEngine();if(r.length){for(a.setColorWrite(!1),o=0;o4&&(o.push(Qi.b.MatricesIndicesExtraKind),o.push(Qi.b.MatricesWeightsExtraKind)),r.push(\"#define NUM_BONE_INFLUENCERS \"+a.numBoneInfluencers);var p=a.skeleton;p&&p.isUsingTextureForMatrices?r.push(\"#define BONETEXTURE\"):r.push(\"#define BonesPerMesh \"+(p?p.bones.length+1:0)),a.numBoneInfluencers>0&&f.addCPUSkinningFallback(0,a)}else r.push(\"#define NUM_BONE_INFLUENCERS 0\");var _=a.morphTargetManager,m=0;_&&_.numInfluencers>0&&(r.push(\"#define MORPHTARGETS\"),m=_.numInfluencers,r.push(\"#define NUM_MORPH_INFLUENCERS \"+m),ro.a.PrepareAttributesForMorphTargetsInfluencers(o,a,m)),t&&(r.push(\"#define INSTANCES\"),ro.a.PushAttributesForInstances(o),e.getRenderingMesh().hasThinInstances&&r.push(\"#define THIN_INSTANCES\")),this._addCustomEffectDefines(r);var g=r.join(\"\\n\");return this._cachedDefines!==g&&(this._cachedDefines=g,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect(\"glowMapGeneration\",o,[\"world\",\"mBones\",\"viewProjection\",\"glowColor\",\"morphTargetInfluences\",\"boneTextureWidth\",\"diffuseMatrix\",\"emissiveMatrix\",\"opacityMatrix\",\"opacityIntensity\"],[\"diffuseSampler\",\"emissiveSampler\",\"opacitySampler\",\"boneSampler\"],g,f,void 0,void 0,{maxSimultaneousMorphTargets:m})),this._effectLayerMapGenerationEffect.isReady()},e.prototype.render=function(){var e=this._mergeEffect;if(e.isReady()){for(var t=0;t-1&&this._scene.effectLayers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},e.prototype.getClassName=function(){return\"EffectLayer\"},e.Parse=function(e,t,i){return Ce.b.Instantiate(e.customType).Parse(e,t,i)},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport(\"EffectLayerSceneComponent\")},Object(h.c)([Object(w.c)()],e.prototype,\"name\",void 0),Object(h.c)([Object(w.f)()],e.prototype,\"neutralColor\",void 0),Object(h.c)([Object(w.c)()],e.prototype,\"isEnabled\",void 0),Object(h.c)([Object(w.d)()],e.prototype,\"camera\",null),Object(h.c)([Object(w.c)()],e.prototype,\"renderingGroupId\",null),Object(h.c)([Object(w.c)()],e.prototype,\"disableBoundingBoxesFromEffectLayer\",void 0),e}();n.a.AddParser(Me.a.NAME_EFFECTLAYER,(function(e,t,i,n){if(e.effectLayers){i.effectLayers||(i.effectLayers=new Array);for(var r=0;r0){this._previousStencilState=this._engine.getStencilBuffer();for(var n=0,r=i;n-1)){this._renderEffects=!0,this._needStencil=this._needStencil||o.needStencil();var a=o._mainTexture;a._shouldRender()&&(this.scene.incrementRenderId(),a.render(!1,!1),t=!0)}}this.scene.incrementRenderId()}return t},e.prototype._setStencil=function(){this._needStencil&&this._engine.setStencilBuffer(!0)},e.prototype._setStencilBack=function(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},e.prototype._draw=function(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var t=this.scene.effectLayers,i=0;i-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){this._meshesUsingTheirOwnMaterials.push(e.uniqueId)},t.prototype.unReferenceMeshFromUsingItsOwnMaterial=function(e){for(var t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);t>=0;)this._meshesUsingTheirOwnMaterials.splice(t,1),t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId)},t.prototype._disposeMesh=function(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)},t.prototype.getClassName=function(){return\"GlowLayer\"},t.prototype.serialize=function(){var e,t=w.a.Serialize(this);if(t.customType=\"BABYLON.GlowLayer\",t.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e0&&e.isBackground===t&&e.renderTargetTextures.indexOf(n)>-1&&0!=(e.layerMask&i)},e.prototype._drawRenderTargetBackground=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!0,t.scene.activeCamera.layerMask,e)}))},e.prototype._drawRenderTargetForeground=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!1,t.scene.activeCamera.layerMask,e)}))},e.prototype.addFromContainer=function(e){var t=this;e.layers&&e.layers.forEach((function(e){t.scene.layers.push(e)}))},e.prototype.removeFromContainer=function(e,t){var i=this;void 0===t&&(t=!1),e.layers&&e.layers.forEach((function(e){var n=i.scene.layers.indexOf(e);-1!==n&&i.scene.layers.splice(n,1),t&&e.dispose()}))},e}(),gs=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\n\\nuniform vec4 color;\\n\\n#include\\nvoid main(void) {\\nvec4 baseColor=texture2D(textureSampler,vUV);\\n#ifdef LINEAR\\nbaseColor.rgb=toGammaSpace(baseColor.rgb);\\n#endif\\n#ifdef ALPHATEST\\nif (baseColor.a<0.4)\\ndiscard;\\n#endif\\ngl_FragColor=baseColor*color;\\n}\";ai.a.ShadersStore.layerPixelShader=gs;var vs=\"\\nattribute vec2 position;\\n\\nuniform vec2 scale;\\nuniform vec2 offset;\\nuniform mat4 textureMatrix;\\n\\nvarying vec2 vUV;\\nconst vec2 madd=vec2(0.5,0.5);\\nvoid main(void) {\\nvec2 shiftedPosition=position*scale+offset;\\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\\ngl_Position=vec4(shiftedPosition,0.0,1.0);\\n}\";ai.a.ShadersStore.layerVertexShader=vs;var bs=function(){function e(e,t,i,n,r){this.name=e,this.scale=new a.d(1,1),this.offset=new a.d(0,0),this.alphaBlendingMode=g.a.ALPHA_COMBINE,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this._vertexBuffers={},this.onDisposeObservable=new o.c,this.onBeforeRenderObservable=new o.c,this.onAfterRenderObservable=new o.c,this.texture=t?new Ke.a(t,i,!0):null,this.isBackground=void 0===n||n,this.color=void 0===r?new s.b(1,1,1,1):r,this._scene=i||x.a.LastCreatedScene;var c=this._scene._getComponent(Me.a.NAME_LAYER);c||(c=new ms(this._scene),this._scene._addComponent(c)),this._scene.layers.push(this);var l=this._scene.getEngine(),u=[];u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1);var h=new Qi.b(l,u,Qi.b.PositionKind,!1,!1,2);this._vertexBuffers[Qi.b.PositionKind]=h,this._createIndexBuffer()}return Object.defineProperty(e.prototype,\"onDispose\",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onBeforeRender\",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onAfterRender\",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype._createIndexBuffer=function(){var e=this._scene.getEngine(),t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},e.prototype._rebuild=function(){var e=this._vertexBuffers[Qi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.render=function(){var e=this._scene.getEngine(),t=\"\";this.alphaTest&&(t=\"#define ALPHATEST\"),this.texture&&!this.texture.gammaSpace&&(t+=\"\\r\\n#define LINEAR\"),this._previousDefines!==t&&(this._previousDefines=t,this._effect=e.createEffect(\"layer\",[Qi.b.PositionKind],[\"textureMatrix\",\"color\",\"scale\",\"offset\"],[\"textureSampler\"],t));var i=this._effect;if(i&&i.isReady()&&this.texture&&this.texture.isReady()){e=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),e.enableEffect(i),e.setState(!1),i.setTexture(\"textureSampler\",this.texture),i.setMatrix(\"textureMatrix\",this.texture.getTextureMatrix()),i.setFloat4(\"color\",this.color.r,this.color.g,this.color.b,this.color.a),i.setVector2(\"offset\",this.offset),i.setVector2(\"scale\",this.scale),e.bindBuffers(this._vertexBuffers,this._indexBuffer,i),this.alphaTest?e.drawElementsType(xo.a.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(xo.a.TriangleFillMode,0,6),e.setAlphaMode(g.a.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},e.prototype.dispose=function(){var e=this._vertexBuffers[Qi.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[Qi.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null),this.renderTargetTextures=[];var t=this._scene.layers.indexOf(this);this._scene.layers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},e}(),ys=function(){function e(e,t,i,n,r){this.size=e,this.position=t,this.alphaMode=g.a.ALPHA_ONEONE,this.color=i||new s.a(1,1,1),this.texture=n?new Ke.a(n,r.getScene(),!0):null,this._system=r,r.lensFlares.push(this)}return e.AddFlare=function(t,i,n,r,o){return new e(t,i,n,r,o)},e.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},e}(),Ts=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\n\\nuniform vec4 color;\\nvoid main(void) {\\nvec4 baseColor=texture2D(textureSampler,vUV);\\ngl_FragColor=baseColor*color;\\n}\";ai.a.ShadersStore.lensFlarePixelShader=Ts;var Es=\"\\nattribute vec2 position;\\n\\nuniform mat4 viewportMatrix;\\n\\nvarying vec2 vUV;\\nconst vec2 madd=vec2(0.5,0.5);\\nvoid main(void) {\\nvUV=position*madd+madd;\\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\\n}\";ai.a.ShadersStore.lensFlareVertexShader=Es;var Ss=function(){function e(t,i,n){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=n||x.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._emitter=i,this.id=t,n.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return n.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&n.activeCamera.layerMask)};var r=n.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[Qi.b.PositionKind]=new Qi.b(r,o,Qi.b.PositionKind,!1,!1,2);var a=[];a.push(0),a.push(1),a.push(2),a.push(0),a.push(2),a.push(3),this._indexBuffer=r.createIndexBuffer(a),this._effect=r.createEffect(\"lensFlare\",[Qi.b.PositionKind],[\"color\",\"viewportMatrix\"],[\"textureSampler\"],\"\")}return Object.defineProperty(e.prototype,\"isEnabled\",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEmitter=function(){return this._emitter},e.prototype.setEmitter=function(e){this._emitter=e},e.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},e.prototype.computeEffectivePosition=function(e){var t=this.getEmitterPosition();return t=a.e.Project(t,a.a.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=a.e.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),this.viewportBorder>0&&(e.x-=this.viewportBorder,e.y-=this.viewportBorder,e.width+=2*this.viewportBorder,e.height+=2*this.viewportBorder,t.x+=this.viewportBorder,t.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),t.z>0&&(this._positionX>e.x&&this._positionXe.y&&(this._positionY,e.y,e.height),!0)},e.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var e=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),t=e.length();e.normalize();var i=new Xt.a(this._scene.activeCamera.globalPosition,e),n=this._scene.pickWithRay(i,this.meshesSelectionPredicate,!0);return!n||!n.hit||n.distance>t},e.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var e,t,i=this._scene.getEngine(),n=this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0),i.getRenderHeight(!0));if(!this.computeEffectivePosition(n))return!1;if(!this._isVisible())return!1;var r=(e=this._positionXn.x+n.width-this.borderLimit?this._positionX-n.x-n.width+this.borderLimit:0)>(t=this._positionYn.y+n.height-this.borderLimit?this._positionY-n.y-n.height+this.borderLimit:0)?e:t;(r-=this.viewportBorder)>this.borderLimit&&(r=this.borderLimit);var o=1-L.a.Clamp(r/this.borderLimit,0,1);if(o<0)return!1;o>1&&(o=1),this.viewportBorder>0&&(n.x+=this.viewportBorder,n.y+=this.viewportBorder,n.width-=2*this.viewportBorder,n.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var s=n.x+n.width/2,c=n.y+n.height/2,l=s-this._positionX,u=c-this._positionY;i.enableEffect(this._effect),i.setState(!1),i.setDepthBuffer(!1),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var h=0;h0);for(var i=0,n=t;i0)}},e}();Ss._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_LENSFLARESYSTEM);t||(t=new As(e),e._addComponent(t))};var Ps=\"\\n\\n\\n\\n\\nfloat bayerDither2(vec2 _P) {\\nreturn mod(2.0*_P.y+_P.x+1.0,4.0);\\n}\\n\\n\\nfloat bayerDither4(vec2 _P) {\\nvec2 P1=mod(_P,2.0);\\nvec2 P2=floor(0.5*mod(_P,4.0));\\nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);\\n}\\n\\nfloat bayerDither8(vec2 _P) {\\nvec2 P1=mod(_P,2.0);\\nvec2 P2=floor(0.5*mod(_P,4.0));\\nvec2 P4=floor(0.25*mod(_P,8.0));\\nreturn 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);\\n}\\n\";ai.a.IncludesShadersStore.bayerDitherFunctions=Ps;var Cs=\"#if SM_FLOAT == 0\\n#include\\n#endif\\n#if SM_SOFTTRANSPARENTSHADOW == 1\\n#include\\nuniform float softTransparentShadowSM;\\n#endif\\nvarying float vDepthMetricSM;\\n#if SM_USEDISTANCE == 1\\nuniform vec3 lightDataSM;\\nvarying vec3 vPositionWSM;\\n#endif\\nuniform vec3 biasAndScaleSM;\\nuniform vec2 depthValuesSM;\\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\\nvarying float zSM;\\n#endif\\n\";ai.a.IncludesShadersStore.shadowMapFragmentDeclaration=Cs;var Rs=\" float depthSM=vDepthMetricSM;\\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\\n#if SM_USEDISTANCE == 1\\ndepthSM=clamp(((length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);\\n#else\\ndepthSM=clamp(((zSM+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);\\n#endif\\ngl_FragDepth=depthSM;\\n#elif SM_USEDISTANCE == 1\\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y)+biasAndScaleSM.x;\\n#endif\\n#if SM_ESM == 1\\ndepthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);\\n#endif\\n#if SM_FLOAT == 1\\ngl_FragColor=vec4(depthSM,1.0,1.0,1.0);\\n#else\\ngl_FragColor=pack(depthSM);\\n#endif\\nreturn;\";ai.a.IncludesShadersStore.shadowMapFragment=Rs;var xs=\"#include\\n#ifdef ALPHATEST\\nvarying vec2 vUV;\\nuniform sampler2D diffuseSampler;\\n#endif\\n#include\\nvoid main(void)\\n{\\n#include\\n#ifdef ALPHATEST\\nfloat alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;\\nif (alphaFromAlphaTexture<0.4)\\ndiscard;\\n#endif\\n#if SM_SOFTTRANSPARENTSHADOW == 1\\n#ifdef ALPHATEST\\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;\\n#else\\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;\\n#endif\\n#endif\\n#include\\n}\";ai.a.ShadersStore.shadowMapPixelShader=xs;var Os=\"#if SM_NORMALBIAS == 1\\nuniform vec3 lightDataSM;\\n#endif\\nuniform vec3 biasAndScaleSM;\\nuniform vec2 depthValuesSM;\\nvarying float vDepthMetricSM;\\n#if SM_USEDISTANCE == 1\\nvarying vec3 vPositionWSM;\\n#endif\\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\\nvarying float zSM;\\n#endif\\n\";ai.a.IncludesShadersStore.shadowMapVertexDeclaration=Os;var Ms=\"\\n#if SM_NORMALBIAS == 1\\n#if SM_DIRECTIONINLIGHTDATA == 1\\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\\n#else\\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;\\nvec3 worldLightDirSM=normalize(directionToLightSM);\\n#endif\\nfloat ndlSM=dot(vNormalW,worldLightDirSM);\\nfloat sinNLSM=sqrt(1.0-ndlSM*ndlSM);\\nfloat normalBiasSM=biasAndScaleSM.y*sinNLSM;\\nworldPos.xyz-=vNormalW*normalBiasSM;\\n#endif\\n\";ai.a.IncludesShadersStore.shadowMapVertexNormalBias=Ms;var Is=\"#if SM_USEDISTANCE == 1\\nvPositionWSM=worldPos.xyz;\\n#endif\\n#if SM_DEPTHTEXTURE == 1\\n\\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w;\\n#endif\\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\\nzSM=gl_Position.z;\\ngl_Position.z=0.0;\\n#elif SM_USEDISTANCE == 0\\n\\nvDepthMetricSM=((gl_Position.z+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x;\\n#endif\\n\";ai.a.IncludesShadersStore.shadowMapVertexMetric=Is;var Ds=\"\\nattribute vec3 position;\\n#ifdef NORMAL\\nattribute vec3 normal;\\n#endif\\n#include\\n#include\\n#include[0..maxSimultaneousMorphTargets]\\n\\n#include\\n#include\\nuniform mat4 viewProjection;\\n#ifdef ALPHATEST\\nvarying vec2 vUV;\\nuniform mat4 diffuseMatrix;\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#endif\\n#include\\n#include\\nvoid main(void)\\n{\\nvec3 positionUpdated=position;\\n#ifdef UV1\\nvec2 uvUpdated=uv;\\n#endif\\n#ifdef NORMAL\\nvec3 normalUpdated=normal;\\n#endif\\n#include[0..maxSimultaneousMorphTargets]\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\\n#ifdef NORMAL\\nmat3 normWorldSM=mat3(finalWorld);\\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\\nvec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));\\nvNormalW=normalize(normWorldSM*vNormalW);\\n#else\\n#ifdef NONUNIFORMSCALING\\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\\n#endif\\nvec3 vNormalW=normalize(normWorldSM*normalUpdated);\\n#endif\\n#endif\\n#include\\n\\ngl_Position=viewProjection*worldPos;\\n#include\\n#ifdef ALPHATEST\\n#ifdef UV1\\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#ifdef UV2\\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#endif\\n#include\\n}\";ai.a.ShadersStore.shadowMapVertexShader=Ds;var Ns=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\n\\nuniform vec2 screenSize;\\nvoid main(void)\\n{\\nvec4 colorDepth=vec4(0.0);\\nfor (int x=-OFFSET; x<=OFFSET; x++)\\nfor (int y=-OFFSET; y<=OFFSET; y++)\\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\\n}\";ai.a.ShadersStore.depthBoxBlurPixelShader=Ns;var Ls=\"#if SM_SOFTTRANSPARENTSHADOW == 1\\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\\n#endif\\n\";ai.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow=Ls;var ws=new a.a,Fs=new a.a,Bs=function(){function e(t,i,n){this.onBeforeShadowMapRenderObservable=new o.c,this.onAfterShadowMapRenderObservable=new o.c,this.onBeforeShadowMapRenderMeshObservable=new o.c,this.onAfterShadowMapRenderMeshObservable=new o.c,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=e.FILTER_NONE,this._filteringQuality=e.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.enableSoftTransparentShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=a.e.Zero(),this._viewMatrix=a.a.Zero(),this._projectionMatrix=a.a.Zero(),this._transformMatrix=a.a.Zero(),this._cachedPosition=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=a.a.Identity(),this._mapSize=t,this._light=i,this._scene=i.getScene(),i._shadowGenerator=this,this.id=i.id,e._SceneComponentInitialization(this._scene);var r=this._scene.getEngine().getCaps();n?r.textureFloatRender&&r.textureFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_FLOAT:r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_HALF_FLOAT:this._textureType=g.a.TEXTURETYPE_UNSIGNED_INT:r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_HALF_FLOAT:r.textureFloatRender&&r.textureFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_FLOAT:this._textureType=g.a.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(e.prototype,\"bias\",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"normalBias\",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"blurBoxOffset\",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"blurScale\",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"blurKernel\",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"useKernelBlur\",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"depthScale\",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!1,configurable:!0}),e.prototype._validateFilter=function(e){return e},Object.defineProperty(e.prototype,\"filter\",{get:function(){return this._filter},set:function(t){if(t=this._validateFilter(t),this._light.needCube()){if(t===e.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(t===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(t===e.FILTER_PCF||t===e.FILTER_PCSS)return void(this.usePoissonSampling=!0)}t!==e.FILTER_PCF&&t!==e.FILTER_PCSS||1!==this._scene.getEngine().webGLVersion?this._filter!==t&&(this._filter=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"usePoissonSampling\",{get:function(){return this.filter===e.FILTER_POISSONSAMPLING},set:function(t){var i=this._validateFilter(e.FILTER_POISSONSAMPLING);(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"useExponentialShadowMap\",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"useBlurExponentialShadowMap\",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"useCloseExponentialShadowMap\",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"useBlurCloseExponentialShadowMap\",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"usePercentageCloserFiltering\",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){var i=this._validateFilter(e.FILTER_PCF);(t||this.filter===e.FILTER_PCF)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"filteringQuality\",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"useContactHardeningShadow\",{get:function(){return this.filter===e.FILTER_PCSS},set:function(t){var i=this._validateFilter(e.FILTER_PCSS);(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"contactHardeningLightSizeUVRatio\",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"darkness\",{get:function(){return this._darkness},set:function(e){this.setDarkness(e)},enumerable:!1,configurable:!0}),e.prototype.getDarkness=function(){return this._darkness},e.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},Object.defineProperty(e.prototype,\"transparencyShadow\",{get:function(){return this._transparencyShadow},set:function(e){this.setTransparencyShadow(e)},enumerable:!1,configurable:!0}),e.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},e.prototype.getShadowMap=function(){return this._shadowMap},e.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},e.prototype.getClassName=function(){return e.CLASSNAME},e.prototype.addShadowCaster=function(e,t){var i;return void 0===t&&(t=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(i=this._shadowMap.renderList).push.apply(i,e.getChildMeshes()),this):this},e.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var i=this._shadowMap.renderList.indexOf(e);if(-1!==i&&this._shadowMap.renderList.splice(i,1),t)for(var n=0,r=e.getChildren();n1?(this._shadowMap=new Ni(this._light.name+\"_shadowMap\",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(g.a.LESS,!0)):this._shadowMap=new Ni(this._light.name+\"_shadowMap\",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())},e.prototype._initializeShadowMap=function(){var t=this;if(this._createTargetRenderTexture(),null!==this._shadowMap){this._shadowMap.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.customIsReadyFunction=function(e,t){return!0};var i=this._scene.getEngine();this._shadowMap.onBeforeRenderObservable.add((function(n){if(t._currentFaceIndex=n,t._filter===e.FILTER_PCF&&i.setColorWrite(!1),t._scene.getSceneUniformBuffer().useUbo){var r=t._scene.getSceneUniformBuffer();r.updateMatrix(\"viewProjection\",t.getTransformMatrix()),r.updateMatrix(\"view\",t._viewMatrix),r.update()}})),this._shadowMap.onAfterUnbindObservable.add((function(){if(t._scene.getSceneUniformBuffer().useUbo){var n=t._scene.getSceneUniformBuffer();n.updateMatrix(\"viewProjection\",t._scene.getTransformMatrix()),n.updateMatrix(\"view\",t._scene.getViewMatrix()),n.update()}if(t._filter===e.FILTER_PCF&&i.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var r=t.getShadowMapForRendering();if(r){var o=r.getInternalTexture();t._scene.postProcessManager.directRender(t._blurPostProcesses,o,!0),i.unBindFramebuffer(o,!0)}}}));var n=new s.b(0,0,0,0),r=new s.b(1,1,1,1);this._shadowMap.onClearObservable.add((function(i){t._filter===e.FILTER_PCF?i.clear(r,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?i.clear(n,!0,!0,!1):i.clear(r,!0,!0,!1)})),this._shadowMap.onResizeObservable.add((function(e){t._storedUniqueId=t._shadowMap.uniqueId,t._mapSize=e.getRenderSize(),t._light._markMeshesAsLightDirty(),t.recreateShadowMap()}));for(var o=Di.b.MIN_RENDERINGGROUPS;o=a.length)return void(e&&e(i));setTimeout(d,16)}};d()}else e&&e(this)}else e&&e(this)}else e&&e(this)},e.prototype.forceCompilationAsync=function(e){var t=this;return new Promise((function(i){t.forceCompilation((function(){i()}),e)}))},e.prototype._isReadyCustomDefines=function(e,t,i){},e.prototype._prepareShadowDefines=function(e,t,i,n){i.push(\"#define SM_FLOAT \"+(this._textureType!==g.a.TEXTURETYPE_UNSIGNED_INT?\"1\":\"0\")),i.push(\"#define SM_ESM \"+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?\"1\":\"0\")),i.push(\"#define SM_DEPTHTEXTURE \"+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?\"1\":\"0\"));var r=e.getMesh();return i.push(\"#define SM_NORMALBIAS \"+(this.normalBias&&r.isVerticesDataPresent(Qi.b.NormalKind)?\"1\":\"0\")),i.push(\"#define SM_DIRECTIONINLIGHTDATA \"+(this.getLight().getTypeID()===kr.a.LIGHTTYPEID_DIRECTIONALLIGHT?\"1\":\"0\")),i.push(\"#define SM_USEDISTANCE \"+(this._light.needCube()?\"1\":\"0\")),i.push(\"#define SM_SOFTTRANSPARENTSHADOW \"+(this.enableSoftTransparentShadow&&n?\"1\":\"0\")),this._isReadyCustomDefines(i,e,t),i},e.prototype.isReady=function(e,t,i){var n=e.getMaterial(),r=null==n?void 0:n.shadowDepthWrapper,o=[];if(this._prepareShadowDefines(e,t,o,i),r){if(!r.isReadyForSubMesh(e,o,this,t))return!1}else{var a=[Qi.b.PositionKind],s=e.getMesh();if(this.normalBias&&s.isVerticesDataPresent(Qi.b.NormalKind)&&(a.push(Qi.b.NormalKind),o.push(\"#define NORMAL\"),s.nonUniformScaling&&o.push(\"#define NONUNIFORMSCALING\")),n&&n.needAlphaTesting()){var c=n.getAlphaTestTexture();if(c){if(!c.isReady())return!1;o.push(\"#define ALPHATEST\"),s.isVerticesDataPresent(Qi.b.UVKind)&&(a.push(Qi.b.UVKind),o.push(\"#define UV1\")),s.isVerticesDataPresent(Qi.b.UV2Kind)&&1===c.coordinatesIndex&&(a.push(Qi.b.UV2Kind),o.push(\"#define UV2\"))}}var l=new po.a;if(s.useBones&&s.computeBonesUsingShaders&&s.skeleton){a.push(Qi.b.MatricesIndicesKind),a.push(Qi.b.MatricesWeightsKind),s.numBoneInfluencers>4&&(a.push(Qi.b.MatricesIndicesExtraKind),a.push(Qi.b.MatricesWeightsExtraKind));var u=s.skeleton;o.push(\"#define NUM_BONE_INFLUENCERS \"+s.numBoneInfluencers),s.numBoneInfluencers>0&&l.addCPUSkinningFallback(0,s),u.isUsingTextureForMatrices?o.push(\"#define BONETEXTURE\"):o.push(\"#define BonesPerMesh \"+(u.bones.length+1))}else o.push(\"#define NUM_BONE_INFLUENCERS 0\");var h=s.morphTargetManager,d=0;h&&h.numInfluencers>0&&(o.push(\"#define MORPHTARGETS\"),d=h.numInfluencers,o.push(\"#define NUM_MORPH_INFLUENCERS \"+d),ro.a.PrepareAttributesForMorphTargetsInfluencers(a,s,d));var f=this._scene;if(f.clipPlane&&o.push(\"#define CLIPPLANE\"),f.clipPlane2&&o.push(\"#define CLIPPLANE2\"),f.clipPlane3&&o.push(\"#define CLIPPLANE3\"),f.clipPlane4&&o.push(\"#define CLIPPLANE4\"),f.clipPlane5&&o.push(\"#define CLIPPLANE5\"),f.clipPlane6&&o.push(\"#define CLIPPLANE6\"),t&&(o.push(\"#define INSTANCES\"),ro.a.PushAttributesForInstances(a),e.getRenderingMesh().hasThinInstances&&o.push(\"#define THIN_INSTANCES\")),this.customShaderOptions&&this.customShaderOptions.defines)for(var p=0,_=this.customShaderOptions.defines;p<_.length;p++){var m=_[p];-1===o.indexOf(m)&&o.push(m)}var g=o.join(\"\\n\");if(this._cachedDefines!==g){this._cachedDefines=g;var v=\"shadowMap\",b=[\"world\",\"mBones\",\"viewProjection\",\"diffuseMatrix\",\"lightDataSM\",\"depthValuesSM\",\"biasAndScaleSM\",\"morphTargetInfluences\",\"boneTextureWidth\",\"vClipPlane\",\"vClipPlane2\",\"vClipPlane3\",\"vClipPlane4\",\"vClipPlane5\",\"vClipPlane6\",\"softTransparentShadowSM\"],y=[\"diffuseSampler\",\"boneSampler\"];if(this.customShaderOptions){if(v=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(var T=0,E=this.customShaderOptions.attributes;T\\n#endif\\nvoid main(void)\\n{\\n#ifdef ALPHATEST\\nif (texture2D(diffuseSampler,vUV).a<0.4)\\ndiscard;\\n#endif\\n#ifdef NONLINEARDEPTH\\n#ifdef PACKED\\ngl_FragColor=pack(gl_FragCoord.z);\\n#else\\ngl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);\\n#endif\\n#else\\n#ifdef PACKED\\ngl_FragColor=pack(vDepthMetric);\\n#else\\ngl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);\\n#endif\\n#endif\\n}\";ai.a.ShadersStore.depthPixelShader=Us;var Vs=\"\\nattribute vec3 position;\\n#include\\n#include\\n#include[0..maxSimultaneousMorphTargets]\\n\\n#include\\nuniform mat4 viewProjection;\\nuniform vec2 depthValues;\\n#if defined(ALPHATEST) || defined(NEED_UV)\\nvarying vec2 vUV;\\nuniform mat4 diffuseMatrix;\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#endif\\nvarying float vDepthMetric;\\nvoid main(void)\\n{\\nvec3 positionUpdated=position;\\n#ifdef UV1\\nvec2 uvUpdated=uv;\\n#endif\\n#include[0..maxSimultaneousMorphTargets]\\n#include\\n#include\\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\\n#ifdef UV1\\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#ifdef UV2\\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#endif\\n}\\n\";ai.a.ShadersStore.depthVertexShader=Vs;var ks=function(){function e(t,i,n,r){var o=this;void 0===i&&(i=g.a.TEXTURETYPE_FLOAT),void 0===n&&(n=null),void 0===r&&(r=!1),this.enabled=!0,this.useOnlyInActiveCamera=!1,this._scene=t,this._storeNonLinearDepth=r,this.isPacked=i===g.a.TEXTURETYPE_UNSIGNED_BYTE,this.isPacked?this._clearColor=new s.b(1,1,1,1):this._clearColor=new s.b(1,0,0,1),e._SceneComponentInitialization(this._scene),this._camera=n;var a=t.getEngine(),c=this.isPacked||1===a.webGLVersion?g.a.TEXTUREFORMAT_RGBA:g.a.TEXTUREFORMAT_R;this._depthMap=new Ni(\"depthMap\",{width:a.getRenderWidth(),height:a.getRenderHeight()},this._scene,!1,!0,i,!1,void 0,void 0,void 0,void 0,c),this._depthMap.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._depthMap.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add((function(e){e.clear(o._clearColor,!0,!0,!0)}));var l=function(e){var t=e.getRenderingMesh(),i=e.getEffectiveMesh(),n=o._scene,r=n.getEngine(),a=e.getMaterial();if(i._internalAbstractMeshDataInfo._isActiveIntermediate=!1,a&&0!==e.verticesCount&&e._renderId!==n.getRenderId()){r.setState(a.backFaceCulling,0,!1,n.useRightHandedSystem);var s=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(!s.mustReturn){var c=r.getCaps().instancedArrays&&(null!==s.visibleInstances[e._id]&&void 0!==s.visibleInstances[e._id]||t.hasThinInstances),l=o._camera||n.activeCamera;if(o.isReady(e,c)&&l){if(e._renderId=n.getRenderId(),r.enableEffect(o._effect),t._bind(e,o._effect,a.fillMode),o._effect.setMatrix(\"viewProjection\",n.getTransformMatrix()),o._effect.setFloat2(\"depthValues\",l.minZ,l.minZ+l.maxZ),a&&a.needAlphaTesting()){var u=a.getAlphaTestTexture();u&&(o._effect.setTexture(\"diffuseSampler\",u),o._effect.setMatrix(\"diffuseMatrix\",u.getTextureMatrix()))}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&o._effect.setMatrices(\"mBones\",t.skeleton.getTransformMatrices(t)),ro.a.BindMorphTargetParameters(t,o._effect),t._processRendering(i,e,o._effect,a.fillMode,s,c,(function(e,t){return o._effect.setMatrix(\"world\",t)}))}}}};this._depthMap.customRenderFunction=function(e,t,i,n){var r;if(n.length){for(a.setColorWrite(!1),r=0;r4&&(r.push(Qi.b.MatricesIndicesExtraKind),r.push(Qi.b.MatricesWeightsExtraKind)),n.push(\"#define NUM_BONE_INFLUENCERS \"+o.numBoneInfluencers),n.push(\"#define BonesPerMesh \"+(o.skeleton?o.skeleton.bones.length+1:0))):n.push(\"#define NUM_BONE_INFLUENCERS 0\");var a=o.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,n.push(\"#define MORPHTARGETS\"),n.push(\"#define NUM_MORPH_INFLUENCERS \"+s),ro.a.PrepareAttributesForMorphTargetsInfluencers(r,o,s)),t&&(n.push(\"#define INSTANCES\"),ro.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&n.push(\"#define THIN_INSTANCES\")),this._storeNonLinearDepth&&n.push(\"#define NONLINEARDEPTH\"),this.isPacked&&n.push(\"#define PACKED\");var c=n.join(\"\\n\");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this._scene.getEngine().createEffect(\"depth\",r,[\"world\",\"mBones\",\"viewProjection\",\"diffuseMatrix\",\"depthValues\",\"morphTargetInfluences\"],[\"diffuseSampler\"],c,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){this._depthMap.dispose()},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport(\"DepthRendererSceneComponent\")},e}(),zs=\"attribute vec2 vUV;\\nuniform sampler2D textureSampler;\\n#if defined(INITIAL)\\nuniform sampler2D sourceTexture;\\nuniform vec2 texSize;\\nvoid main(void)\\n{\\nivec2 coord=ivec2(vUV*(texSize-1.0));\\nfloat f1=texelFetch(sourceTexture,coord,0).r;\\nfloat f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;\\nfloat f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;\\nfloat f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;\\nfloat minz=min(min(min(f1,f2),f3),f4);\\n#ifdef DEPTH_REDUX\\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\\n#else\\nfloat maxz=max(max(max(f1,f2),f3),f4);\\n#endif\\nglFragColor=vec4(minz,maxz,0.,0.);\\n}\\n#elif defined(MAIN)\\nuniform vec2 texSize;\\nvoid main(void)\\n{\\nivec2 coord=ivec2(vUV*(texSize-1.0));\\nvec2 f1=texelFetch(textureSampler,coord,0).rg;\\nvec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;\\nvec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;\\nvec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;\\nfloat minz=min(min(min(f1.x,f2.x),f3.x),f4.x);\\nfloat maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);\\nglFragColor=vec4(minz,maxz,0.,0.);\\n}\\n#elif defined(ONEBEFORELAST)\\nuniform ivec2 texSize;\\nvoid main(void)\\n{\\nivec2 coord=ivec2(vUV*vec2(texSize-1));\\nvec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;\\nvec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;\\nvec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;\\nvec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;\\nfloat minz=min(f1.x,f2.x);\\nfloat maxz=max(f1.y,f2.y);\\nglFragColor=vec4(minz,maxz,0.,0.);\\n}\\n#elif defined(LAST)\\nvoid main(void)\\n{\\ndiscard;\\nglFragColor=vec4(0.);\\n}\\n#endif\\n\";ai.a.ShadersStore.minmaxReduxPixelShader=zs;var Gs=function(){function e(e){this.onAfterReductionPerformed=new o.c,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new Ii.a(e.getScene())}return Object.defineProperty(e.prototype,\"sourceTexture\",{get:function(){return this._sourceTexture},enumerable:!1,configurable:!0}),e.prototype.setSourceTexture=function(e,t,i,n){var r=this;if(void 0===i&&(i=g.a.TEXTURETYPE_HALF_FLOAT),void 0===n&&(n=!0),e!==this._sourceTexture){this.dispose(!1),this._sourceTexture=e,this._reductionSteps=[],this._forceFullscreenViewport=n;var o=this._camera.getScene(),a=new li(\"Initial reduction phase\",\"minmaxRedux\",[\"texSize\"],[\"sourceTexture\"],1,null,g.a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,\"#define INITIAL\"+(t?\"\\n#define DEPTH_REDUX\":\"\"),i,void 0,void 0,void 0,g.a.TEXTUREFORMAT_RG);a.autoClear=!1,a.forceFullscreenViewport=n;var s=this._sourceTexture.getRenderWidth(),c=this._sourceTexture.getRenderHeight();a.onApply=function(e,t){return function(i){i.setTexture(\"sourceTexture\",r._sourceTexture),i.setFloatArray2(\"texSize\",new Float32Array([e,t]))}}(s,c),this._reductionSteps.push(a);for(var l=1;s>1||c>1;){s=Math.max(Math.round(s/2),1),c=Math.max(Math.round(c/2),1);var u=new li(\"Reduction phase \"+l,\"minmaxRedux\",[\"texSize\"],null,{width:s,height:c},null,g.a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,\"#define \"+(1==s&&1==c?\"LAST\":1==s||1==c?\"ONEBEFORELAST\":\"MAIN\"),i,void 0,void 0,void 0,g.a.TEXTUREFORMAT_RG);if(u.autoClear=!1,u.forceFullscreenViewport=n,u.onApply=function(e,t){return function(i){1==e||1==t?i.setIntArray2(\"texSize\",new Int32Array([e,t])):i.setFloatArray2(\"texSize\",new Float32Array([e,t]))}}(s,c),this._reductionSteps.push(u),l++,1==s&&1==c){u.onAfterRenderObservable.add(function(e,t,i){var n=new Float32Array(4*e*t),a={min:0,max:0};return function(){o.getEngine()._readTexturePixels(i.inputTexture,e,t,-1,0,n),a.min=n[0],a.max=n[1],r.onAfterReductionPerformed.notifyObservers(a)}}(s,c,u))}}}},Object.defineProperty(e.prototype,\"refreshRate\",{get:function(){return this._sourceTexture?this._sourceTexture.refreshRate:-1},set:function(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"activated\",{get:function(){return this._activated},enumerable:!1,configurable:!0}),e.prototype.activate=function(){var e=this;!this._onAfterUnbindObserver&&this._sourceTexture&&(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add((function(){e._reductionSteps[0].activate(e._camera),e._postProcessManager.directRender(e._reductionSteps,e._reductionSteps[0].inputTexture,e._forceFullscreenViewport),e._camera.getScene().getEngine().unBindFramebuffer(e._reductionSteps[0].inputTexture,!1)})),this._activated=!0)},e.prototype.deactivate=function(){this._onAfterUnbindObserver&&this._sourceTexture&&(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)},e.prototype.dispose=function(e){if(void 0===e&&(e=!0),e&&this.onAfterReductionPerformed.clear(),this.deactivate(),this._reductionSteps){for(var t=0;tt&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)},Object.defineProperty(t.prototype,\"minDistance\",{get:function(){return this._minDistance},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"maxDistance\",{get:function(){return this._maxDistance},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e=0&&ethis._scene.activeCamera.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"debug\",{get:function(){return this._debug},set:function(e){this._debug=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"depthClamp\",{get:function(){return this._depthClamp},set:function(e){this._depthClamp=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"cascadeBlendPercentage\",{get:function(){return this._cascadeBlendPercentage},set:function(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"lambda\",{get:function(){return this._lambda},set:function(e){var t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)},enumerable:!1,configurable:!0}),t.prototype.getCascadeViewMatrix=function(e){return e>=0&&e=0&&e=0&&e=n&&(i=0,n=1),i==t._minDistance&&n==t._maxDistance||t.setMinMaxDistance(i,n)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"autoCalcDepthBoundsRefreshRate\",{get:function(){var e,t,i;return null!==(i=null===(t=null===(e=this._depthReducer)||void 0===e?void 0:e.depthRenderer)||void 0===t?void 0:t.getDepthMap().refreshRate)&&void 0!==i?i:-1},set:function(e){var t;(null===(t=this._depthReducer)||void 0===t?void 0:t.depthRenderer)&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!1,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._scene.activeCamera;if(e){for(var t=e.minZ,i=e.maxZ,n=i-t,r=this._minDistance,o=t+r*n,a=t+(this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(i-t),this._maxDistance):this._maxDistance)*n,s=a-o,c=a/o,l=0;lMath.PI;)r-=2*Math.PI;var a=r/Math.PI,s=o/Math.PI;a=.5*a+.5;var c=Math.round(a*i);c<0?c=0:c>=i&&(c=i-1);var l=Math.round(s*n);l<0?l=0:l>=n&&(l=n-1);var u=n-l-1;return{r:t[u*i*3+3*c+0],g:t[u*i*3+3*c+1],b:t[u*i*3+3*c+2]}},e.FACE_LEFT=[new a.e(-1,-1,-1),new a.e(1,-1,-1),new a.e(-1,1,-1),new a.e(1,1,-1)],e.FACE_RIGHT=[new a.e(1,-1,1),new a.e(-1,-1,1),new a.e(1,1,1),new a.e(-1,1,1)],e.FACE_FRONT=[new a.e(1,-1,-1),new a.e(1,-1,1),new a.e(1,1,-1),new a.e(1,1,1)],e.FACE_BACK=[new a.e(-1,-1,1),new a.e(-1,-1,-1),new a.e(-1,1,1),new a.e(-1,1,-1)],e.FACE_DOWN=[new a.e(1,1,-1),new a.e(1,1,1),new a.e(-1,1,-1),new a.e(-1,1,1)],e.FACE_UP=[new a.e(-1,-1,-1),new a.e(-1,-1,1),new a.e(1,-1,-1),new a.e(1,-1,1)],e}(),nc=function(){function e(){}return e.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},e.Rgbe2float=function(e,t,i,n,r,o){r>0?(r=this.Ldexp(1,r-136),e[o+0]=t*r,e[o+1]=i*r,e[o+2]=n*r):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e.readStringLine=function(e,t){for(var i=\"\",n=\"\",r=t;r32767)throw\"HDR Bad header format, unsupported size\";return{height:t,width:i,dataPosition:a+=n.length+1}},e.GetCubeMapTextureData=function(e,t){var i=new Uint8Array(e),n=this.RGBE_ReadHeader(i),r=this.RGBE_ReadPixels(i,n);return ic.ConvertPanoramaToCubemap(r,n.width,n.height,t)},e.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},e.RGBE_ReadPixels_RLE=function(e,t){for(var i,n,r,o,a,s=t.height,c=t.width,l=t.dataPosition,u=0,h=0,d=0,f=new ArrayBuffer(4*c),p=new Uint8Array(f),_=new ArrayBuffer(t.width*t.height*4*3),m=new Float32Array(_);s>0;){if(i=e[l++],n=e[l++],r=e[l++],o=e[l++],2!=i||2!=n||128&r||t.width<8||t.width>32767)return this.RGBE_ReadPixels_NOT_RLE(e,t);if((r<<8|o)!=c)throw\"HDR Bad header format, wrong scan line width\";for(u=0,d=0;d<4;d++)for(h=(d+1)*c;u128){if(0==(a=i-128)||a>h-u)throw\"HDR Bad Format, bad scanline data (run)\";for(;a-- >0;)p[u++]=n}else{if(0==(a=i)||a>h-u)throw\"HDR Bad Format, bad scanline data (non-run)\";if(p[u++]=n,--a>0)for(var g=0;g0;){for(a=0;a\\n#include\\n#include\\n#include\\nuniform float alphaG;\\nuniform samplerCube inputTexture;\\nuniform vec2 vFilteringInfo;\\nuniform float hdrScale;\\nvarying vec3 direction;\\nvoid main() {\\nvec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);\\ngl_FragColor=vec4(color*hdrScale,1.0);\\n}\";ai.a.ShadersStore.hdrFilteringPixelShader=sc;var cc=function(){function e(e,t){void 0===t&&(t={}),this._lodGenerationOffset=0,this._lodGenerationScale=.8,this.quality=g.a.TEXTURE_FILTERING_QUALITY_OFFLINE,this.hdrScale=1,this._engine=e,this.hdrScale=t.hdrScale||this.hdrScale,this.quality=t.hdrScale||this.quality}return e.prototype._createRenderTarget=function(e){var t=g.a.TEXTURETYPE_UNSIGNED_BYTE;this._engine.getCaps().textureHalfFloatRender?t=g.a.TEXTURETYPE_HALF_FLOAT:this._engine.getCaps().textureFloatRender&&(t=g.a.TEXTURETYPE_FLOAT);var i=this._engine.createRenderTargetCubeTexture(e,{format:g.a.TEXTUREFORMAT_RGBA,type:t,generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,samplingMode:g.a.TEXTURE_NEAREST_SAMPLINGMODE});return this._engine.updateTextureWrappingMode(i,g.a.TEXTURE_CLAMP_ADDRESSMODE,g.a.TEXTURE_CLAMP_ADDRESSMODE,g.a.TEXTURE_CLAMP_ADDRESSMODE),this._engine.updateTextureSamplingMode(g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,i,!0),i},e.prototype._prefilterInternal=function(e){var t=e.getSize().width,i=Math.round(L.a.Log2(t))+1,n=this._effectWrapper.effect,r=this._createRenderTarget(t);this._effectRenderer.setViewport();var o=e.getInternalTexture();o&&this._engine.updateTextureSamplingMode(g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,o,!0),this._effectRenderer.applyEffectWrapper(this._effectWrapper);var s=[[new a.e(0,0,-1),new a.e(0,-1,0),new a.e(1,0,0)],[new a.e(0,0,1),new a.e(0,-1,0),new a.e(-1,0,0)],[new a.e(1,0,0),new a.e(0,0,1),new a.e(0,1,0)],[new a.e(1,0,0),new a.e(0,0,-1),new a.e(0,-1,0)],[new a.e(1,0,0),new a.e(0,-1,0),new a.e(0,0,1)],[new a.e(-1,0,0),new a.e(0,-1,0),new a.e(0,0,-1)]];n.setFloat(\"hdrScale\",this.hdrScale),n.setFloat2(\"vFilteringInfo\",e.getSize().width,i),n.setTexture(\"inputTexture\",e);for(var c=0;c<6;c++){n.setVector3(\"up\",s[c][0]),n.setVector3(\"right\",s[c][1]),n.setVector3(\"front\",s[c][2]);for(var l=0;l=2&&this._prefilterOnLoad){var n=this._onLoad,r=new cc(i);this._onLoad=function(){r.prefilter(e,n)}}this._texture=i.createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,g.a.TEXTUREFORMAT_RGB,i.getCaps().textureFloat?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,(function(n){e.lodGenerationOffset=0,e.lodGenerationScale=.8;var r=nc.GetCubeMapTextureData(n,e._size);if(e._generateHarmonics){var o=$n.ConvertCubeMapToSphericalPolynomial(r);e.sphericalPolynomial=o}for(var a=[],s=null,c=0;c<6;c++){if(!i.getCaps().textureFloat){var l=new ArrayBuffer(e._size*e._size*3);s=new Uint8Array(l)}var u=r[t._facesMapping[c]];if(e.gammaSpace||s)for(var h=0;h255){var m=255/_;d*=m,f*=m,p*=m}s[3*h+0]=d,s[3*h+1]=f,s[3*h+2]=p}s?a.push(s):a.push(u)}return a}),null,this._onLoad,this._onError)},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e},t.prototype.delayLoad=function(){this.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=g.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var t,i=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&(null===(t=this.getScene())||void 0===t||t.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(i)})))},t.Parse=function(e,i,n){var r=null;return e.name&&!e.isRenderTarget&&((r=new t(n+e.name,i,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name=e.name,r.hasAlpha=e.hasAlpha,r.level=e.level,r.coordinatesMode=e.coordinatesMode,r.isBlocking=e.isBlocking),r&&(e.boundingBoxPosition&&(r.boundingBoxPosition=a.e.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(r.boundingBoxSize=a.e.FromArray(e.boundingBoxSize)),e.rotationY&&(r.rotationY=e.rotationY)),r},t.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this.gammaSpace,e.generateHarmonics=this._generateHarmonics,e.customType=\"BABYLON.HDRCubeTexture\",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e.rotationY=this._rotationY,e},t._facesMapping=[\"right\",\"left\",\"up\",\"down\",\"front\",\"back\"],t}(Zn.a);c.a.RegisteredTypes[\"BABYLON.HDRCubeTexture\"]=lc;var uc=function(){function e(e,t,i){void 0===t&&(t=0),void 0===i&&(i=null),this.name=e,this.animations=new Array,this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new o.c,this._onDataLayoutChanged=new o.c,this._animationPropertiesOverride=null,this._scene=i||x.a.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}return Object.defineProperty(e.prototype,\"influence\",{get:function(){return this._influence},set:function(e){if(this._influence!==e){var t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers()&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"animationPropertiesOverride\",{get:function(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"uniqueId\",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"hasPositions\",{get:function(){return!!this._positions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"hasNormals\",{get:function(){return!!this._normals},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"hasTangents\",{get:function(){return!!this._tangents},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"hasUVs\",{get:function(){return!!this._uvs},enumerable:!1,configurable:!0}),e.prototype.setPositions=function(e){var t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getPositions=function(){return this._positions},e.prototype.setNormals=function(e){var t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getNormals=function(){return this._normals},e.prototype.setTangents=function(e){var t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getTangents=function(){return this._tangents},e.prototype.setUVs=function(e){var t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getUVs=function(){return this._uvs},e.prototype.clone=function(){var t=this,i=w.a.Clone((function(){return new e(t.name,t.influence,t._scene)}),this);return i._positions=this._positions,i._normals=this._normals,i._tangents=this._tangents,i._uvs=this._uvs,i},e.prototype.serialize=function(){var e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),null!=this.id&&(e.id=this.id),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),w.a.AppendSerializedAnimations(this,e),e},e.prototype.getClassName=function(){return\"MorphTarget\"},e.Parse=function(t){var i=new e(t.name,t.influence);if(i.setPositions(t.positions),null!=t.id&&(i.id=t.id),t.normals&&i.setNormals(t.normals),t.tangents&&i.setTangents(t.tangents),t.uvs&&i.setUVs(t.uvs),t.animations)for(var n=0;n=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0))},e.prototype.clone=function(){for(var t=new e(this._scene),i=0,n=this._targets;i-1&&(this._impostors.splice(t,1).length&&this.getPhysicsPlugin().removePhysicsBody(e))},e.prototype.addJoint=function(e,t,i){var n={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(n),this._physicsPlugin.generateJoint(n)},e.prototype.removeJoint=function(e,t,i){var n=this._joints.filter((function(n){return n.connectedImpostor===t&&n.joint===i&&n.mainImpostor===e}));n.length&&this._physicsPlugin.removeJoint(n[0])},e.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},e.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},e.prototype.getImpostors=function(){return this._impostors},e.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;t0&&(this._physicsBodysToRemoveAfterStep.forEach((function(t){e.world.remove(t)})),this._physicsBodysToRemoveAfterStep=[])},e.prototype.applyImpulse=function(e,t,i){var n=new this.BJSCANNON.Vec3(i.x,i.y,i.z),r=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(r,n)},e.prototype.applyForce=function(e,t,i){var n=new this.BJSCANNON.Vec3(i.x,i.y,i.z),r=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(r,n)},e.prototype.generatePhysicsBody=function(e){if(this._removeMarkedPhysicsBodiesFromWorld(),e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var t=this._createShape(e),i=e.physicsBody;i&&this.removePhysicsBody(e);var n=this._addMaterial(\"mat-\"+e.uniqueId,e.getParam(\"friction\"),e.getParam(\"restitution\")),r={mass:e.getParam(\"mass\"),material:n},o=e.getParam(\"nativeOptions\");for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);e.physicsBody=new this.BJSCANNON.Body(r),e.physicsBody.addEventListener(\"collide\",e.onCollide),this.world.addEventListener(\"preStep\",e.beforeStep),this.world.addEventListener(\"postStep\",e.afterStep),e.physicsBody.addShape(t),this.world.add(e.physicsBody),i&&[\"force\",\"torque\",\"velocity\",\"angularVelocity\"].forEach((function(t){var n=i[t];e.physicsBody[t].set(n.x,n.y,n.z)})),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},e.prototype._processChildMeshes=function(e){var t=this,i=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],n=e.object.rotationQuaternion;if(i.length){var r=function(i){if(n&&i.rotationQuaternion){var o=i.getPhysicsImpostor();if(o)if(o.parent!==e){var a=i.getAbsolutePosition().subtract(i.parent.getAbsolutePosition()),s=i.rotationQuaternion;o.physicsBody&&(t.removePhysicsBody(o),o.physicsBody=null),o.parent=e,o.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(o),new t.BJSCANNON.Vec3(a.x,a.y,a.z),new t.BJSCANNON.Quaternion(s.x,s.y,s.z,s.w)),e.physicsBody.mass+=o.getParam(\"mass\")}n.multiplyInPlace(i.rotationQuaternion),i.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(r)}};i.filter((function(e){return!!e.physicsImpostor})).forEach(r)}},e.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener(\"collide\",e.onCollide),this.world.removeEventListener(\"preStep\",e.beforeStep),this.world.removeEventListener(\"postStep\",e.afterStep),-1===this._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody)&&this._physicsBodysToRemoveAfterStep.push(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var n,r=e.joint.jointData,o={pivotA:r.mainPivot?(new this.BJSCANNON.Vec3).set(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z):null,pivotB:r.connectedPivot?(new this.BJSCANNON.Vec3).set(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z):null,axisA:r.mainAxis?(new this.BJSCANNON.Vec3).set(r.mainAxis.x,r.mainAxis.y,r.mainAxis.z):null,axisB:r.connectedAxis?(new this.BJSCANNON.Vec3).set(r.connectedAxis.x,r.connectedAxis.y,r.connectedAxis.z):null,maxForce:r.nativeParams.maxForce,collideConnected:!!r.collision};switch(e.joint.type){case fc.e.HingeJoint:case fc.e.Hinge2Joint:n=new this.BJSCANNON.HingeConstraint(t,i,o);break;case fc.e.DistanceJoint:n=new this.BJSCANNON.DistanceConstraint(t,i,r.maxDistance||2);break;case fc.e.SpringJoint:var a=r;n=new this.BJSCANNON.Spring(t,i,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case fc.e.LockJoint:n=new this.BJSCANNON.LockConstraint(t,i,o);break;case fc.e.PointToPointJoint:case fc.e.BallAndSocketJoint:default:n=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotB,o.maxForce)}n.collideConnected=!!r.collision,e.joint.physicsJoint=n,e.joint.type!==fc.e.SpringJoint?this.world.addConstraint(n):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){n.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==fc.e.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,i){var n,r;for(n=0;n1e3*i));s++);this.time+=n;for(var c=this.time%i/i,l=e,u=this.bodies,h=0;h!==u.length;h++){var d=u[h];d.type!==t.Body.STATIC&&d.sleepState!==t.Body.SLEEPING?(d.position.vsub(d.previousPosition,l),l.scale(c,l),d.position.vadd(l,d.interpolatedPosition)):(d.interpolatedPosition.set(d.position.x,d.position.y,d.position.z),d.interpolatedQuaternion.set(d.quaternion.x,d.quaternion.y,d.quaternion.z,d.quaternion.w))}}}},e.prototype.raycast=function(e,t){return this._cannonRaycastResult.reset(),this.world.raycastClosest(e,t,{},this._cannonRaycastResult),this._raycastResult.reset(e,t),this._cannonRaycastResult.hasHit&&(this._raycastResult.setHitData({x:this._cannonRaycastResult.hitNormalWorld.x,y:this._cannonRaycastResult.hitNormalWorld.y,z:this._cannonRaycastResult.hitNormalWorld.z},{x:this._cannonRaycastResult.hitPointWorld.x,y:this._cannonRaycastResult.hitPointWorld.y,z:this._cannonRaycastResult.hitPointWorld.z}),this._raycastResult.setHitDistance(this._cannonRaycastResult.distance)),this._raycastResult},e}();pc.DefaultPluginFactory=function(){return new mc};var gc=function(){function e(e,t,i){void 0===e&&(e=!0),void 0===i&&(i=OIMO),this._useDeltaForWorldStep=e,this.name=\"OimoJSPlugin\",this._fixedTimeStep=1/60,this._tmpImpostorsArray=[],this._tmpPositionVector=a.e.Zero(),this.BJSOIMO=i,this.world=new this.BJSOIMO.World({iterations:t}),this.world.clear(),this._raycastResult=new _c}return e.prototype.setGravity=function(e){this.world.gravity.set(e.x,e.y,e.z)},e.prototype.setTimeStep=function(e){this.world.timeStep=e},e.prototype.getTimeStep=function(){return this.world.timeStep},e.prototype.executeStep=function(e,t){var i=this;t.forEach((function(e){e.beforeStep()})),this.world.timeStep=this._useDeltaForWorldStep?e:this._fixedTimeStep,this.world.step(),t.forEach((function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e}));for(var n=this.world.contacts;null!==n;)if(!n.touching||n.body1.sleeping||n.body2.sleeping){var r=this._tmpImpostorsArray[+n.body1.name],o=this._tmpImpostorsArray[+n.body2.name];r&&o?(r.onCollide({body:o.physicsBody,point:null}),o.onCollide({body:r.physicsBody,point:null}),n=n.next):n=n.next}else n=n.next},e.prototype.applyImpulse=function(e,t,i){var n=e.physicsBody.mass;e.physicsBody.applyImpulse(i.scale(this.world.invScale),t.scale(this.world.invScale*n))},e.prototype.applyForce=function(e,t,i){m.a.Warn(\"Oimo doesn't support applying force. Using impule instead.\"),this.applyImpulse(e,t,i)},e.prototype.generatePhysicsBody=function(e){var t=this;if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var i={name:e.uniqueId,config:[e.getParam(\"mass\")||.001,e.getParam(\"friction\"),e.getParam(\"restitution\")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:0!==e.getParam(\"mass\"),density:e.getParam(\"mass\"),friction:e.getParam(\"friction\"),restitution:e.getParam(\"restitution\"),world:this.world},n=[e];(s=e.object).getChildMeshes&&s.getChildMeshes().forEach((function(e){e.physicsImpostor&&n.push(e.physicsImpostor)}));var r=function(e){return Math.max(e,pc.Epsilon)},o=new a.b;n.forEach((function(n){if(n.object.rotationQuaternion){var a=n.object.rotationQuaternion;o.copyFrom(a),n.object.rotationQuaternion.set(0,0,0,1),n.object.computeWorldMatrix(!0);var s=o.toEulerAngles(),c=n.getObjectExtendSize();if(n===e){var l=e.getObjectCenter();e.object.getAbsolutePivotPoint().subtractToRef(l,t._tmpPositionVector),t._tmpPositionVector.divideInPlace(e.object.scaling),i.pos.push(l.x),i.pos.push(l.y),i.pos.push(l.z),i.posShape.push(0,0,0),i.rotShape.push(0,0,0)}else{var u=n.object.position.clone();i.posShape.push(u.x),i.posShape.push(u.y),i.posShape.push(u.z),i.rotShape.push(57.29577951308232*s.x,57.29577951308232*s.y,57.29577951308232*s.z)}switch(n.object.rotationQuaternion.copyFrom(o),n.type){case dc.a.ParticleImpostor:m.a.Warn(\"No Particle support in OIMO.js. using SphereImpostor instead\");case dc.a.SphereImpostor:var h=c.x,d=c.y,f=c.z,p=Math.max(r(h),r(d),r(f))/2;i.type.push(\"sphere\"),i.size.push(p),i.size.push(p),i.size.push(p);break;case dc.a.CylinderImpostor:var _=r(c.x)/2,g=r(c.y);i.type.push(\"cylinder\"),i.size.push(_),i.size.push(g),i.size.push(g);break;case dc.a.PlaneImpostor:case dc.a.BoxImpostor:default:_=r(c.x),g=r(c.y);var v=r(c.z);i.type.push(\"box\"),i.size.push(_),i.size.push(g),i.size.push(v)}n.object.rotationQuaternion=a}})),e.physicsBody=this.world.add(i),e.physicsBody.resetQuaternion(o),e.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var s;e.setDeltaPosition(this._tmpPositionVector)}},e.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var n,r=e.joint.jointData,o=r.nativeParams||{},a={body1:t,body2:i,axe1:o.axe1||(r.mainAxis?r.mainAxis.asArray():null),axe2:o.axe2||(r.connectedAxis?r.connectedAxis.asArray():null),pos1:o.pos1||(r.mainPivot?r.mainPivot.asArray():null),pos2:o.pos2||(r.connectedPivot?r.connectedPivot.asArray():null),min:o.min,max:o.max,collision:o.collision||r.collision,spring:o.spring,world:this.world};switch(e.joint.type){case fc.e.BallAndSocketJoint:n=\"jointBall\";break;case fc.e.SpringJoint:m.a.Warn(\"OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead\");var s=r;a.min=s.length||a.min,a.max=Math.max(a.min,a.max);case fc.e.DistanceJoint:n=\"jointDistance\",a.max=r.maxDistance;break;case fc.e.PrismaticJoint:n=\"jointPrisme\";break;case fc.e.SliderJoint:n=\"jointSlide\";break;case fc.e.WheelJoint:n=\"jointWheel\";break;case fc.e.HingeJoint:default:n=\"jointHinge\"}a.type=n,e.joint.physicsJoint=this.world.add(a)}},e.prototype.removeJoint=function(e){try{this.world.removeJoint(e.joint.physicsJoint)}catch(e){m.a.Warn(e)}},e.prototype.isSupported=function(){return void 0!==this.BJSOIMO},e.prototype.setTransformationFromPhysicsBody=function(e){if(!e.physicsBody.sleeping){if(e.physicsBody.shapes.next){for(var t=e.physicsBody.shapes;t.next;)t=t.next;e.object.position.set(t.position.x,t.position.y,t.position.z)}else{var i=e.physicsBody.getPosition();e.object.position.set(i.x,i.y,i.z)}if(e.object.rotationQuaternion){var n=e.physicsBody.getQuaternion();e.object.rotationQuaternion.set(n.x,n.y,n.z,n.w)}}},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var n=e.physicsBody;e.physicsBody.shapes.next||(n.position.set(t.x,t.y,t.z),n.orientation.set(i.x,i.y,i.z,i.w),n.syncShapes(),n.awake())},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.set(t.x,t.y,t.z)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.set(t.x,t.y,t.z)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new a.e(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new a.e(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?2:1)},e.prototype.getBodyMass=function(e){return e.physicsBody.shapes.density},e.prototype.getBodyFriction=function(e){return e.physicsBody.shapes.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.shapes.friction=t},e.prototype.getBodyRestitution=function(e){return e.physicsBody.shapes.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.shapes.restitution=t},e.prototype.sleepBody=function(e){e.physicsBody.sleep()},e.prototype.wakeUpBody=function(e){e.physicsBody.awake()},e.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.limitMotor.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotor.lowerLimit=i)},e.prototype.setMotor=function(e,t,i,n){void 0!==i?m.a.Warn(\"OimoJS plugin currently has unexpected behavior when using setMotor with force parameter\"):i=1e6,t*=-1;var r=n?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setMotor(t,i)},e.prototype.setLimit=function(e,t,i,n){var r=n?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setLimit(t,void 0===i?-t:i)},e.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.orientation.x,e.rotationQuaternion.y=i.orientation.y,e.rotationQuaternion.z=i.orientation.z,e.rotationQuaternion.w=i.orientation.s)},e.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},e.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes;t.x=2*i.halfWidth,t.y=2*i.halfHeight,t.z=2*i.halfDepth},e.prototype.dispose=function(){this.world.clear()},e.prototype.raycast=function(e,t){return m.a.Warn(\"raycast is not currently supported by the Oimo physics plugin\"),this._raycastResult.reset(e,t),this._raycastResult},e}(),vc=i(97),bc=function(){function e(e,t,i){var n=this;void 0===e&&(e=!0),void 0===t&&(t=Ammo),void 0===i&&(i=null),this._useDeltaForWorldStep=e,this.bjsAMMO={},this.name=\"AmmoJSPlugin\",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new a.b,this._tmpContactCallbackResult=!1,this._tmpContactPoint=new a.e,this._tmpMatrix=new a.a,\"function\"==typeof t?t(this.bjsAMMO):this.bjsAMMO=t,this.isSupported()?(this._collisionConfiguration=new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,this._dispatcher=new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),this._overlappingPairCache=i||new this.bjsAMMO.btDbvtBroadphase,this._solver=new this.bjsAMMO.btSequentialImpulseConstraintSolver,this._softBodySolver=new this.bjsAMMO.btDefaultSoftBodySolver,this.world=new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher,this._overlappingPairCache,this._solver,this._collisionConfiguration,this._softBodySolver),this._tmpAmmoConcreteContactResultCallback=new this.bjsAMMO.ConcreteContactResultCallback,this._tmpAmmoConcreteContactResultCallback.addSingleResult=function(e,t,i,r){var o=(e=n.bjsAMMO.wrapPointer(e,Ammo.btManifoldPoint)).getPositionWorldOnA();n._tmpContactPoint.x=o.x(),n._tmpContactPoint.y=o.y(),n._tmpContactPoint.z=o.z(),n._tmpContactCallbackResult=!0},this._raycastResult=new _c,this._tmpAmmoTransform=new this.bjsAMMO.btTransform,this._tmpAmmoTransform.setIdentity(),this._tmpAmmoQuaternion=new this.bjsAMMO.btQuaternion(0,0,0,1),this._tmpAmmoVectorA=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorB=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorC=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorD=new this.bjsAMMO.btVector3(0,0,0)):m.a.Error(\"AmmoJS is not available. Please make sure you included the js file.\")}return e.prototype.setGravity=function(e){this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),this.world.setGravity(this._tmpAmmoVectorA),this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)},e.prototype.setTimeStep=function(e){this._timeStep=e},e.prototype.setFixedTimeStep=function(e){this._fixedTimeStep=e},e.prototype.setMaxSteps=function(e){this._maxSteps=e},e.prototype.getTimeStep=function(){return this._timeStep},e.prototype._isImpostorInContact=function(e){return this._tmpContactCallbackResult=!1,this.world.contactTest(e.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._isImpostorPairInContact=function(e,t){return this._tmpContactCallbackResult=!1,this.world.contactPairTest(e.physicsBody,t.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._stepSimulation=function(e,t,i){if(void 0===e&&(e=1/60),void 0===t&&(t=10),void 0===i&&(i=1/60),0==t)this.world.stepSimulation(e,0);else for(;t>0&&e>0;)e-i0&&this._isImpostorInContact(s))for(var c=0,l=s._onPhysicsCollideCallbacks;c3?3:s;var c=(new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,i-1,s);return c.get_m_cfg().set_collisions(17),c},e.prototype._createCustom=function(e){var t=null;return this.onCreateCustomShape&&(t=this.onCreateCustomShape(e)),null==t&&(t=new this.bjsAMMO.btCompoundShape),t},e.prototype._addHullVerts=function(e,t,i){var n=this,r=0;if(i&&i.getIndices&&i.getWorldMatrix&&i.getChildMeshes){var o=i.getIndices();o||(o=[]);var s=i.getVerticesData(Qi.b.PositionKind);s||(s=[]),i.computeWorldMatrix(!1);for(var c=o.length/3,l=0;l0){if(e.type!=dc.a.NoImpostor){var l=this._createShape(e,!0);l&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),n.addChildShape(this._tmpAmmoTransform,l))}return n}this.bjsAMMO.destroy(n),n=null}switch(e.type){case dc.a.SphereImpostor:if(L.a.WithinEpsilon(o.x,o.y,1e-4)&&L.a.WithinEpsilon(o.x,o.z,1e-4))n=new this.bjsAMMO.btSphereShape(o.x/2);else{var u=[new this.bjsAMMO.btVector3(0,0,0)];(n=new this.bjsAMMO.btMultiSphereShape(u,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x/2,o.y/2,o.z/2))}break;case dc.a.CapsuleImpostor:n=new this.bjsAMMO.btCapsuleShape(o.x/2,o.y/2);break;case dc.a.CylinderImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),n=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case dc.a.PlaneImpostor:case dc.a.BoxImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),n=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case dc.a.MeshImpostor:if(0==e.getParam(\"mass\")){var h=new this.bjsAMMO.btTriangleMesh;e._pluginData.toDispose.push(h);var d=this._addMeshVerts(h,r,r);n=0==d?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(h);break}case dc.a.ConvexHullImpostor:var f=new this.bjsAMMO.btConvexHullShape;0==(d=this._addHullVerts(f,r,r))?(e._pluginData.toDispose.push(f),n=new this.bjsAMMO.btCompoundShape):n=f;break;case dc.a.NoImpostor:n=new this.bjsAMMO.btSphereShape(o.x/2);break;case dc.a.CustomImpostor:n=this._createCustom(e);break;case dc.a.SoftbodyImpostor:n=this._createSoftbody(e);break;case dc.a.ClothImpostor:n=this._createCloth(e);break;case dc.a.RopeImpostor:n=this._createRope(e);break;default:m.a.Warn(\"The impostor type is not currently supported by the ammo plugin.\")}return n},e.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.object.position.set(this._tmpAmmoTransform.getOrigin().x(),this._tmpAmmoTransform.getOrigin().y(),this._tmpAmmoTransform.getOrigin().z()),e.object.rotationQuaternion?e.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()):e.object.rotation&&(this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()),this._tmpQuaternion.toEulerAnglesToRef(e.object.rotation))},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var n=e.physicsBody.getWorldTransform();if(Math.abs(n.getOrigin().x()-t.x)>Nt.a||Math.abs(n.getOrigin().y()-t.y)>Nt.a||Math.abs(n.getOrigin().z()-t.z)>Nt.a||Math.abs(n.getRotation().x()-i.x)>Nt.a||Math.abs(n.getRotation().y()-i.y)>Nt.a||Math.abs(n.getRotation().z()-i.z)>Nt.a||Math.abs(n.getRotation().w()-i.w)>Nt.a)if(this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),n.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(i.x,i.y,i.z,i.w),n.setRotation(this._tmpAmmoQuaternion),e.physicsBody.setWorldTransform(n),0==e.mass){var r=e.physicsBody.getMotionState();r&&r.setWorldTransform(n)}else e.physicsBody.activate()},e.prototype.isSupported=function(){return void 0!==this.bjsAMMO},e.prototype.setLinearVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.linearVelocity(this._tmpAmmoVectorA):e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)},e.prototype.setAngularVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.angularVelocity(this._tmpAmmoVectorA):e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)},e.prototype.getLinearVelocity=function(e){if(e.soft)var t=e.physicsBody.linearVelocity();else t=e.physicsBody.getLinearVelocity();if(!t)return null;var i=new a.e(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),i},e.prototype.getAngularVelocity=function(e){if(e.soft)var t=e.physicsBody.angularVelocity();else t=e.physicsBody.getAngularVelocity();if(!t)return null;var i=new a.e(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),i},e.prototype.setBodyMass=function(e,t){e.soft?e.physicsBody.setTotalMass(t,!1):e.physicsBody.setMassProps(t),e._pluginData.mass=t},e.prototype.getBodyMass=function(e){return e._pluginData.mass||0},e.prototype.getBodyFriction=function(e){return e._pluginData.friction||0},e.prototype.setBodyFriction=function(e,t){e.soft?e.physicsBody.get_m_cfg().set_kDF(t):e.physicsBody.setFriction(t),e._pluginData.friction=t},e.prototype.getBodyRestitution=function(e){return e._pluginData.restitution||0},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.setRestitution(t),e._pluginData.restitution=t},e.prototype.getBodyPressure=function(e){return e.soft?e._pluginData.pressure||0:(m.a.Warn(\"Pressure is not a property of a rigid body\"),0)},e.prototype.setBodyPressure=function(e,t){e.soft?e.type===dc.a.SoftbodyImpostor?(e.physicsBody.get_m_cfg().set_kPR(t),e._pluginData.pressure=t):(e.physicsBody.get_m_cfg().set_kPR(0),e._pluginData.pressure=0):m.a.Warn(\"Pressure can only be applied to a softbody\")},e.prototype.getBodyStiffness=function(e){return e.soft?e._pluginData.stiffness||0:(m.a.Warn(\"Stiffness is not a property of a rigid body\"),0)},e.prototype.setBodyStiffness=function(e,t){e.soft?(t=(t=t<0?0:t)>1?1:t,e.physicsBody.get_m_materials().at(0).set_m_kLST(t),e._pluginData.stiffness=t):m.a.Warn(\"Stiffness cannot be applied to a rigid body\")},e.prototype.getBodyVelocityIterations=function(e){return e.soft?e._pluginData.velocityIterations||0:(m.a.Warn(\"Velocity iterations is not a property of a rigid body\"),0)},e.prototype.setBodyVelocityIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_viterations(t),e._pluginData.velocityIterations=t):m.a.Warn(\"Velocity iterations cannot be applied to a rigid body\")},e.prototype.getBodyPositionIterations=function(e){return e.soft?e._pluginData.positionIterations||0:(m.a.Warn(\"Position iterations is not a property of a rigid body\"),0)},e.prototype.setBodyPositionIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_piterations(t),e._pluginData.positionIterations=t):m.a.Warn(\"Position iterations cannot be applied to a rigid body\")},e.prototype.appendAnchor=function(e,t,i,n,r,o){void 0===r&&(r=1),void 0===o&&(o=!1);var a=e.segments,s=Math.round((a-1)*i)+a*(a-1-Math.round((a-1)*n));e.physicsBody.appendAnchor(s,t.physicsBody,o,r)},e.prototype.appendHook=function(e,t,i,n,r){void 0===n&&(n=1),void 0===r&&(r=!1);var o=Math.round(e.segments*i);e.physicsBody.appendAnchor(o,t.physicsBody,r,n)},e.prototype.sleepBody=function(e){m.a.Warn(\"sleepBody is not currently supported by the Ammo physics plugin\")},e.prototype.wakeUpBody=function(e){e.physicsBody.activate()},e.prototype.updateDistanceJoint=function(e,t,i){m.a.Warn(\"updateDistanceJoint is not currently supported by the Ammo physics plugin\")},e.prototype.setMotor=function(e,t,i,n){e.physicsJoint.enableAngularMotor(!0,t,i)},e.prototype.setLimit=function(e,t,i){m.a.Warn(\"setLimit is not currently supported by the Ammo physics plugin\")},e.prototype.syncMeshWithImpostor=function(e,t){t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.position.x=this._tmpAmmoTransform.getOrigin().x(),e.position.y=this._tmpAmmoTransform.getOrigin().y(),e.position.z=this._tmpAmmoTransform.getOrigin().z(),e.rotationQuaternion&&(e.rotationQuaternion.x=this._tmpAmmoTransform.getRotation().x(),e.rotationQuaternion.y=this._tmpAmmoTransform.getRotation().y(),e.rotationQuaternion.z=this._tmpAmmoTransform.getRotation().z(),e.rotationQuaternion.w=this._tmpAmmoTransform.getRotation().w())},e.prototype.getRadius=function(e){return e.getObjectExtendSize().x/2},e.prototype.getBoxSizeToRef=function(e,t){var i=e.getObjectExtendSize();t.x=i.x,t.y=i.y,t.z=i.z},e.prototype.dispose=function(){this.bjsAMMO.destroy(this.world),this.bjsAMMO.destroy(this._solver),this.bjsAMMO.destroy(this._overlappingPairCache),this.bjsAMMO.destroy(this._dispatcher),this.bjsAMMO.destroy(this._collisionConfiguration),this.bjsAMMO.destroy(this._tmpAmmoVectorA),this.bjsAMMO.destroy(this._tmpAmmoVectorB),this.bjsAMMO.destroy(this._tmpAmmoVectorC),this.bjsAMMO.destroy(this._tmpAmmoTransform),this.bjsAMMO.destroy(this._tmpAmmoQuaternion),this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback),this.world=null},e.prototype.raycast=function(e,t){this._tmpAmmoVectorRCA=new this.bjsAMMO.btVector3(e.x,e.y,e.z),this._tmpAmmoVectorRCB=new this.bjsAMMO.btVector3(t.x,t.y,t.z);var i=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);return this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,i),this._raycastResult.reset(e,t),i.hasHit()&&(this._raycastResult.setHitData({x:i.get_m_hitNormalWorld().x(),y:i.get_m_hitNormalWorld().y(),z:i.get_m_hitNormalWorld().z()},{x:i.get_m_hitPointWorld().x(),y:i.get_m_hitPointWorld().y(),z:i.get_m_hitPointWorld().z()}),this._raycastResult.calculateHitDistance()),this.bjsAMMO.destroy(i),this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),this.bjsAMMO.destroy(this._tmpAmmoVectorRCB),this._raycastResult},e.DISABLE_COLLISION_FLAG=4,e.KINEMATIC_FLAG=2,e.DISABLE_DEACTIVATION_FLAG=4,e}();n.a.prototype.removeReflectionProbe=function(e){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(e);return-1!==t&&this.reflectionProbes.splice(t,1),t},n.a.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var yc=function(){function e(e,t,i,n,r){var o=this;void 0===n&&(n=!0),void 0===r&&(r=!1),this.name=e,this._viewMatrix=a.a.Identity(),this._target=a.e.Zero(),this._add=a.e.Zero(),this._invertYAxis=!1,this.position=a.e.Zero(),this._scene=i,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this);var s=g.a.TEXTURETYPE_UNSIGNED_BYTE;if(r){var c=this._scene.getEngine().getCaps();c.textureHalfFloatRender?s=g.a.TEXTURETYPE_HALF_FLOAT:c.textureFloatRender&&(s=g.a.TEXTURETYPE_FLOAT)}this._renderTargetTexture=new Ni(e,t,i,n,!0,s,!0),this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(e){case 0:o._add.copyFromFloats(1,0,0);break;case 1:o._add.copyFromFloats(-1,0,0);break;case 2:o._add.copyFromFloats(0,o._invertYAxis?1:-1,0);break;case 3:o._add.copyFromFloats(0,o._invertYAxis?-1:1,0);break;case 4:o._add.copyFromFloats(0,0,1);break;case 5:o._add.copyFromFloats(0,0,-1)}o._attachedMesh&&o.position.copyFrom(o._attachedMesh.getAbsolutePosition()),o.position.addToRef(o._add,o._target),a.a.LookAtLHToRef(o.position,o._target,a.e.Up(),o._viewMatrix),i.activeCamera&&(o._projectionMatrix=a.a.PerspectiveFovLH(Math.PI/2,1,i.activeCamera.minZ,i.activeCamera.maxZ),i.setTransformMatrix(o._viewMatrix,o._projectionMatrix)),i._forcedViewPosition=o.position})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){i._forcedViewPosition=null,i.updateTransformMatrix(!0)}))}return Object.defineProperty(e.prototype,\"samples\",{get:function(){return this._renderTargetTexture.samples},set:function(e){this._renderTargetTexture.samples=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"refreshRate\",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,\"cubeTexture\",{get:function(){return this._renderTargetTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"renderList\",{get:function(){return this._renderTargetTexture.renderList},enumerable:!1,configurable:!0}),e.prototype.attachToMesh=function(e){this._attachedMesh=e},e.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderTargetTexture.setRenderingAutoClearDepthStencil(e,t)},e.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);-1!==e&&this._scene.reflectionProbes.splice(e,1),this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null)},e.prototype.toString=function(e){var t=\"Name: \"+this.name;return e&&(t+=\", position: \"+this.position.toString(),this._attachedMesh&&(t+=\", attached mesh: \"+this._attachedMesh.name)),t},e.prototype.getClassName=function(){return\"ReflectionProbe\"},e.prototype.serialize=function(){var e=w.a.Serialize(this,this._renderTargetTexture.serialize());return e.isReflectionProbe=!0,e},e.Parse=function(t,i,n){var r=null;if(i.reflectionProbes)for(var o=0;o0){var n=t._waitingData.lods.ids,r=i.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=n.length){var a=o.length>n.length?o[o.length-1]:0;i.setEnabled(!1);for(var s=0;s0&&i.addLODLevel(a,null),!0===r&&i.setEnabled(!0)}else Ce.b.Warn(\"Invalid level of detail distances for \"+t.name)}}t._waitingData.lods=null}},Rc=function(e,t,i,r,o){void 0===o&&(o=!1);var a=new Ee(e),s=\"importScene has failed JSON parse\";try{var l=JSON.parse(t);s=\"\";var u,h,d=pr.loggingLevel===pr.DETAILED_LOGGING;if(void 0!==l.environmentTexture&&null!==l.environmentTexture){var f=void 0===l.isPBR||l.isPBR;if(l.environmentTextureType&&\"BABYLON.HDRCubeTexture\"===l.environmentTextureType){var p=l.environmentTextureSize?l.environmentTextureSize:128,_=new lc((l.environmentTexture.match(/https?:\\/\\//g)?\"\":i)+l.environmentTexture,e,p,!0,!f);l.environmentTextureRotationY&&(_.rotationY=l.environmentTextureRotationY),e.environmentTexture=_}else if(io.a.EndsWith(l.environmentTexture,\".env\")){var g=new no((l.environmentTexture.match(/https?:\\/\\//g)?\"\":i)+l.environmentTexture,e);l.environmentTextureRotationY&&(g.rotationY=l.environmentTextureRotationY),e.environmentTexture=g}else{var v=no.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\\/\\//g)?\"\":i)+l.environmentTexture,e);l.environmentTextureRotationY&&(v.rotationY=l.environmentTextureRotationY),e.environmentTexture=v}if(!0===l.createDefaultSkybox){var b=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,y=l.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,f,b,y)}a.environmentTexture=e.environmentTexture}if(void 0!==l.environmentIntensity&&null!==l.environmentIntensity&&(e.environmentIntensity=l.environmentIntensity),void 0!==l.lights&&null!==l.lights)for(u=0,h=l.lights.length;u0){for(var ae=0;ae0){for(var ce=0;ce-1&&void 0!==u.skeletons&&null!==u.skeletons)if(!1===g.indexOf(b.skeletonId)>-1)for(var M=0,I=u.skeletons.length;M1,this.wrapU=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.wrapV=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.wrapR=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.anisotropicFilteringLevel=1;var r=function(r){if(\"string\"==typeof r){for(var o,a=null,s=null,c=r.split(\"\\n\"),l=0,u=0,h=0,d=0,f=0,p=0;p0&&(p+1)%4==0)a[p]=255;else{var T=s[p];a[p]=T/f*255}e.is3D?(e.updateSize(l,l,l),n.updateRawTexture3D(e,a,g.a.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(l*l,l),n.updateRawTexture(e,a,g.a.TEXTUREFORMAT_RGBA,!1)),e.isReady=!0,i._triggerOnLoad()}},o=this.getScene();return o?o._loadFile(this.url,r):n._loadFile(this.url,r),this._texture},t.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(\".3dl\")==this.url.length-4&&this.load3dlTexture()},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine());return e.level=this.level,e},t.prototype.delayLoad=function(){this.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=g.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},t.Parse=function(e,i){var n=null;return e.name&&!e.isRenderTarget&&((n=new t(e.name,i)).name=e.name,n.level=e.level),n},t.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType=\"BABYLON.ColorGradingTexture\",e},t._noneEmptyLineRegex=/\\S+/,t}(Zn.a);c.a.RegisteredTypes[\"BABYLON.ColorGradingTexture\"]=wc;var Fc=function(e){function t(t,i,n,r,o,a,s){void 0===r&&(r=!1),void 0===o&&(o=!0),void 0===a&&(a=null),void 0===s&&(s=null);var c=e.call(this,i)||this;if(c._onLoad=null,c._onError=null,!t)throw new Error(\"Image url is not set\");return c._coordinatesMode=Ke.a.CUBIC_MODE,c.name=t,c.url=t,c._size=n,c._noMipmap=r,c.gammaSpace=o,c._onLoad=a,c._onError=s,c.hasAlpha=!1,c.isCube=!0,c._texture=c._getFromCache(t,c._noMipmap),c._texture?a&&(c._texture.isReady?Ce.b.SetImmediate((function(){return a()})):c._texture.onLoadedObservable.add(a)):i.useDelayedTextureLoading?c.delayLoadState=g.a.DELAYLOADSTATE_NOTLOADED:c.loadImage(c.loadTexture.bind(c),c._onError),c}return Object(h.d)(t,e),t.prototype.loadImage=function(e,t){var i=this,n=document.createElement(\"canvas\"),r=new Image;r.addEventListener(\"load\",(function(){i._width=r.width,i._height=r.height,n.width=i._width,n.height=i._height;var t=n.getContext(\"2d\");t.drawImage(r,0,0);var o=t.getImageData(0,0,r.width,r.height);i._buffer=o.data.buffer,n.remove(),e()})),r.addEventListener(\"error\",(function(e){t&&t(i.getClassName()+\" could not be loaded\",e)})),r.src=this.url},t.prototype.loadTexture=function(){var e=this,i=this.getScene();i&&(this._texture=i.getEngine().createRawCubeTextureFromUrl(this.url,i,this._size,g.a.TEXTUREFORMAT_RGB,i.getEngine().getCaps().textureFloat?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INTEGER,this._noMipmap,(function(){for(var i=e.getFloat32ArrayFromArrayBuffer(e._buffer),n=ic.ConvertPanoramaToCubemap(i,e._width,e._height,e._size),r=[],o=0;o<6;o++){var a=n[t._FacesMapping[o]];r.push(a)}return r}),null,this._onLoad,this._onError))},t.prototype.getFloat32ArrayFromArrayBuffer=function(e){for(var t=new DataView(e),i=new Float32Array(3*e.byteLength/4),n=0,r=0;ri.length)m.a.Error(\"Unable to load TGA file - Not enough data\");else{n+=r.id_length;var o,a=!1,s=!1,c=!1;switch(r.image_type){case e._TYPE_RLE_INDEXED:a=!0;case e._TYPE_INDEXED:s=!0;break;case e._TYPE_RLE_RGB:a=!0;case e._TYPE_RGB:break;case e._TYPE_RLE_GREY:a=!0;case e._TYPE_GREY:c=!0}var l,u,h,d,f,p,_,g=r.pixel_size>>3,v=r.width*r.height*g;if(s&&(l=i.subarray(n,n+=r.colormap_length*(r.colormap_size>>3))),a){var b,y,T;o=new Uint8Array(v);for(var E=0,S=new Uint8Array(g);n>e._ORIGIN_SHIFT){default:case e._ORIGIN_UL:u=0,d=1,_=r.width,h=0,f=1,p=r.height;break;case e._ORIGIN_BL:u=0,d=1,_=r.width,h=r.height-1,f=-1,p=-1;break;case e._ORIGIN_UR:u=r.width-1,d=-1,_=-1,h=0,f=1,p=r.height;break;case e._ORIGIN_BR:u=r.width-1,d=-1,_=-1,h=r.height-1,f=-1,p=-1}var A=e[\"_getImageData\"+(c?\"Grey\":\"\")+r.pixel_size+\"bits\"](r,l,o,h,f,p,u,d,_);t.getEngine()._uploadDataToTextureDirectly(t,A)}}},e._getImageData8bits=function(e,t,i,n,r,o,a,s,c){var l,u,h,d=i,f=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,m++)l=d[m],g[4*(u+p*h)+3]=255,g[4*(u+p*h)+2]=f[3*l+0],g[4*(u+p*h)+1]=f[3*l+1],g[4*(u+p*h)+0]=f[3*l+2];return g},e._getImageData16bits=function(e,t,i,n,r,o,a,s,c){var l,u,h,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,_+=2){var g=255*((31744&(l=d[_+0]+(d[_+1]<<8)))>>10)/31|0,v=255*((992&l)>>5)/31|0,b=255*(31&l)/31|0;m[4*(u+f*h)+0]=g,m[4*(u+f*h)+1]=v,m[4*(u+f*h)+2]=b,m[4*(u+f*h)+3]=32768&l?0:255}return m},e._getImageData24bits=function(e,t,i,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=3)_[4*(l+d*u)+3]=255,_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+1]=h[p+1],_[4*(l+d*u)+0]=h[p+2];return _},e._getImageData32bits=function(e,t,i,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=4)_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+1]=h[p+1],_[4*(l+d*u)+0]=h[p+2],_[4*(l+d*u)+3]=h[p+3];return _},e._getImageDataGrey8bits=function(e,t,i,n,r,o,a,s,c){var l,u,h,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,_++)l=d[_],m[4*(u+f*h)+0]=l,m[4*(u+f*h)+1]=l,m[4*(u+f*h)+2]=l,m[4*(u+f*h)+3]=255;return m},e._getImageDataGrey16bits=function(e,t,i,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=2)_[4*(l+d*u)+0]=h[p+0],_[4*(l+d*u)+1]=h[p+0],_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+3]=h[p+1];return _},e._TYPE_INDEXED=1,e._TYPE_RGB=2,e._TYPE_GREY=3,e._TYPE_RLE_INDEXED=9,e._TYPE_RLE_RGB=10,e._TYPE_RLE_GREY=11,e._ORIGIN_MASK=48,e._ORIGIN_SHIFT=4,e._ORIGIN_BL=0,e._ORIGIN_BR=1,e._ORIGIN_UL=2,e._ORIGIN_UR=3,e}(),Vc=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,\".tga\")},e.prototype.loadCubeData=function(e,t,i,n,r){throw\".env not supported in Cube.\"},e.prototype.loadData=function(e,t,i){var n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=Uc.GetTGAHeader(n);i(r.width,r.height,t.generateMipMaps,!1,(function(){Uc.UploadContent(t,n)}))},e}();Se.a._TextureLoaders.push(new Vc);var kc,zc=function(){};!function(e){e[e.cTFETC1=0]=\"cTFETC1\",e[e.cTFBC1=1]=\"cTFBC1\",e[e.cTFBC4=2]=\"cTFBC4\",e[e.cTFPVRTC1_4_OPAQUE_ONLY=3]=\"cTFPVRTC1_4_OPAQUE_ONLY\",e[e.cTFBC7_M6_OPAQUE_ONLY=4]=\"cTFBC7_M6_OPAQUE_ONLY\",e[e.cTFETC2=5]=\"cTFETC2\",e[e.cTFBC3=6]=\"cTFBC3\",e[e.cTFBC5=7]=\"cTFBC5\"}(kc||(kc={}));var Gc=function(){function e(){}return e.GetInternalFormatFromBasisFormat=function(e){if(e===kc.cTFETC1)return 36196;if(e===kc.cTFBC1)return 33776;if(e===kc.cTFBC3)return 33779;throw\"The chosen Basis transcoder format is not currently supported\"},e._CreateWorkerAsync=function(){var t=this;return this._WorkerPromise||(this._WorkerPromise=new Promise((function(i){t._Worker?i(t._Worker):Ce.b.LoadFileAsync(e.WasmModuleURL).then((function(n){var r=URL.createObjectURL(new Blob([\"(\"+jc+\")()\"],{type:\"application/javascript\"}));t._Worker=new Worker(r);var o=function(e){\"init\"===e.data.action&&(t._Worker.removeEventListener(\"message\",o),i(t._Worker))};t._Worker.addEventListener(\"message\",o),t._Worker.postMessage({action:\"init\",url:e.JSModuleURL,wasmBinary:n})}))}))),this._WorkerPromise},e.TranscodeAsync=function(e,t){var i=this,n=e instanceof ArrayBuffer?new Uint8Array(e):e;return new Promise((function(e,r){i._CreateWorkerAsync().then((function(){var o=i._actionId++,a=function(t){\"transcode\"===t.data.action&&t.data.id===o&&(i._Worker.removeEventListener(\"message\",a),t.data.success?e(t.data):r(\"Transcode is not supported on this device\"))};i._Worker.addEventListener(\"message\",a);var s=new Uint8Array(n.byteLength);s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),i._Worker.postMessage({action:\"transcode\",id:o,imageData:s,config:t,ignoreSupportedFormats:i._IgnoreSupportedFormats},[s.buffer])}))}))},e.LoadTextureFromTranscodeResult=function(t,i){for(var n,r=t.getEngine(),o=function(){if(n=i.fileInfo.images[a].levels[0],t._invertVScale=t.invertY,-1===i.format)if(t.type=g.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.format=g.a.TEXTUREFORMAT_RGB,r.webGLVersion<2&&(L.a.Log2(n.width)%1!=0||L.a.Log2(n.height)%1!=0)){var o=new Qe.a(r,Qe.b.Temp);t._invertVScale=t.invertY,o.type=g.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,o.format=g.a.TEXTUREFORMAT_RGB,o.width=n.width+3&-4,o.height=n.height+3&-4,r._bindTextureDirectly(r._gl.TEXTURE_2D,o,!0),r._uploadDataToTextureDirectly(o,n.transcodedPixels,a,0,g.a.TEXTUREFORMAT_RGB,!0),r._rescaleTexture(o,t,r.scenes[0],r._getInternalFormat(g.a.TEXTUREFORMAT_RGB),(function(){r._releaseTexture(o),r._bindTextureDirectly(r._gl.TEXTURE_2D,t,!0)}))}else t._invertVScale=!t.invertY,t.width=n.width+3&-4,t.height=n.height+3&-4,r._uploadDataToTextureDirectly(t,n.transcodedPixels,a,0,g.a.TEXTUREFORMAT_RGB,!0);else t.width=n.width,t.height=n.height,i.fileInfo.images[a].levels.forEach((function(n,o){r._uploadCompressedDataToTextureDirectly(t,e.GetInternalFormatFromBasisFormat(i.format),n.width,n.height,n.transcodedPixels,a,o)})),r.webGLVersion<2&&(L.a.Log2(t.width)%1!=0||L.a.Log2(t.height)%1!=0)&&(Ce.b.Warn(\"Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1.\"),t._cachedWrapU=Ke.a.CLAMP_ADDRESSMODE,t._cachedWrapV=Ke.a.CLAMP_ADDRESSMODE)},a=0;a>2&3],o[f++]=r[d>>4&3],o[f++]=r[d>>6&3]}}return o}(a,0,e.getImageWidth(t,i)+3&-4,e.getImageHeight(t,i)+3&-4));return a}onmessage=function(a){if(\"init\"===a.data.action)r||(Module={wasmBinary:a.data.wasmBinary},importScripts(a.data.url),r=new Promise((function(e){Module.onRuntimeInitialized=function(){Module.initializeBasis(),e()}}))),r.then((function(){postMessage({action:\"init\"})}));else if(\"transcode\"===a.data.action){var s=a.data.config,c=a.data.imageData,l=new Module.BasisFile(c),u=function(e){for(var t=e.getHasAlpha(),i=e.getNumImages(),n=[],r=0;r1&&t.generateMipMaps;Gc.LoadTextureFromTranscodeResult(t,e),t.getEngine()._setCubeMapTextureParams(t,i),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()})).catch((function(e){Ce.b.Warn(\"Failed to transcode Basis file, transcoding may not be supported on this device\"),t.isReady=!0}))}},e.prototype.loadData=function(e,t,i){var n=t.getEngine().getCaps(),r={supportedCompressionFormats:{etc1:!!n.etc1,s3tc:!!n.s3tc,pvrtc:!!n.pvrtc,etc2:!!n.etc2}};Gc.TranscodeAsync(e,r).then((function(e){var n=e.fileInfo.images[0].levels[0],r=e.fileInfo.images[0].levels.length>1&&t.generateMipMaps;i(n.width,n.height,r,-1!==e.format,(function(){Gc.LoadTextureFromTranscodeResult(t,e)}))})).catch((function(e){Ce.b.Warn(\"Failed to transcode Basis file, transcoding may not be supported on this device\"),i(0,0,!1,!1,(function(){}))}))},e}();Se.a._TextureLoaders.push(new Wc);var Hc=function(e){function t(t,i,n,r,o){var a=this,s=!(!o||!o.generateMipMaps)&&o.generateMipMaps,c=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,l=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio;if((a=e.call(this,t,i,r,s,l)||this).isSupported){var u=[],h=[];a._initTypes(n,u,h,o);var d=!o||void 0===o.generateDepthBuffer||o.generateDepthBuffer,f=!(!o||void 0===o.generateStencilBuffer)&&o.generateStencilBuffer;return a._size=i,a._multiRenderTargetOptions={samplingModes:h,generateMipMaps:s,generateDepthBuffer:d,generateStencilBuffer:f,generateDepthTexture:c,types:u,textureCount:n},a._count=n,a._createInternalTextures(),a._createTextures(),a}a.dispose()}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"isSupported\",{get:function(){return this._getEngine().webGLVersion>1||this._getEngine().getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"textures\",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"count\",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"depthTexture\",{get:function(){return this._textures[this._textures.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"wrapU\",{set:function(e){if(this._textures)for(var t=0;t=0;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},t}(Ni),Xc=function(e,t,i){this.id=e,this.scale=t,this.offset=i},Yc=function(){function e(t,i,n,r){var o,a,c,l,u,h,d,f,p,_,m,g,v;return this.name=t,this.meshes=i,this.scene=r,this.options=n,this.options.map=null!==(o=this.options.map)&&void 0!==o?o:[\"ambientTexture\",\"bumpTexture\",\"diffuseTexture\",\"emissiveTexture\",\"lightmapTexture\",\"opacityTexture\",\"reflectionTexture\",\"refractionTexture\",\"specularTexture\"],this.options.uvsIn=null!==(a=this.options.uvsIn)&&void 0!==a?a:Qi.b.UVKind,this.options.uvsOut=null!==(c=this.options.uvsOut)&&void 0!==c?c:Qi.b.UVKind,this.options.layout=null!==(l=this.options.layout)&&void 0!==l?l:e.LAYOUT_STRIP,this.options.layout===e.LAYOUT_COLNUM&&(this.options.colnum=null!==(u=this.options.colnum)&&void 0!==u?u:8),this.options.updateInputMeshes=null===(h=this.options.updateInputMeshes)||void 0===h||h,this.options.disposeSources=null===(d=this.options.disposeSources)||void 0===d||d,this._expecting=0,this.options.fillBlanks=null===(f=this.options.fillBlanks)||void 0===f||f,!0===this.options.fillBlanks&&(this.options.customFillColor=null!==(p=this.options.customFillColor)&&void 0!==p?p:\"black\"),this.options.frameSize=null!==(_=this.options.frameSize)&&void 0!==_?_:256,this.options.paddingRatio=null!==(m=this.options.paddingRatio)&&void 0!==m?m:.0115,this._paddingValue=Math.ceil(this.options.frameSize*this.options.paddingRatio),this._paddingValue%2!=0&&this._paddingValue++,this.options.paddingMode=null!==(g=this.options.paddingMode)&&void 0!==g?g:e.SUBUV_WRAP,this.options.paddingMode===e.SUBUV_COLOR&&(this.options.paddingColor=null!==(v=this.options.paddingColor)&&void 0!==v?v:new s.b(0,0,0,1)),this.sets={},this.frames=[],this}return e.prototype._createFrames=function(e){for(var t=this,i=this._calculateSize(),n=new a.d(1,1).divide(i),r=0,o=this._expecting,c=this.meshes.length,l=Object.keys(this.sets),u=0;u0);for(var e=0;e0)}},e}(),Qc=\"\\nattribute vec2 position;\\n\\nvarying vec2 vPosition;\\nvarying vec2 vUV;\\nconst vec2 madd=vec2(0.5,0.5);\\nvoid main(void) {\\nvPosition=position;\\nvUV=position*madd+madd;\\ngl_Position=vec4(position,0.0,1.0);\\n}\";ai.a.ShadersStore.proceduralVertexShader=Qc;var qc=function(e){function t(t,i,n,r,a,s,c,l){void 0===a&&(a=null),void 0===s&&(s=!0),void 0===c&&(c=!1),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,null,r,!s)||this;u.isEnabled=!0,u.autoClear=!0,u.onGeneratedObservable=new o.c,u.onBeforeGenerationObservable=new o.c,u.nodeMaterialSource=null,u._textures={},u._currentRefreshId=-1,u._frameId=-1,u._refreshRate=1,u._vertexBuffers={},u._uniforms=new Array,u._samplers=new Array,u._floats={},u._ints={},u._floatsArrays={},u._colors3={},u._colors4={},u._vectors2={},u._vectors3={},u._matrices={},u._fallbackTextureUsed=!1,u._cachedDefines=\"\",u._contentUpdateId=-1;var h=(r=u.getScene()||x.a.LastCreatedScene)._getComponent(Me.a.NAME_PROCEDURALTEXTURE);h||(h=new Kc(r),r._addComponent(h)),r.proceduralTextures.push(u),u._fullEngine=r.getEngine(),u.name=t,u.isRenderTarget=!0,u._size=i,u._generateMipMaps=s,u.setFragment(n),u._fallbackTexture=a,c?(u._texture=u._fullEngine.createRenderTargetCubeTexture(i,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:l}),u.setFloat(\"face\",0)):u._texture=u._fullEngine.createRenderTargetTexture(i,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:l});var d=[];return d.push(1,1),d.push(-1,1),d.push(-1,-1),d.push(1,-1),u._vertexBuffers[Qi.b.PositionKind]=new Qi.b(u._fullEngine,d,Qi.b.PositionKind,!1,!1,2),u._createIndexBuffer(),u}return Object(h.d)(t,e),t.prototype.getEffect=function(){return this._effect},t.prototype.getContent=function(){return this._contentData&&this._frameId===this._contentUpdateId||(this._contentData=this.readPixels(0,0,this._contentData),this._contentUpdateId=this._frameId),this._contentData},t.prototype._createIndexBuffer=function(){var e=this._fullEngine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},t.prototype._rebuild=function(){var e=this._vertexBuffers[Qi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===Ni.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Ni.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){void 0!==this._effect&&this._effect.dispose()},t.prototype._getDefines=function(){return\"\"},t.prototype.isReady=function(){var e,t=this,i=this._fullEngine;if(this.nodeMaterialSource)return this._effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var n=this._getDefines();return!(!this._effect||n!==this._cachedDefines||!this._effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:\"procedural\",fragmentElement:this._fragment.fragmentElement}:{vertex:\"procedural\",fragment:this._fragment},this._cachedDefines=n,this._effect=i.createEffect(e,[Qi.b.PositionKind],this._uniforms,this._samplers,n,void 0,void 0,(function(){t.releaseInternalTexture(),t._fallbackTexture&&(t._texture=t._fallbackTexture._texture,t._texture&&t._texture.incrementReferences()),t._fallbackTextureUsed=!0})),this._effect.isReady())},t.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},t.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(t.prototype,\"refreshRate\",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!1,configurable:!0}),t.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,this._frameId++,!0):(this._currentRefreshId++,!1)):(this._texture&&(this._texture.isReady=!1),!1)},t.prototype.getRenderSize=function(){return this._size},t.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this._fullEngine.createRenderTargetTexture(e,t),this._size=e,this._generateMipMaps=t)},t.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},t.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},t.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},t.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},t.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},t.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},t.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},t.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},t.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},t.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},t.prototype.render=function(e){var t=this.getScene();if(t){var i=this._fullEngine;if(i.enableEffect(this._effect),this.onBeforeGenerationObservable.notifyObservers(this),i.setState(!1),!this.nodeMaterialSource){for(var n in this._textures)this._effect.setTexture(n,this._textures[n]);for(n in this._ints)this._effect.setInt(n,this._ints[n]);for(n in this._floats)this._effect.setFloat(n,this._floats[n]);for(n in this._floatsArrays)this._effect.setArray(n,this._floatsArrays[n]);for(n in this._colors3)this._effect.setColor3(n,this._colors3[n]);for(n in this._colors4){var r=this._colors4[n];this._effect.setFloat4(n,r.r,r.g,r.b,r.a)}for(n in this._vectors2)this._effect.setVector2(n,this._vectors2[n]);for(n in this._vectors3)this._effect.setVector3(n,this._vectors3[n]);for(n in this._matrices)this._effect.setMatrix(n,this._matrices[n])}if(this._texture){if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat(\"face\",o),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(xo.a.TriangleFillMode,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture,0,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(xo.a.TriangleFillMode,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},t.prototype.clone=function(){var e=this.getSize(),i=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.coordinatesMode=this.coordinatesMode,i},t.prototype.dispose=function(){var t=this.getScene();if(t){var i=t.proceduralTextures.indexOf(this);i>=0&&t.proceduralTextures.splice(i,1);var n=this._vertexBuffers[Qi.b.PositionKind];n&&(n.dispose(),this._vertexBuffers[Qi.b.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),e.prototype.dispose.call(this)}},Object(h.c)([Object(w.c)()],t.prototype,\"isEnabled\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"autoClear\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_generateMipMaps\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"_size\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"refreshRate\",null),t}(Ke.a);c.a.RegisteredTypes[\"BABYLON.ProceduralTexture\"]=qc;var Zc=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,n,null,r,o,a)||this;return s._animate=!0,s._time=0,s._texturePath=i,s._loadJson(i),s.refreshRate=1,s}return Object(h.d)(t,e),t.prototype._loadJson=function(e){var t=this,i=function(){try{t.setFragment(t._texturePath)}catch(e){m.a.Error(\"No json or ShaderStore or DOM element found for CustomProceduralTexture\")}},n=e+\"/config.json\",r=new V.a;r.open(\"GET\",n),r.addEventListener(\"load\",(function(){if(200===r.status||r.responseText&&r.responseText.length>0)try{t._config=JSON.parse(r.response),t.updateShaderUniforms(),t.updateTextures(),t.setFragment(t._texturePath+\"/custom\"),t._animate=t._config.animate,t.refreshRate=t._config.refreshrate}catch(e){i()}else i()}),!1),r.addEventListener(\"error\",(function(){i()}),!1);try{r.send()}catch(e){m.a.Error(\"CustomProceduralTexture: Error on XHR send request.\")}},t.prototype.isReady=function(){if(!e.prototype.isReady.call(this))return!1;for(var t in this._textures){if(!this._textures[t].isReady())return!1}return!0},t.prototype.render=function(t){var i=this.getScene();this._animate&&i&&(this._time+=.03*i.getAnimationRatio(),this.updateShaderUniforms()),e.prototype.render.call(this,t)},t.prototype.updateTextures=function(){for(var e=0;e0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isConnectedInVertexShader\",{get:function(){if(this.target===el.Vertex)return!0;if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e=0)&&(t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),t},e.prototype.dispose=function(){this.onConnectionObservable.clear()},e}(),dl=i(152),fl=function(){function e(e,t,i,n){void 0===t&&(t=el.Vertex),void 0===i&&(i=!1),void 0===n&&(n=!1),this._isFinalMerger=!1,this._isInput=!1,this._name=\"\",this._isUnique=!1,this.inputsAreExclusive=!1,this._codeVariableName=\"\",this._inputs=new Array,this._outputs=new Array,this.comments=\"\",this.visibleInInspector=!1,this._target=t,this._isFinalMerger=i,this._isInput=n,this._name=e,this.uniqueId=dl.a.UniqueId}return Object.defineProperty(e.prototype,\"name\",{get:function(){return this._name},set:function(e){this.validateBlockName(e)&&(this._name=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isUnique\",{get:function(){return this._isUnique},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isFinalMerger\",{get:function(){return this._isFinalMerger},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isInput\",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"buildId\",{get:function(){return this._buildId},set:function(e){this._buildId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"target\",{get:function(){return this._target},set:function(e){0==(this._target&e)&&(this._target=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"inputs\",{get:function(){return this._inputs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"outputs\",{get:function(){return this._outputs},enumerable:!1,configurable:!0}),e.prototype.getInputByName=function(e){var t=this._inputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.getOutputByName=function(e){var t=this._outputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.initialize=function(e){},e.prototype.bind=function(e,t,i,n){},e.prototype._declareOutput=function(e,t){return t._getGLType(e.type)+\" \"+e.associatedVariableName},e.prototype._writeVariable=function(e){return e.connectedPoint?\"\"+e.associatedVariableName:\"0.\"},e.prototype._writeFloat=function(e){var t=e.toString();return-1===t.indexOf(\".\")&&(t+=\".0\"),\"\"+t},e.prototype.getClassName=function(){return\"NodeMaterialBlock\"},e.prototype.registerInput=function(e,t,i,n,r){return void 0===i&&(i=!1),(r=null!=r?r:new hl(e,this,al.Input)).type=t,r.isOptional=i,n&&(r.target=n),this._inputs.push(r),this},e.prototype.registerOutput=function(e,t,i,n){return(n=null!=n?n:new hl(e,this,al.Output)).type=t,i&&(n.target=i),this._outputs.push(n),this},e.prototype.getFirstAvailableInput=function(e){void 0===e&&(e=null);for(var t=0,i=this._inputs;t=this._outputs.length?null:this._outputs[t+1]},e.prototype.connectTo=function(e,t){if(0!==this._outputs.length){for(var i=t&&t.output?this.getOutputByName(t.output):this.getFirstAvailableOutput(e),n=!0;n;){var r=t&&t.input?e.getInputByName(t.input):e.getFirstAvailableInput(i);if(i&&r&&i.canConnectTo(r))i.connectTo(r),n=!1;else{if(!i)throw\"Unable to find a compatible match\";i=this.getSiblingOutput(i)}}return this}},e.prototype._buildBlock=function(e){},e.prototype.updateUniformsAndSamples=function(e,t,i,n){},e.prototype.provideFallbacks=function(e,t){},e.prototype.initializeDefines=function(e,t,i,n){void 0===n&&(n=!1)},e.prototype.prepareDefines=function(e,t,i,n,r){void 0===n&&(n=!1)},e.prototype.autoConfigure=function(e){},e.prototype.replaceRepeatableContent=function(e,t,i,n){},e.prototype.isReady=function(e,t,i,n){return void 0===n&&(n=!1),!0},e.prototype._linkConnectionTypes=function(e,t,i){void 0===i&&(i=!1),i?this._inputs[t]._acceptedConnectionPointType=this._inputs[e]:this._inputs[e]._linkedConnectionSource=this._inputs[t],this._inputs[t]._linkedConnectionSource=this._inputs[e]},e.prototype._processBuild=function(e,t,i,n){e.build(t,n);var r=null!=t._vertexState,o=e._buildTarget===el.Vertex&&e.target!==el.VertexAndFragment;if(r&&(0==(e.target&e._buildTarget)||0==(e.target&i.target)||this.target!==el.VertexAndFragment&&o)&&(!e.isInput&&t.target!==e._buildTarget||e.isInput&&e.isAttribute&&!e._noContextSwitch)){var a=i.connectedPoint;t._vertexState._emitVaryingFromString(\"v_\"+a.associatedVariableName,t._getGLType(a.type))&&(t._vertexState.compilationString+=\"v_\"+a.associatedVariableName+\" = \"+a.associatedVariableName+\";\\r\\n\"),i.associatedVariableName=\"v_\"+a.associatedVariableName,i._enforceAssociatedVariableName=!0}},e.prototype.validateBlockName=function(e){for(var t=0,i=[\"position\",\"normal\",\"tangent\",\"particle_positionw\",\"uv\",\"uv2\",\"position2d\",\"particle_uv\",\"matricesIndices\",\"matricesWeights\",\"world0\",\"world1\",\"world2\",\"world3\",\"particle_color\",\"particle_texturemask\"];t[0..\"+i.repeatKey+\"]\\r\\n\";var n=ai.a.IncludesShadersStore[e]+\"\\r\\n\";if(this.sharedData.emitComments&&(n=t+\"\\r\\n\"+n),!i)return n;if(i.replaceStrings)for(var r=0;r[0..\"+i.repeatKey+\"]\\r\\n\":this.functions[r]=\"#include<\"+e+\">\\r\\n\",void(this.sharedData.emitComments&&(this.functions[r]=t+\"\\r\\n\"+this.functions[r]));if(this.functions[r]=ai.a.IncludesShadersStore[e],this.sharedData.emitComments&&(this.functions[r]=t+\"\\r\\n\"+this.functions[r]),i.removeIfDef&&(this.functions[r]=this.functions[r].replace(/^\\s*?#ifdef.+$/gm,\"\"),this.functions[r]=this.functions[r].replace(/^\\s*?#endif.*$/gm,\"\"),this.functions[r]=this.functions[r].replace(/^\\s*?#else.*$/gm,\"\"),this.functions[r]=this.functions[r].replace(/^\\s*?#elif.*$/gm,\"\")),i.removeAttributes&&(this.functions[r]=this.functions[r].replace(/^\\s*?attribute.+$/gm,\"\")),i.removeUniforms&&(this.functions[r]=this.functions[r].replace(/^\\s*?uniform.+$/gm,\"\")),i.removeVaryings&&(this.functions[r]=this.functions[r].replace(/^\\s*?varying.+$/gm,\"\")),i.replaceStrings)for(var o=0;o0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},e.prototype.getDragGradients=function(){return this._dragGradients},e.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},e.prototype.getColorGradients=function(){return this._colorGradients},e.prototype.getSizeGradients=function(){return this._sizeGradients},e.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},e.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},e.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},e.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},e.prototype.getVelocityGradients=function(){return this._velocityGradients},e.prototype.getStartSizeGradients=function(){return this._startSizeGradients},e.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(e.prototype,\"direction1\",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:a.e.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"direction2\",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:a.e.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"minEmitBox\",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:a.e.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"maxEmitBox\",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:a.e.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isBillboardBased\",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"imageProcessingConfiguration\",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(!e&&this._scene?this._imageProcessingConfiguration=this._scene.imageProcessingConfiguration:this._imageProcessingConfiguration=e)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,i){if(!t)return this;for(var n=0,r=0,o=t;r-1))return this._optimizers.push(e),this},t.prototype.unregisterOptimizer=function(e){var t=this._optimizers.indexOf(e);if(-1!==t)return this._optimizers.splice(t,1),this},t.prototype.addOutputNode=function(e){if(null===e.target)throw\"This node is not meant to be an output node. You may want to explicitly set its target value.\";return 0!=(e.target&el.Vertex)&&this._addVertexOutputNode(e),0!=(e.target&el.Fragment)&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(0!=(e.target&el.Vertex)&&this._removeVertexOutputNode(e),0!=(e.target&el.Fragment)&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=el.Vertex,this._vertexOutputNodes.push(e),this},t.prototype._removeVertexOutputNode=function(e){var t=this._vertexOutputNodes.indexOf(e);if(-1!==t)return this._vertexOutputNodes.splice(t,1),this},t.prototype._addFragmentOutputNode=function(e){if(-1===this._fragmentOutputNodes.indexOf(e))return e.target=el.Fragment,this._fragmentOutputNodes.push(e),this},t.prototype._removeFragmentOutputNode=function(e){var t=this._fragmentOutputNodes.indexOf(e);if(-1!==t)return this._fragmentOutputNodes.splice(t,1),this},t.prototype.needAlphaBlending=function(){return!this.ignoreAlpha&&(this.alpha<1||this._sharedData&&this._sharedData.hints.needAlphaBlending)},t.prototype.needAlphaTesting=function(){return this._sharedData&&this._sharedData.hints.needAlphaTesting},t.prototype._initializeBlock=function(e,t,i){if(e.initialize(t),e.autoConfigure(this),e._preparationId=this._buildId,-1===this.attachedBlocks.indexOf(e)){if(e.isUnique)for(var n=e.getClassName(),r=0,o=this.attachedBlocks;r-1&&this.attachedBlocks.splice(t,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e){void 0===e&&(e=!1),this._buildWasSuccessful=!1;var i=this.getScene().getEngine(),n=this._mode===rl.Particle;if(0===this._vertexOutputNodes.length&&!n)throw\"You must define at least one vertexOutputNode\";if(0===this._fragmentOutputNodes.length)throw\"You must define at least one fragmentOutputNode\";this._vertexCompilationState=new pl,this._vertexCompilationState.supportUniformBuffers=i.supportsUniformBuffers,this._vertexCompilationState.target=el.Vertex,this._fragmentCompilationState=new pl,this._fragmentCompilationState.supportUniformBuffers=i.supportsUniformBuffers,this._fragmentCompilationState.target=el.Fragment,this._sharedData=new _l,this._vertexCompilationState.sharedData=this._sharedData,this._fragmentCompilationState.sharedData=this._sharedData,this._sharedData.buildId=this._buildId,this._sharedData.emitComments=this._options.emitComments,this._sharedData.verbose=e,this._sharedData.scene=this.getScene(),this._sharedData.allowEmptyVertexProgram=n;for(var r=[],o=[],a=0,s=this._vertexOutputNodes;a0\\r\\n\",t.compilationString+=this._declareOutput(r,t)+\" = \"+o.associatedVariableName+\" * \"+n+\";\\r\\n\",t.compilationString+=\"#else\\r\\n\",t.compilationString+=this._declareOutput(r,t)+\" = \"+o.associatedVariableName+\";\\r\\n\",t.compilationString+=\"#endif\\r\\n\",this},t}(fl);c.a.RegisteredTypes[\"BABYLON.BonesBlock\"]=Zl;var Jl=function(e){function t(t){var i=e.call(this,t,el.Vertex)||this;return i.registerInput(\"world0\",tl.Vector4),i.registerInput(\"world1\",tl.Vector4),i.registerInput(\"world2\",tl.Vector4),i.registerInput(\"world3\",tl.Vector4),i.registerInput(\"world\",tl.Matrix,!0),i.registerOutput(\"output\",tl.Matrix),i.registerOutput(\"instanceID\",tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"InstancesBlock\"},Object.defineProperty(t.prototype,\"world0\",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"world1\",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"world2\",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"world3\",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"world\",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"output\",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"instanceID\",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.world0.connectedPoint){var t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"world0\"===e.name}));t||(t=new Sl(\"world0\")).setAsAttribute(\"world0\"),t.output.connectTo(this.world0)}if(!this.world1.connectedPoint){var i=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"world1\"===e.name}));i||(i=new Sl(\"world1\")).setAsAttribute(\"world1\"),i.output.connectTo(this.world1)}if(!this.world2.connectedPoint){var n=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"world2\"===e.name}));n||(n=new Sl(\"world2\")).setAsAttribute(\"world2\"),n.output.connectTo(this.world2)}if(!this.world3.connectedPoint){var r=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"world3\"===e.name}));r||(r=new Sl(\"world3\")).setAsAttribute(\"world3\"),r.output.connectTo(this.world3)}if(!this.world.connectedPoint){var o=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"world\"===e.name}));o||(o=new Sl(\"world\")).setAsSystemValue(nl.World),o.output.connectTo(this.world)}this.world.define=\"!INSTANCES || THIN_INSTANCES\"},t.prototype.prepareDefines=function(e,t,i,n,r){void 0===n&&(n=!1);var o=!1;i.INSTANCES!==n&&(i.setValue(\"INSTANCES\",n),o=!0),r&&i.THIN_INSTANCES!==!!(null==r?void 0:r.getRenderingMesh().hasThinInstances)&&(i.setValue(\"THIN_INSTANCES\",!!(null==r?void 0:r.getRenderingMesh().hasThinInstances)),o=!0),o&&i.markAsUnprocessed()},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t),t.sharedData.blocksWithDefines.push(this);var i=this._outputs[0],n=this._outputs[1],r=this.world0,o=this.world1,a=this.world2,s=this.world3;return t.compilationString+=\"#ifdef INSTANCES\\r\\n\",t.compilationString+=this._declareOutput(i,t)+\" = mat4(\"+r.associatedVariableName+\", \"+o.associatedVariableName+\", \"+a.associatedVariableName+\", \"+s.associatedVariableName+\");\\r\\n\",t.compilationString+=\"#ifdef THIN_INSTANCES\\r\\n\",t.compilationString+=i.associatedVariableName+\" = \"+this.world.associatedVariableName+\" * \"+i.associatedVariableName+\";\\r\\n\",t.compilationString+=\"#endif\\r\\n\",t.compilationString+=this._declareOutput(n,t)+\" = float(gl_InstanceID);\\r\\n\",t.compilationString+=\"#else\\r\\n\",t.compilationString+=this._declareOutput(i,t)+\" = \"+this.world.associatedVariableName+\";\\r\\n\",t.compilationString+=this._declareOutput(n,t)+\" = 0.0;\\r\\n\",t.compilationString+=\"#endif\\r\\n\",this},t}(fl);c.a.RegisteredTypes[\"BABYLON.InstancesBlock\"]=Jl;var $l=function(e){function t(t){var i=e.call(this,t,el.Vertex)||this;return i.registerInput(\"position\",tl.Vector3),i.registerInput(\"normal\",tl.Vector3),i.registerInput(\"tangent\",tl.Vector3),i.registerInput(\"uv\",tl.Vector2),i.registerOutput(\"positionOutput\",tl.Vector3),i.registerOutput(\"normalOutput\",tl.Vector3),i.registerOutput(\"tangentOutput\",tl.Vector3),i.registerOutput(\"uvOutput\",tl.Vector2),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"MorphTargetsBlock\"},Object.defineProperty(t.prototype,\"position\",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"normal\",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"tangent\",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"uv\",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"positionOutput\",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"normalOutput\",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"tangentOutput\",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"uvOutput\",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName(\"morphTargetInfluences\")},t.prototype.autoConfigure=function(e){if(!this.position.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"position\"===e.name}));t||(t=new Sl(\"position\")).setAsAttribute(),t.output.connectTo(this.position)}if(!this.normal.isConnected){var i=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"normal\"===e.name}));i||(i=new Sl(\"normal\")).setAsAttribute(\"normal\"),i.output.connectTo(this.normal)}if(!this.tangent.isConnected){var n=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"tangent\"===e.name}));n||(n=new Sl(\"tangent\")).setAsAttribute(\"tangent\"),n.output.connectTo(this.tangent)}if(!this.uv.isConnected){var r=e.getInputBlockByPredicate((function(e){return e.isAttribute&&\"uv\"===e.name}));r||(r=new Sl(\"uv\")).setAsAttribute(\"uv\"),r.output.connectTo(this.uv)}},t.prototype.prepareDefines=function(e,t,i){i._areAttributesDirty&&ro.a.PrepareDefinesForMorphTargets(e,i)},t.prototype.bind=function(e,t,i){i&&i.morphTargetManager&&i.morphTargetManager.numInfluencers>0&&ro.a.BindMorphTargetParameters(i,e)},t.prototype.replaceRepeatableContent=function(e,t,i,n){for(var r=this.position,o=this.normal,a=this.tangent,s=this.uv,c=this.positionOutput,l=this.normalOutput,u=this.tangentOutput,h=this.uvOutput,d=e,f=n.NUM_MORPH_INFLUENCERS,p=i.morphTargetManager,_=p&&p.supportsNormals&&n.NORMAL,m=p&&p.supportsTangents&&n.TANGENT,g=p&&p.supportsUVs&&n.UV1,v=\"\",b=0;b0)for(b=0;b=0;ro.a.PrepareUniformsAndSamplersForLight(r,e.uniforms,e.samplers,i[\"PROJECTEDLIGHTTEXTURE\"+r],n,o)}},t.prototype.bind=function(e,t,i){if(i){var n=i.getScene();this.light?ro.a.BindLight(this.light,this._lightId,n,e,!0):ro.a.BindLights(n,i,e,!0,t.maxSimultaneousLights)}},t.prototype._injectVertexCode=function(e){var t=this.worldPosition,i=\"//\"+this.name;this.light?(this._lightId=(void 0!==e.counters.lightCounter?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?\"lightUboDeclaration\":\"lightFragmentDeclaration\",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?\"lightUboDeclaration\":\"lightFragmentDeclaration\",i,{repeatKey:\"maxSimultaneousLights\"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var n=\"v_\"+t.associatedVariableName;e._emitVaryingFromString(n,\"vec4\")&&(e.compilationString+=n+\" = \"+t.associatedVariableName+\";\\r\\n\"),this.light?e.compilationString+=e._emitCodeFromInclude(\"shadowsVertex\",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:t.associatedVariableName}]}):(e.compilationString+=\"vec4 worldPos = \"+t.associatedVariableName+\";\\r\\n\",this.view.isConnected&&(e.compilationString+=\"mat4 view = \"+this.view.associatedVariableName+\";\\r\\n\"),e.compilationString+=e._emitCodeFromInclude(\"shadowsVertex\",i,{repeatKey:\"maxSimultaneousLights\"}))},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===el.Fragment){t.sharedData.bindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var i=\"//\"+this.name,n=this.worldPosition;t._emitFunctionFromInclude(\"helperFunctions\",i),t._emitFunctionFromInclude(\"lightsFragmentFunctions\",i,{replaceStrings:[{search:/vPositionW/g,replace:\"v_\"+n.associatedVariableName+\".xyz\"}]}),t._emitFunctionFromInclude(\"shadowsFragmentFunctions\",i,{replaceStrings:[{search:/vPositionW/g,replace:\"v_\"+n.associatedVariableName+\".xyz\"}]}),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?\"lightUboDeclaration\":\"lightFragmentDeclaration\",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?\"lightUboDeclaration\":\"lightFragmentDeclaration\",i,{repeatKey:\"maxSimultaneousLights\"}),0===this._lightId&&(t._registerTempVariable(\"viewDirectionW\")&&(t.compilationString+=\"vec3 viewDirectionW = normalize(\"+this.cameraPosition.associatedVariableName+\" - v_\"+n.associatedVariableName+\".xyz);\\r\\n\"),t.compilationString+=\"lightingInfo info;\\r\\n\",t.compilationString+=\"float shadow = 1.;\\r\\n\",t.compilationString+=\"float glossiness = \"+(this.glossiness.isConnected?this.glossiness.associatedVariableName:\"1.0\")+\" * \"+(this.glossPower.isConnected?this.glossPower.associatedVariableName:\"1024.0\")+\";\\r\\n\",t.compilationString+=\"vec3 diffuseBase = vec3(0., 0., 0.);\\r\\n\",t.compilationString+=\"vec3 specularBase = vec3(0., 0., 0.);\\r\\n\",t.compilationString+=\"vec3 normalW = \"+this.worldNormal.associatedVariableName+\".xyz;\\r\\n\"),this.light?t.compilationString+=t._emitCodeFromInclude(\"lightFragment\",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):t.compilationString+=t._emitCodeFromInclude(\"lightFragment\",i,{repeatKey:\"maxSimultaneousLights\"});var r=this.diffuseOutput,o=this.specularOutput;return t.compilationString+=this._declareOutput(r,t)+\" = diffuseBase\"+(this.diffuseColor.isConnected?\" * \"+this.diffuseColor.associatedVariableName:\"\")+\";\\r\\n\",o.hasEndpoints&&(t.compilationString+=this._declareOutput(o,t)+\" = specularBase\"+(this.specularColor.isConnected?\" * \"+this.specularColor.associatedVariableName:\"\")+\";\\r\\n\"),this.shadow.hasEndpoints&&(t.compilationString+=this._declareOutput(this.shadow,t)+\" = shadow;\\r\\n\"),this}this._injectVertexCode(t)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.light&&(t.lightId=this.light.id),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),t.lightId&&(this.light=i.getLightByID(t.lightId))},t}(fl);c.a.RegisteredTypes[\"BABYLON.LightBlock\"]=lu;var uu=function(e){function t(t,i){void 0===i&&(i=!1);var n=e.call(this,t,i?el.Fragment:el.VertexAndFragment)||this;return n.convertToGammaSpace=!1,n.convertToLinearSpace=!1,n._fragmentOnly=i,n.registerInput(\"uv\",tl.Vector2,!1,el.VertexAndFragment),n.registerOutput(\"rgba\",tl.Color4,el.Neutral),n.registerOutput(\"rgb\",tl.Color3,el.Neutral),n.registerOutput(\"r\",tl.Float,el.Neutral),n.registerOutput(\"g\",tl.Float,el.Neutral),n.registerOutput(\"b\",tl.Float,el.Neutral),n.registerOutput(\"a\",tl.Float,el.Neutral),n._inputs[0].acceptedConnectionPointTypes.push(tl.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),n._inputs[0]._prioritizeVertex=!i,n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"TextureBlock\"},Object.defineProperty(t.prototype,\"uv\",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"rgba\",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"rgb\",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"r\",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"g\",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"b\",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"a\",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"target\",{get:function(){if(this._fragmentOnly)return el.Fragment;if(!this.uv.isConnected)return el.VertexAndFragment;if(this.uv.sourceBlock.isInput)return el.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===el.Fragment)return el.Fragment;if(e.target===el.Vertex)return el.VertexAndFragment;if(e.target===el.Neutral||e.target===el.VertexAndFragment){var t=e.ownerBlock;e=null;for(var i=0,n=t.inputs;i1?i.setValue(\"NUM_SAMPLES\",this.realTimeFilteringQuality+\"u\",!0):i.setValue(\"NUM_SAMPLES\",\"\"+this.realTimeFilteringQuality,!0),i.setValue(\"BRDF_V_HEIGHT_CORRELATED\",!0),i.setValue(\"MS_BRDF_ENERGY_CONSERVATION\",this.useEnergyConservation,!0),i.setValue(\"RADIANCEOCCLUSION\",this.useRadianceOcclusion,!0),i.setValue(\"HORIZONOCCLUSION\",this.useHorizonOcclusion,!0),i.setValue(\"UNLIT\",this.unlit,!0),i.setValue(\"FORCENORMALFORWARD\",this.forceNormalForward,!0),this._environmentBRDFTexture&&so.a.ReflectionTextureEnabled?(i.setValue(\"ENVIRONMENTBRDF\",!0),i.setValue(\"ENVIRONMENTBRDF_RGBD\",this._environmentBRDFTexture.isRGBD,!0)):(i.setValue(\"ENVIRONMENTBRDF\",!1),i.setValue(\"ENVIRONMENTBRDF_RGBD\",!1)),i._areLightsDirty){var r=e.getScene();if(this.light){var o={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};ro.a.PrepareDefinesForLight(r,e,this.light,this._lightId,i,!0,o),o.needRebuild&&i.rebuild()}else ro.a.PrepareDefinesForLights(r,e,i,!0,t.maxSimultaneousLights),i._needNormals=!0,ro.a.PrepareDefinesForMultiview(r,i)}},t.prototype.updateUniformsAndSamples=function(e,t,i,n){for(var r=0;r=0;ro.a.PrepareUniformsAndSamplersForLight(r,e.uniforms,e.samplers,i[\"PROJECTEDLIGHTTEXTURE\"+r],n,o)}},t.prototype.bind=function(e,t,i){var n,r;if(i){var o=i.getScene();this.light?ro.a.BindLight(this.light,this._lightId,o,e,!0):ro.a.BindLights(o,i,e,!0,t.maxSimultaneousLights),e.setTexture(this._environmentBrdfSamplerName,this._environmentBRDFTexture),e.setFloat2(\"vDebugMode\",this.debugLimit,this.debugFactor);var a=this._scene.ambientColor;a&&e.setColor3(\"ambientFromScene\",a);var c=o.useRightHandedSystem===(null!=o._mirroredCameraPosition);e.setFloat(this._invertNormalName,c?-1:1),e.setFloat4(\"vLightingIntensity\",this.directIntensity,1,this.environmentIntensity*this._scene.environmentIntensity,this.specularIntensity);var l=null!==(r=null===(n=this.indexOfRefraction.connectInputBlock)||void 0===n?void 0:n.value)&&void 0!==r?r:1.5,u=Math.pow((l-1)/(l+1),2);this._metallicReflectanceColor.scaleToRef(u*this._metallicF0Factor,s.c.Color3[0]);var h=this._metallicF0Factor;e.setColor4(this._vMetallicReflectanceFactorsName,s.c.Color3[0],h)}},t.prototype._injectVertexCode=function(e){var t,i,n=this.worldPosition,r=\"//\"+this.name;this.light?(this._lightId=(void 0!==e.counters.lightCounter?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?\"lightUboDeclaration\":\"lightFragmentDeclaration\",r,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?\"lightUboDeclaration\":\"lightFragmentDeclaration\",r,{repeatKey:\"maxSimultaneousLights\"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var o=\"v_\"+n.associatedVariableName;e._emitVaryingFromString(o,\"vec4\")&&(e.compilationString+=o+\" = \"+n.associatedVariableName+\";\\r\\n\");var a=this.reflection.isConnected?null===(t=this.reflection.connectedPoint)||void 0===t?void 0:t.ownerBlock:null;a&&(a.viewConnectionPoint=this.view),e.compilationString+=null!==(i=null==a?void 0:a.handleVertexSide(e))&&void 0!==i?i:\"\",e._emitUniformFromString(\"vDebugMode\",\"vec2\",\"defined(IGNORE) || DEBUGMODE > 0\"),e._emitUniformFromString(\"ambientFromScene\",\"vec3\"),e._emitVaryingFromString(\"vClipSpacePosition\",\"vec4\",\"defined(IGNORE) || DEBUGMODE > 0\")&&(e._injectAtEnd+=\"#if DEBUGMODE > 0\\r\\n\",e._injectAtEnd+=\"vClipSpacePosition = gl_Position;\\r\\n\",e._injectAtEnd+=\"#endif\\r\\n\"),this.light?e.compilationString+=e._emitCodeFromInclude(\"shadowsVertex\",r,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:n.associatedVariableName}]}):(e.compilationString+=\"vec4 worldPos = \"+n.associatedVariableName+\";\\r\\n\",this.view.isConnected&&(e.compilationString+=\"mat4 view = \"+this.view.associatedVariableName+\";\\r\\n\"),e.compilationString+=e._emitCodeFromInclude(\"shadowsVertex\",r,{repeatKey:\"maxSimultaneousLights\"}))},t.prototype._getAlbedoOpacityCode=function(){var e=\"albedoOpacityOutParams albedoOpacityOut;\\r\\n\";return e+=\"albedoOpacityBlock(\\n vec4(\"+(this.baseColor.isConnected?this.baseColor.associatedVariableName:\"vec3(1.)\")+\", 1.),\\n #ifdef ALBEDO\\n vec4(1.),\\n vec2(1., 1.),\\n #endif\\n #ifdef OPACITY\\n vec4(\"+(this.opacity.isConnected?this.opacity.associatedVariableName:\"1.\")+\"),\\n vec2(1., 1.),\\n #endif\\n albedoOpacityOut\\n );\\n\\n vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;\\n float alpha = albedoOpacityOut.alpha;\\r\\n\"},t.prototype._getAmbientOcclusionCode=function(){var e=\"ambientOcclusionOutParams aoOut;\\r\\n\";return e+=\"ambientOcclusionBlock(\\n #ifdef AMBIENT\\n vec3(\"+(this.ambientOcc.isConnected?this.ambientOcc.associatedVariableName:\"1.\")+\"),\\n vec4(0., 1.0, 1.0, 0.),\\n #endif\\n aoOut\\n );\\r\\n\"},t.prototype._getReflectivityCode=function(e){var t=\"reflectivityOutParams reflectivityOut;\\r\\n\";return this._vMetallicReflectanceFactorsName=e._getFreeVariableName(\"vMetallicReflectanceFactors\"),e._emitUniformFromString(this._vMetallicReflectanceFactorsName,\"vec4\"),t+=\"vec3 baseColor = surfaceAlbedo;\\n\\n reflectivityBlock(\\n vec4(\"+this.metallic.associatedVariableName+\", \"+this.roughness.associatedVariableName+\", 0., 0.),\\n #ifdef METALLICWORKFLOW\\n surfaceAlbedo,\\n \"+this._vMetallicReflectanceFactorsName+\",\\n #endif\\n #ifdef REFLECTIVITY\\n vec3(0., 0., 1.),\\n vec4(1.),\\n #endif\\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\\n aoOut.ambientOcclusionColor,\\n #endif\\n #ifdef MICROSURFACEMAP\\n microSurfaceTexel, <== not handled!\\n #endif\\n reflectivityOut\\n );\\n\\n float microSurface = reflectivityOut.microSurface;\\n float roughness = reflectivityOut.roughness;\\n\\n #ifdef METALLICWORKFLOW\\n surfaceAlbedo = reflectivityOut.surfaceAlbedo;\\n #endif\\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\\n aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;\\n #endif\\r\\n\"},t.prototype._buildBlock=function(t){var i,n,r,o,a,s,c,l,u,h,d,f,p,_,m,g,v,b,y,T,E,S,A,P,C,R,x,O,M,I,D,N,L,w,F,B,U,V,k;e.prototype._buildBlock.call(this,t),this._scene=t.sharedData.scene,this._environmentBRDFTexture||(this._environmentBRDFTexture=To.GetEnvironmentBRDFTexture(this._scene));var z=this.reflection.isConnected?null===(i=this.reflection.connectedPoint)||void 0===i?void 0:i.ownerBlock:null;if(z&&(z.worldPositionConnectionPoint=this.worldPosition,z.cameraPositionConnectionPoint=this.cameraPosition,z.worldNormalConnectionPoint=this.worldNormal),t.target!==el.Fragment)return this._injectVertexCode(t),this;t.sharedData.bindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var G=\"//\"+this.name,j=\"v_\"+this.worldPosition.associatedVariableName,W=this.perturbedNormal;this._environmentBrdfSamplerName=t._getFreeVariableName(\"environmentBrdfSampler\"),t._emit2DSampler(this._environmentBrdfSamplerName),t.sharedData.hints.needAlphaBlending=t.sharedData.hints.needAlphaBlending||this.useAlphaBlending,t.sharedData.hints.needAlphaTesting=t.sharedData.hints.needAlphaTesting||this.useAlphaTest,t._emitExtension(\"lod\",\"#extension GL_EXT_shader_texture_lod : enable\",\"defined(LODBASEDMICROSFURACE)\"),t._emitExtension(\"derivatives\",\"#extension GL_OES_standard_derivatives : enable\"),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?\"lightUboDeclaration\":\"lightFragmentDeclaration\",G,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?\"lightUboDeclaration\":\"lightFragmentDeclaration\",G,{repeatKey:\"maxSimultaneousLights\"}),t._emitFunctionFromInclude(\"helperFunctions\",G),t._emitFunctionFromInclude(\"importanceSampling\",G),t._emitFunctionFromInclude(\"pbrHelperFunctions\",G),t._emitFunctionFromInclude(\"imageProcessingFunctions\",G),t._emitFunctionFromInclude(\"shadowsFragmentFunctions\",G,{replaceStrings:[{search:/vPositionW/g,replace:j+\".xyz\"}]}),t._emitFunctionFromInclude(\"pbrDirectLightingSetupFunctions\",G,{replaceStrings:[{search:/vPositionW/g,replace:j+\".xyz\"}]}),t._emitFunctionFromInclude(\"pbrDirectLightingFalloffFunctions\",G),t._emitFunctionFromInclude(\"pbrBRDFFunctions\",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(n=null==z?void 0:z._defineSkyboxName)&&void 0!==n?n:\"REFLECTIONMAP_SKYBOX\"}]}),t._emitFunctionFromInclude(\"hdrFilteringFunctions\",G),t._emitFunctionFromInclude(\"pbrDirectLightingFunctions\",G,{replaceStrings:[{search:/vPositionW/g,replace:j+\".xyz\"}]}),t._emitFunctionFromInclude(\"pbrIBLFunctions\",G),t._emitFunctionFromInclude(\"pbrBlockAlbedoOpacity\",G),t._emitFunctionFromInclude(\"pbrBlockReflectivity\",G),t._emitFunctionFromInclude(\"pbrBlockAmbientOcclusion\",G),t._emitFunctionFromInclude(\"pbrBlockAlphaFresnel\",G),t._emitFunctionFromInclude(\"pbrBlockAnisotropic\",G),t._emitUniformFromString(\"vLightingIntensity\",\"vec4\"),this._vNormalWName=t._getFreeVariableName(\"vNormalW\"),t.compilationString+=\"vec4 \"+this._vNormalWName+\" = normalize(\"+this.worldNormal.associatedVariableName+\");\\r\\n\",t._registerTempVariable(\"viewDirectionW\")&&(t.compilationString+=\"vec3 viewDirectionW = normalize(\"+this.cameraPosition.associatedVariableName+\" - \"+j+\".xyz);\\r\\n\"),t.compilationString+=\"vec3 geometricNormalW = \"+this._vNormalWName+\".xyz;\\r\\n\",t.compilationString+=\"vec3 normalW = \"+(W.isConnected?\"normalize(\"+W.associatedVariableName+\".xyz)\":\"geometricNormalW\")+\";\\r\\n\",this._invertNormalName=t._getFreeVariableName(\"invertNormal\"),t._emitUniformFromString(this._invertNormalName,\"float\"),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockNormalFinal\",G,{replaceStrings:[{search:/vPositionW/g,replace:j+\".xyz\"},{search:/vEyePosition.w/g,replace:this._invertNormalName}]}),t.compilationString+=this._getAlbedoOpacityCode(),t.compilationString+=t._emitCodeFromInclude(\"depthPrePass\",G),t.compilationString+=this._getAmbientOcclusionCode(),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockLightmapInit\",G),t.compilationString+=\"#ifdef UNLIT\\n vec3 diffuseBase = vec3(1., 1., 1.);\\n #else\\r\\n\",t.compilationString+=this._getReflectivityCode(t),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockGeometryInfo\",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(r=null==z?void 0:z._defineSkyboxName)&&void 0!==r?r:\"REFLECTIONMAP_SKYBOX\"},{search:/REFLECTIONMAP_3D/g,replace:null!==(o=null==z?void 0:z._define3DName)&&void 0!==o?o:\"REFLECTIONMAP_3D\"}]});var H=this.anisotropy.isConnected?null===(a=this.anisotropy.connectedPoint)||void 0===a?void 0:a.ownerBlock:null;H&&(H.worldPositionConnectionPoint=this.worldPosition,H.worldNormalConnectionPoint=this.worldNormal,t.compilationString+=H.getCode(t,!this.perturbedNormal.isConnected)),z&&z.hasTexture&&(t.compilationString+=z.getCode(t,H?\"anisotropicOut.anisotropicNormal\":\"normalW\")),t._emitFunctionFromInclude(\"pbrBlockReflection\",G,{replaceStrings:[{search:/computeReflectionCoords/g,replace:\"computeReflectionCoordsPBR\"},{search:/REFLECTIONMAP_3D/g,replace:null!==(s=null==z?void 0:z._define3DName)&&void 0!==s?s:\"REFLECTIONMAP_3D\"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(c=null==z?void 0:z._defineOppositeZ)&&void 0!==c?c:\"REFLECTIONMAP_OPPOSITEZ\"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(l=null==z?void 0:z._defineProjectionName)&&void 0!==l?l:\"REFLECTIONMAP_PROJECTION\"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(u=null==z?void 0:z._defineSkyboxName)&&void 0!==u?u:\"REFLECTIONMAP_SKYBOX\"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(h=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==h?h:\"LODINREFLECTIONALPHA\"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(d=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==d?d:\"LINEARSPECULARREFLECTION\"},{search:/vReflectionFilteringInfo/g,replace:null!==(f=null==z?void 0:z._vReflectionFilteringInfoName)&&void 0!==f?f:\"vReflectionFilteringInfo\"}]}),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockReflectance0\",G,{replaceStrings:[{search:/metallicReflectanceFactors/g,replace:this._vMetallicReflectanceFactorsName}]});var X=this.sheen.isConnected?null===(p=this.sheen.connectedPoint)||void 0===p?void 0:p.ownerBlock:null;X&&(t.compilationString+=X.getCode(z)),t._emitFunctionFromInclude(\"pbrBlockSheen\",G,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(_=null==z?void 0:z._define3DName)&&void 0!==_?_:\"REFLECTIONMAP_3D\"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(m=null==z?void 0:z._defineSkyboxName)&&void 0!==m?m:\"REFLECTIONMAP_SKYBOX\"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(g=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==g?g:\"LODINREFLECTIONALPHA\"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(v=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==v?v:\"LINEARSPECULARREFLECTION\"}]});var Y=this.clearcoat.isConnected?null===(b=this.clearcoat.connectedPoint)||void 0===b?void 0:b.ownerBlock:null,K=!this.perturbedNormal.isConnected&&!this.anisotropy.isConnected,Q=this.perturbedNormal.isConnected&&(null===(y=this.perturbedNormal.connectedPoint)||void 0===y?void 0:y.ownerBlock).worldTangent.isConnected,q=this.anisotropy.isConnected&&(null===(T=this.anisotropy.connectedPoint)||void 0===T?void 0:T.ownerBlock).worldTangent.isConnected,Z=Q||!this.perturbedNormal.isConnected&&q;t.compilationString+=ih.GetCode(t,Y,z,j,K,Z,this.worldNormal.associatedVariableName),K&&(Z=null!==(E=null==Y?void 0:Y.worldTangent.isConnected)&&void 0!==E&&E),t._emitFunctionFromInclude(\"pbrBlockClearcoat\",G,{replaceStrings:[{search:/computeReflectionCoords/g,replace:\"computeReflectionCoordsPBR\"},{search:/REFLECTIONMAP_3D/g,replace:null!==(S=null==z?void 0:z._define3DName)&&void 0!==S?S:\"REFLECTIONMAP_3D\"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(A=null==z?void 0:z._defineOppositeZ)&&void 0!==A?A:\"REFLECTIONMAP_OPPOSITEZ\"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(P=null==z?void 0:z._defineProjectionName)&&void 0!==P?P:\"REFLECTIONMAP_PROJECTION\"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(C=null==z?void 0:z._defineSkyboxName)&&void 0!==C?C:\"REFLECTIONMAP_SKYBOX\"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(R=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==R?R:\"LODINREFLECTIONALPHA\"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(x=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==x?x:\"LINEARSPECULARREFLECTION\"},{search:/defined\\(TANGENT\\)/g,replace:Z?\"defined(TANGENT)\":\"defined(IGNORE)\"}]}),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockReflectance\",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(O=null==z?void 0:z._defineSkyboxName)&&void 0!==O?O:\"REFLECTIONMAP_SKYBOX\"},{search:/REFLECTIONMAP_3D/g,replace:null!==(M=null==z?void 0:z._define3DName)&&void 0!==M?M:\"REFLECTIONMAP_3D\"}]});var J=this.subsurface.isConnected?null===(I=this.subsurface.connectedPoint)||void 0===I?void 0:I.ownerBlock:null,$=this.subsurface.isConnected?null===(N=(null===(D=this.subsurface.connectedPoint)||void 0===D?void 0:D.ownerBlock).refraction.connectedPoint)||void 0===N?void 0:N.ownerBlock:null;$&&($.viewConnectionPoint=this.view,$.indexOfRefractionConnectionPoint=this.indexOfRefraction),t.compilationString+=rh.GetCode(t,J,z,j),t._emitFunctionFromInclude(\"pbrBlockSubSurface\",G,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(L=null==z?void 0:z._define3DName)&&void 0!==L?L:\"REFLECTIONMAP_3D\"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(w=null==z?void 0:z._defineOppositeZ)&&void 0!==w?w:\"REFLECTIONMAP_OPPOSITEZ\"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(F=null==z?void 0:z._defineProjectionName)&&void 0!==F?F:\"REFLECTIONMAP_PROJECTION\"},{search:/SS_REFRACTIONMAP_3D/g,replace:null!==(B=null==$?void 0:$._define3DName)&&void 0!==B?B:\"SS_REFRACTIONMAP_3D\"},{search:/SS_LODINREFRACTIONALPHA/g,replace:null!==(U=null==$?void 0:$._defineLODRefractionAlpha)&&void 0!==U?U:\"SS_LODINREFRACTIONALPHA\"},{search:/SS_LINEARSPECULARREFRACTION/g,replace:null!==(V=null==$?void 0:$._defineLinearSpecularRefraction)&&void 0!==V?V:\"SS_LINEARSPECULARREFRACTION\"},{search:/SS_REFRACTIONMAP_OPPOSITEZ/g,replace:null!==(k=null==$?void 0:$._defineOppositeZ)&&void 0!==k?k:\"SS_REFRACTIONMAP_OPPOSITEZ\"}]}),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockDirectLighting\",G),this.light?t.compilationString+=t._emitCodeFromInclude(\"lightFragment\",G,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):t.compilationString+=t._emitCodeFromInclude(\"lightFragment\",G,{repeatKey:\"maxSimultaneousLights\"}),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockFinalLitComponents\",G),t.compilationString+=\"#endif\\r\\n\";var ee=this.ambientColor.isConnected?this.ambientColor.associatedVariableName:\"vec3(0., 0., 0.)\",te=_a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();-1===te.indexOf(\".\")&&(te+=\".\"),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockFinalUnlitComponents\",G,{replaceStrings:[{search:/vec3 finalEmissive[\\s\\S]*?finalEmissive\\*=vLightingIntensity\\.y;/g,replace:\"\"},{search:/vAmbientColor/g,replace:ee+\" * ambientFromScene\"},{search:/vAmbientInfos\\.w/g,replace:te}]}),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockFinalColorComposition\",G,{replaceStrings:[{search:/finalEmissive/g,replace:\"vec3(0.)\"}]}),t.compilationString+=t._emitCodeFromInclude(\"pbrBlockImageProcessing\",G,{replaceStrings:[{search:/visibility/g,replace:\"1.\"}]}),t.compilationString+=t._emitCodeFromInclude(\"pbrDebug\",G,{replaceStrings:[{search:/vNormalW/g,replace:this._vNormalWName},{search:/vPositionW/g,replace:j},{search:/albedoTexture\\.rgb;/g,replace:\"vec3(1.);\\r\\ngl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\\r\\n\"}]});for(var ie=0,ne=this._outputs;ie(\"+this._options.remappedVariables.join(\",\")+\")\":ai.a.IncludesShadersStore.shadowMapVertexNormalBias,u=this._options&&this._options.remappedVariables?\"#include(\"+this._options.remappedVariables.join(\",\")+\")\":ai.a.IncludesShadersStore.shadowMapVertexMetric,h=this._options&&this._options.remappedVariables?\"#include(\"+this._options.remappedVariables.join(\",\")+\")\":ai.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow,d=ai.a.IncludesShadersStore.shadowMapFragment;s=(s=-1!==(s=(s=s.replace(/void\\s+?main/g,ai.a.IncludesShadersStore.shadowMapVertexDeclaration+\"\\r\\nvoid main\")).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,l)).indexOf(\"#define SHADOWDEPTH_METRIC\")?s.replace(/#define SHADOWDEPTH_METRIC/g,u):s.replace(/}\\s*$/g,u+\"\\r\\n}\")).replace(/#define SHADER_NAME.*?\\n|out vec4 glFragColor;\\n/g,\"\");var f=c.indexOf(\"#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW\")>=0||c.indexOf(\"#define CUSTOM_FRAGMENT_BEFORE_FOG\")>=0,p=-1!==c.indexOf(\"#define SHADOWDEPTH_FRAGMENT\"),_=\"\";f?c=c.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,h):_=h+\"\\r\\n\",c=c.replace(/void\\s+?main/g,ai.a.IncludesShadersStore.shadowMapFragmentDeclaration+\"\\r\\nvoid main\"),p?c=c.replace(/#define SHADOWDEPTH_FRAGMENT/g,d):_+=d+\"\\r\\n\",_&&(c=c.replace(/}\\s*$/g,_+\"}\")),c=c.replace(/#define SHADER_NAME.*?\\n|out vec4 glFragColor;\\n/g,\"\");var m=r.getUniformNames().slice();return m.push(\"biasAndScaleSM\",\"depthValuesSM\",\"lightDataSM\",\"softTransparentShadowSM\"),o.depthEffect=this._scene.getEngine().createEffect({vertexSource:s,fragmentSource:c,vertexToken:o.token,fragmentToken:o.token},{attributes:r.getAttributesNames(),uniformsNames:m,uniformBuffersNames:r.getUniformBuffersNames(),samplers:r.getSamplers(),defines:a+\"\\n\"+r.defines.replace(\"#define SHADOWS\",\"\").replace(/#define SHADOW\\d/g,\"\"),indexParameters:r.getIndexParameters()},this._scene.getEngine()),o.depthEffect},e}(),dh=i(101);function fh(e,t,i,n,r){var o=new e.DecoderBuffer;o.Init(t,t.byteLength);var a,s,c=new e.Decoder;try{var l=c.GetEncodedGeometryType(o);switch(l){case e.TRIANGULAR_MESH:a=new e.Mesh,s=c.DecodeBufferToMesh(o,a);break;case e.POINT_CLOUD:a=new e.PointCloud,s=c.DecodeBufferToPointCloud(o,a);break;default:throw new Error(\"Invalid geometry type \"+l)}if(!s.ok()||!a.ptr)throw new Error(s.error_msg());if(l===e.TRIANGULAR_MESH){var u=3*a.num_faces(),h=4*u,d=e._malloc(h);try{c.GetTrianglesUInt32Array(a,h,d);var f=new Uint32Array(u);f.set(new Uint32Array(e.HEAPF32.buffer,d,u)),n(f)}finally{e._free(d)}}var p=function(t,i){var n=i.num_components(),o=a.num_points(),s=o*n,l=s*Float32Array.BYTES_PER_ELEMENT,u=e._malloc(l);try{c.GetAttributeDataArrayForAllPoints(a,i,e.DT_FLOAT32,l,u);var h=new Float32Array(e.HEAPF32.buffer,u,s);if(\"color\"===t&&3===n){for(var d=new Float32Array(4*o),f=0,p=0;fe.EPSILON?1:0;l|=h,u.push(h)}switch(l){case 0:(a.e.Dot(this.normal,t.plane.normal)>0?i:n).push(t);break;case 1:r.push(t);break;case 2:o.push(t);break;case 3:var d,f=[],p=[];for(s=0;s=3&&(d=new Th(f,t.shared)).plane&&r.push(d),p.length>=3&&(d=new Th(p,t.shared)).plane&&o.push(d)}},e.EPSILON=1e-5,e}(),Th=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=yh.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e}(),Eh=function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=new Array,e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map((function(e){return e.clone()})),t},e.prototype.invert=function(){for(var e=0;e1)?1:e.arc||1,c=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE;t.push(0,0,0),r.push(.5,.5);for(var l=2*Math.PI*s,u=1===s?l/a:l/(a-1),h=0,d=0;dt.x&&(t.x=i.x),i.yt.y&&(t.y=i.y)})),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}},e}(),Nh=function(){function e(){}return e.Rectangle=function(e,t,i,n){return[new a.d(e,t),new a.d(i,t),new a.d(i,n),new a.d(e,n)]},e.Circle=function(e,t,i,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=32);for(var r=new Array,o=0,s=2*Math.PI/n,c=0;c0){var u=r.length/3;this._points.elements.forEach((function(t){n.push(0,-1,0),r.push(t.x,-e,t.y),o.push(1-(t.x-a.min.x)/a.width,1-(t.y-a.min.y)/a.height)}));var h=s.length;for(l=0;lo.elements.length-1?o.elements[0]:o.elements[h+1],e.push(f.x,0,f.y),e.push(f.x,-s,f.y),e.push(d.x,0,d.y),e.push(d.x,-s,d.y);var p=new a.e(f.x,0,f.y),_=new a.e(d.x,0,d.y).subtract(p),m=new a.e(0,1,0),g=a.e.Cross(_,m);g=g.normalize(),i.push(u/r.width,0),i.push(u/r.width,1),u+=_.length(),i.push(u/r.width,0),i.push(u/r.width,1),c?(t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),n.push(l),n.push(l+2),n.push(l+1),n.push(l+1),n.push(l+2),n.push(l+3)):(t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),n.push(l),n.push(l+1),n.push(l+2),n.push(l+1),n.push(l+3),n.push(l+2)),l+=4}},e}();Ki.a.CreatePolygon=function(e,t,i,n,r,o,c){for(var l=i||new Array(3),u=n,h=[],d=c||!1,f=0;f<3;f++)void 0===l[f]&&(l[f]=new a.f(0,0,1,1)),u&&void 0===u[f]&&(u[f]=new s.b(1,1,1,1));var p=e.getVerticesData(Qi.b.PositionKind),_=e.getVerticesData(Qi.b.NormalKind),m=e.getVerticesData(Qi.b.UVKind),g=e.getIndices(),v=p.length/9,b=0,y=0,T=0,E=0,S=[0];if(d)for(var A=v;A1?1:t.arc:1,o=void 0===t.closed||t.closed,s=t.shape,c=t.radius||1,l=t.tessellation||64,u=t.clip||0,h=t.updatable,d=be.a._GetDefaultSideOrientation(t.sideOrientation),f=t.cap||be.a.NO_CAP,p=2*Math.PI,_=new Array,m=t.invertUV||!1,g=0,v=0,b=p/l*r,y=new Array;for(g=0;g<=l-u;g++){y=[];for(f!=be.a.CAP_START&&f!=be.a.CAP_ALL||(y.push(new a.e(0,s[0].y,0)),y.push(new a.e(Math.cos(g*b)*s[0].x*c,s[0].y,Math.sin(g*b)*s[0].x*c))),v=0;v0||h>0){m=-d,g=-f;v=d,b=f;switch(r){case be.a.CENTER:m-=c/=2,v+=c;break;case be.a.LEFT:v+=c,p=-c/2;break;case be.a.RIGHT:m-=c,p=c/2}switch(o){case be.a.CENTER:g-=h/=2,b+=h;break;case be.a.BOTTOM:b+=h,_=-h/2;break;case be.a.TOP:g-=h,_=h/2}}var y=[],T=[],E=[];E[0]=[0,0,1,0,1,1,0,1],E[1]=[0,0,1,0,1,1,0,1],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(E[1]=[1,1,0,1,0,0,1,0]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(E[1]=[1,0,0,0,0,1,1,1]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(E[1]=[0,1,1,1,1,0,0,0]);for(var S=[],A=[],P=[],C=0,R=0;R0||h>0){var O,M,I,D,N=h>0&&(o===be.a.CENTER||o===be.a.TOP),L=h>0&&(o===be.a.CENTER||o===be.a.BOTTOM),w=c>0&&(r===be.a.CENTER||r===be.a.RIGHT),F=c>0&&(r===be.a.CENTER||r===be.a.LEFT),B=[];if(N&&w&&(y.push(m+p,g+_,0),y.push(-d+p,g+_,0),y.push(-d+p,g+h+_,0),y.push(m+p,g+h+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=1-c/i,M=1-h/n,I=1,M,I,D=1,O,D],t===be.a.ROTATE_ROW&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t===be.a.FLIP_ROW&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),t===be.a.FLIP_N_ROTATE_ROW&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),N&&F&&(y.push(d+p,g+_,0),y.push(v+p,g+_,0),y.push(v+p,g+h+_,0),y.push(d+p,g+h+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=0,M=1-h/n,I=c/i,M,I,D=1,O,D],(t===be.a.ROTATE_ROW||t===be.a.ROTATE_TILE&&s%2==0)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW||t===be.a.FLIP_TILE&&s%2==0)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW||t===be.a.FLIP_N_ROTATE_TILE&&s%2==0)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&w&&(y.push(m+p,f+_,0),y.push(-d+p,f+_,0),y.push(-d+p,b+_,0),y.push(m+p,b+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=1-c/i,M=0,I=1,M,I,D=h/n,O,D],(t===be.a.ROTATE_ROW&&u%2==1||t===be.a.ROTATE_TILE&&u%1==0)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW&&u%2==1||t===be.a.FLIP_TILE&&u%2==0)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW&&u%2==1||t===be.a.FLIP_N_ROTATE_TILE&&u%2==0)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&F&&(y.push(d+p,f+_,0),y.push(v+p,f+_,0),y.push(v+p,b+_,0),y.push(d+p,b+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=0,M=0,I=c/i,M,I,D=h/n,O,D],(t===be.a.ROTATE_ROW&&u%2==1||t===be.a.ROTATE_TILE&&(u+s)%2==1)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW&&u%2==1||t===be.a.FLIP_TILE&&(u+s)%2==1)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW&&u%2==1||t===be.a.FLIP_N_ROTATE_TILE&&(u+s)%2==1)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),N){var U=[];O=0,M=1-h/n,I=1,D=1,U[0]=[O,M,I,M,I,D,O,D],U[1]=[O,M,I,M,I,D,O,D],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(U[1]=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(U[1]=[1-O,M,1-I,M,1-I,D,1-O,D]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(U[1]=[O,1-M,I,1-M,I,1-D,O,1-D]);for(x=0;x1)?1:t.arc||1;var f,p,_=function(e,t,i,n,r,o,s,c){for(var l,u,h,d,f=t.getTangents(),p=t.getNormals(),_=t.getDistances(),m=2*Math.PI/r*c,g=o||function(){return n},v=a.c.Matrix[0],b=s===be.a.NO_CAP||s===be.a.CAP_END?0:2,y=0;y3?0:l,t.arc);var v=Rh.a.CreateRibbon(e,{pathArray:p,closePath:!0,closeArray:!1,updatable:h,sideOrientation:d,invertUV:u,frontUVs:t.frontUVs,backUVs:t.backUVs},i);return v._creationDataStorage.pathArray=p,v._creationDataStorage.path3D=f,v._creationDataStorage.tessellation=s,v._creationDataStorage.cap=l,v._creationDataStorage.arc=t.arc,v._creationDataStorage.radius=o,v},e}();Ki.a.CreateIcoSphere=function(e){var t,i=e.sideOrientation||Ki.a.DEFAULTSIDE,n=e.radius||1,r=void 0===e.flat||e.flat,o=e.subdivisions||4,s=e.radiusX||n,c=e.radiusY||n,l=e.radiusZ||n,u=(1+Math.sqrt(5))/2,h=[-1,u,-0,1,u,0,-1,-u,0,1,-u,0,0,-1,-u,0,1,-u,0,-1,u,0,1,u,u,0,1,u,0,-1,-u,0,1,-u,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],f=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],p=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],_=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],m=new Array,g=new Array,v=new Array,b=new Array,y=0,T=new Array(3),E=new Array(3);for(t=0;t<3;t++)T[t]=a.e.Zero(),E[t]=a.d.Zero();for(var S=0;S<20;S++){for(t=0;t<3;t++){var A=d[3*S+t];T[t].copyFromFloats(h[3*f[A]],h[3*f[A]+1],h[3*f[A]+2]),T[t].normalize().scaleInPlace(n),E[t].copyFromFloats(p[2*A]*(138/1024)+60/1024+_[S]*(-40/1024),p[2*A+1]*(239/1024)+26/1024+_[S]*(20/1024))}for(var P=function(e,t,i,n){var u,h=a.e.Lerp(T[0],T[2],t/o),d=a.e.Lerp(T[1],T[2],t/o),f=o===t?T[2]:a.e.Lerp(h,d,e/(o-t));if(f.normalize(),r){var p=a.e.Lerp(T[0],T[2],n/o),_=a.e.Lerp(T[1],T[2],n/o);u=a.e.Lerp(p,_,i/(o-n))}else u=new a.e(f.x,f.y,f.z);u.x/=s,u.y/=c,u.z/=l,u.normalize();var S=a.d.Lerp(E[0],E[2],t/o),A=a.d.Lerp(E[1],E[2],t/o),P=o===t?E[2]:a.d.Lerp(S,A,e/(o-t));g.push(f.x*s,f.y*c,f.z*l),v.push(u.x,u.y,u.z),b.push(P.x,P.y),m.push(y),y++},C=0;C0)?1:0)+((c=a.e.Dot(e[o+1].position,t)-i>0)?1:0)+((u=a.e.Dot(e[o+2].position,t)-i>0)?1:0)){case 0:r.push(e[o]),r.push(e[o+1]),r.push(e[o+2]);break;case 1:if(s&&(h=e[o+1],d=e[o+2],f=n(e[o],h),p=n(e[o],d)),c){h=e[o],d=e[o+2],f=n(e[o+1],h),p=n(e[o+1],d),r.push(f),r.push(d.clone()),r.push(h.clone()),r.push(d.clone()),r.push(f.clone()),r.push(p);break}u&&(h=e[o],d=e[o+1],f=n(e[o+2],h),p=n(e[o+2],d)),h&&d&&f&&p&&(r.push(h.clone()),r.push(d.clone()),r.push(f),r.push(p),r.push(f.clone()),r.push(d.clone()));break;case 2:s||(d=n(h=e[o].clone(),e[o+1]),f=n(h,e[o+2]),r.push(h),r.push(d),r.push(f)),c||(d=n(h=e[o+1].clone(),e[o+2]),f=n(h,e[o]),r.push(h),r.push(d),r.push(f)),u||(d=n(h=e[o+2].clone(),e[o]),f=n(h,e[o+1]),r.push(h),r.push(d),r.push(f))}}return r},A=0;Ac||i.deleted||i.isDirty))for(var r=0;r<3;++r)if(i.error[r]>0,(function(e){if(r){var t=e+s.verticesStart,o=a.e.FromArray(r,3*t),l=function(e){if(i)for(var t=0;t0&&this._reconstructedMesh.setVerticesData(Qi.b.NormalKind,a),s.length>0&&this._reconstructedMesh.setVerticesData(Qi.b.UVKind,s),c.length>0&&this._reconstructedMesh.setVerticesData(Qi.b.ColorKind,c);var b=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],m.forEach((function(e){gh.a.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),gh.a.AddToMesh(b.materialIndex,_,d,p,3*r.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new be.a(this._mesh.name+\"Decimated\",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},e.prototype.isFlipped=function(e,t,i,n,r){for(var o=0;o.999)return!0;var f=a.e.Cross(h,d).normalize();if(n[o]=!1,a.e.Dot(f,s.normal)<.2)return!0}else n[o]=!0,r.push(s)}}return!1},e.prototype.updateTriangles=function(e,t,i,n){for(var r=n,o=0;o=this._thinInstanceDataStorage.instancesCount)return!1;var n=this._thinInstanceDataStorage.matrixData;return t.copyToArray(n,16*e),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[e]=t),i&&(this.thinInstanceBufferUpdated(\"matrix\"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0},be.a.prototype.thinInstanceSetAttributeAt=function(e,t,i,n){return void 0===n&&(n=!0),!(!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[e]||t>=this._thinInstanceDataStorage.instancesCount)&&(this._thinInstanceUpdateBufferSize(e,0),this._userThinInstanceBuffersStorage.data[e].set(i,t*this._userThinInstanceBuffersStorage.strides[e]),n&&this.thinInstanceBufferUpdated(e),!0)},Object.defineProperty(be.a.prototype,\"thinInstanceCount\",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(e){var t,i;e<=(null!==(i=null===(t=this._thinInstanceDataStorage.matrixData)||void 0===t?void 0:t.length)&&void 0!==i?i:0)/16&&(this._thinInstanceDataStorage.instancesCount=e)},enumerable:!0,configurable:!0}),be.a.prototype.thinInstanceSetBuffer=function(e,t,i,n){var r,o;if(void 0===i&&(i=0),void 0===n&&(n=!1),i=i||16,\"matrix\"===e)if(null===(r=this._thinInstanceDataStorage.matrixBuffer)||void 0===r||r.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=t?t.length:32*i,this._thinInstanceDataStorage.matrixData=t,this._thinInstanceDataStorage.worldMatrices=null,null!==t){this._thinInstanceDataStorage.instancesCount=t.length/i;var a=new Qi.a(this.getEngine(),t,!n,i,!1,!0);this._thinInstanceDataStorage.matrixBuffer=a,this.setVerticesBuffer(a.createVertexBuffer(\"world0\",0,4)),this.setVerticesBuffer(a.createVertexBuffer(\"world1\",4,4)),this.setVerticesBuffer(a.createVertexBuffer(\"world2\",8,4)),this.setVerticesBuffer(a.createVertexBuffer(\"world3\",12,4)),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)}else this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo(!0);else null===t?(null===(o=this._userThinInstanceBuffersStorage)||void 0===o?void 0:o.data[e])&&(this.removeVerticesData(e),delete this._userThinInstanceBuffersStorage.data[e],delete this._userThinInstanceBuffersStorage.strides[e],delete this._userThinInstanceBuffersStorage.sizes[e],delete this._userThinInstanceBuffersStorage.vertexBuffers[e]):(this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.data[e]=t,this._userThinInstanceBuffersStorage.strides[e]=i,this._userThinInstanceBuffersStorage.sizes[e]=t.length,this._userThinInstanceBuffersStorage.vertexBuffers[e]=new Qi.b(this.getEngine(),t,e,!n,!1,i,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e]))},be.a.prototype.thinInstanceBufferUpdated=function(e){var t;\"matrix\"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount):(null===(t=this._userThinInstanceBuffersStorage)||void 0===t?void 0:t.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e],0)},be.a.prototype.thinInstancePartialBufferUpdate=function(e,t,i){var n;\"matrix\"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t,i):(null===(n=this._userThinInstanceBuffersStorage)||void 0===n?void 0:n.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t,i)},be.a.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];var e=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=new Array;for(var t=0;t-1&&(this.agents.splice(t,1),this.transforms.splice(t,1))},e.prototype.getAgents=function(){return this.agents},e.prototype.update=function(e){var t=this.bjsRECASTPlugin.getTimeStep(),i=this.bjsRECASTPlugin.getMaximumSubStepCount();if(t<=Nt.a)this.recastCrowd.update(e);else{var n=e/t;i&&n>i&&(n=i),n<1&&(n=1);for(var r=0;r=400&&o?o(l):i()}),!1),l.addEventListener(\"error\",(function(){m.a.Error(\"error on XHR request.\"),i()}),!1),l.send()}else m.a.Error(\"Error: IndexedDB not supported by your browser or Babylon.js database is not open.\"),i()},e._ValidateXHRData=function(e,t){void 0===t&&(t=7);try{if(1&t){if(e.responseText&&e.responseText.length>0)return!0;if(1===t)return!1}if(2&t){var i=Uc.GetTGAHeader(e.response);if(i.width&&i.height&&i.width>0&&i.height>0)return!0;if(2===t)return!1}if(4&t){var n=new Uint8Array(e.response,0,3);return 68===n[0]&&68===n[1]&&83===n[2]}}catch(e){}return!1},e.IsUASupportingBlobStorage=!0,e.IDBStorageEnabled=!1,e._ParseURL=function(e){document.createElement(\"a\").href=e;var t=e.substring(0,e.lastIndexOf(\"#\")),i=e.substring(t.lastIndexOf(\"/\")+1,e.length);return e.substring(0,e.indexOf(i,0))},e._ReturnFullUrlLocation=function(t){return-1===t.indexOf(\"http:/\")&&-1===t.indexOf(\"https:/\")&&\"undefined\"!=typeof window?e._ParseURL(window.location.href)+t:t},e}(),rd=function(){function e(e,t,i){this.gradient=e,this.color1=t,this.color2=i}return e.prototype.getColorToRef=function(e){this.color2?s.b.LerpToRef(this.color1,this.color2,Math.random(),e):e.copyFrom(this.color1)},e}(),od=function(e,t){this.gradient=e,this.color=t},ad=function(){function e(e,t,i){this.gradient=e,this.factor1=t,this.factor2=i}return e.prototype.getFactor=function(){return void 0===this.factor2||this.factor2===this.factor1?this.factor1:this.factor1+(this.factor2-this.factor1)*Math.random()},e}(),sd=function(){function e(){}return e.GetCurrentGradient=function(e,t,i){if(t[0].gradient>e)i(t[0],t[0],1);else{for(var n=0;n=r.gradient&&e<=o.gradient)return void i(r,o,(e-r.gradient)/(o.gradient-r.gradient))}var a=t.length-1;i(t[a],t[a],1)}},e}(),cd=function(){function e(t){this.particleSystem=t,this.position=a.e.Zero(),this.direction=a.e.Zero(),this.color=new s.b(0,0,0,0),this.colorStep=new s.b(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new a.d(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new s.b(0,0,0,0),this._currentColor2=new s.b(0,0,0,0),this._currentSize1=0,this._currentSize2=0,this._currentAngularSpeed1=0,this._currentAngularSpeed2=0,this._currentVelocity1=0,this._currentVelocity2=0,this._currentLimitVelocity1=0,this._currentLimitVelocity2=0,this._currentDrag1=0,this._currentDrag2=0,this.id=e._Count++,this.particleSystem.isAnimationSheetEnabled&&this.updateCellInfoFromSystem()}return e.prototype.updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID},e.prototype.updateCellIndex=function(){var e=this.age,t=this.particleSystem.spriteCellChangeSpeed;this.particleSystem.spriteRandomStartCell&&(void 0===this._randomCellOffset&&(this._randomCellOffset=Math.random()*this.lifeTime),0===t?(t=1,e=this._randomCellOffset):e+=this._randomCellOffset);var i=this._initialEndSpriteCellID-this._initialStartSpriteCellID,n=L.a.Clamp(e*t%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+n*i|0},e.prototype._inheritParticleInfoToSubEmitter=function(e){if(e.particleSystem.emitter.position){var t=e.particleSystem.emitter;if(t.position.copyFrom(this.position),e.inheritDirection){var i=a.c.Vector3[0];this.direction.normalizeToRef(i),t.setDirection(i,0,Math.PI/2)}}else{e.particleSystem.emitter.copyFrom(this.position)}this.direction.scaleToRef(e.inheritedVelocityAmount/2,a.c.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(a.c.Vector3[0])},e.prototype._inheritParticleInfoToSubEmitters=function(){var e=this;this._attachedSubEmitters&&this._attachedSubEmitters.length>0&&this._attachedSubEmitters.forEach((function(t){e._inheritParticleInfoToSubEmitter(t)}))},e.prototype._reset=function(){this.age=0,this.id=e._Count++,this._currentColorGradient=null,this._currentSizeGradient=null,this._currentAngularSpeedGradient=null,this._currentVelocityGradient=null,this._currentLimitVelocityGradient=null,this._currentDragGradient=null,this.cellIndex=this.particleSystem.startSpriteCellID,this._randomCellOffset=void 0},e.prototype.copyTo=function(e){e.position.copyFrom(this.position),this._initialDirection?e._initialDirection?e._initialDirection.copyFrom(this._initialDirection):e._initialDirection=this._initialDirection.clone():e._initialDirection=null,e.direction.copyFrom(this.direction),this._localPosition&&(e._localPosition?e._localPosition.copyFrom(this._localPosition):e._localPosition=this._localPosition.clone()),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e._randomCellOffset=this._randomCellOffset,e.size=this.size,e.scale.copyFrom(this.scale),e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex,e.id=this.id,e._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(e._currentColorGradient=this._currentColorGradient,e._currentColor1.copyFrom(this._currentColor1),e._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(e._currentSizeGradient=this._currentSizeGradient,e._currentSize1=this._currentSize1,e._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(e._currentAngularSpeedGradient=this._currentAngularSpeedGradient,e._currentAngularSpeed1=this._currentAngularSpeed1,e._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(e._currentVelocityGradient=this._currentVelocityGradient,e._currentVelocity1=this._currentVelocity1,e._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(e._currentLimitVelocityGradient=this._currentLimitVelocityGradient,e._currentLimitVelocity1=this._currentLimitVelocity1,e._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(e._currentDragGradient=this._currentDragGradient,e._currentDrag1=this._currentDrag1,e._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(e._initialStartSpriteCellID=this._initialStartSpriteCellID,e._initialEndSpriteCellID=this._initialEndSpriteCellID),this.particleSystem.useRampGradients&&(e.remapData&&this.remapData?e.remapData.copyFrom(this.remapData):e.remapData=new a.f(0,0,0,0)),this._randomNoiseCoordinates1&&(e._randomNoiseCoordinates1?(e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)):(e._randomNoiseCoordinates1=this._randomNoiseCoordinates1.clone(),e._randomNoiseCoordinates2=this._randomNoiseCoordinates2.clone()))},e._Count=0,e}();!function(e){e[e.ATTACHED=0]=\"ATTACHED\",e[e.END=1]=\"END\"}(id||(id={}));var ld=function(){function e(e){if(this.particleSystem=e,this.type=id.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,!e.emitter||!e.emitter.dispose){var t=c.a.GetClass(\"BABYLON.AbstractMesh\");e.emitter=new t(\"SubemitterSystemEmitter\",e.getScene())}e.onDisposeObservable.add((function(){e.emitter&&e.emitter.dispose&&e.emitter.dispose()}))}return e.prototype.clone=function(){var t=this.particleSystem.emitter;if(t){if(t instanceof a.e)t=t.clone();else if(-1!==t.getClassName().indexOf(\"Mesh\")){(t=new(c.a.GetClass(\"BABYLON.Mesh\"))(\"\",t.getScene())).isVisible=!1}}else t=new a.e;var i=new e(this.particleSystem.clone(\"\",t));return i.particleSystem.name+=\"Clone\",i.type=this.type,i.inheritDirection=this.inheritDirection,i.inheritedVelocityAmount=this.inheritedVelocityAmount,i.particleSystem._disposeEmitterOnDispose=!0,i.particleSystem.disposeOnStop=!0,i},e.prototype.serialize=function(){var e={};return e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem=this.particleSystem.serialize(),e},e._ParseParticleSystem=function(e,t,i){throw Re.a.WarnImport(\"ParseParticle\")},e.Parse=function(t,i,n){var r=t.particleSystem,o=new e(e._ParseParticleSystem(r,i,n));return o.type=t.type,o.inheritDirection=t.inheritDirection,o.inheritedVelocityAmount=t.inheritedVelocityAmount,o.particleSystem._isSubEmitter=!0,o},e.prototype.dispose=function(){this.particleSystem.dispose()},e}(),ud=\"\\nvarying vec2 vUV;\\nvarying vec4 vColor;\\nuniform vec4 textureMask;\\nuniform sampler2D diffuseSampler;\\n#include\\n#include\\n#include\\n#include\\n#ifdef RAMPGRADIENT\\nvarying vec4 remapRanges;\\nuniform sampler2D rampSampler;\\n#endif\\nvoid main(void) {\\n#include\\nvec4 textureColor=texture2D(diffuseSampler,vUV);\\nvec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\\n#ifdef RAMPGRADIENT\\nfloat alpha=baseColor.a;\\nfloat remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);\\nvec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));\\nbaseColor.rgb*=rampColor.rgb;\\n\\nfloat finalAlpha=baseColor.a;\\nbaseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\\n#endif\\n#ifdef BLENDMULTIPLYMODE\\nfloat sourceAlpha=vColor.a*textureColor.a;\\nbaseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\\n#endif\\n\\n\\n#ifdef IMAGEPROCESSINGPOSTPROCESS\\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\\n#else\\n#ifdef IMAGEPROCESSING\\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\\nbaseColor=applyImageProcessing(baseColor);\\n#endif\\n#endif\\ngl_FragColor=baseColor;\\n}\";ai.a.ShadersStore.particlesPixelShader=ud;var hd=\"\\nattribute vec3 position;\\nattribute vec4 color;\\nattribute float angle;\\nattribute vec2 size;\\n#ifdef ANIMATESHEET\\nattribute float cellIndex;\\n#endif\\n#ifndef BILLBOARD\\nattribute vec3 direction;\\n#endif\\n#ifdef BILLBOARDSTRETCHED\\nattribute vec3 direction;\\n#endif\\n#ifdef RAMPGRADIENT\\nattribute vec4 remapData;\\n#endif\\nattribute vec2 offset;\\n\\nuniform mat4 view;\\nuniform mat4 projection;\\nuniform vec2 translationPivot;\\n#ifdef ANIMATESHEET\\nuniform vec3 particlesInfos;\\n#endif\\n\\nvarying vec2 vUV;\\nvarying vec4 vColor;\\nvarying vec3 vPositionW;\\n#ifdef RAMPGRADIENT\\nvarying vec4 remapRanges;\\n#endif\\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\\nuniform mat4 invView;\\n#endif\\n#include\\n#ifdef BILLBOARD\\nuniform vec3 eyePosition;\\n#endif\\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\\nvec3 zaxis=normalize(cross(yaxis,xaxis));\\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\\nmat3 rotMatrix=mat3(row0,row1,row2);\\nvec3 alignedCorner=rotMatrix*rotatedCorner;\\nreturn position+alignedCorner;\\n}\\n#ifdef BILLBOARDSTRETCHED\\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\\nvec3 normalizedToCamera=normalize(toCamera);\\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\\nmat3 rotMatrix=mat3(row0,row1,row2);\\nvec3 alignedCorner=rotMatrix*rotatedCorner;\\nreturn position+alignedCorner;\\n}\\n#endif\\nvoid main(void) {\\nvec2 cornerPos;\\ncornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\\n#ifdef BILLBOARD\\n\\nvec3 rotatedCorner;\\n#ifdef BILLBOARDY\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nrotatedCorner.y=0.;\\nvec3 yaxis=position-eyePosition;\\nyaxis.y=0.;\\nvPositionW=rotate(normalize(yaxis),rotatedCorner);\\nvec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\\n#elif defined(BILLBOARDSTRETCHED)\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nrotatedCorner.z=0.;\\nvec3 toCamera=position-eyePosition;\\nvPositionW=rotateAlign(toCamera,rotatedCorner);\\nvec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\\n#else\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nrotatedCorner.z=0.;\\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\\nvPositionW=(invView*vec4(viewPos,1)).xyz;\\n#endif\\n#ifdef RAMPGRADIENT\\nremapRanges=remapData;\\n#endif\\n\\ngl_Position=projection*vec4(viewPos,1.0);\\n#else\\n\\nvec3 rotatedCorner;\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nrotatedCorner.y=0.;\\nvec3 yaxis=normalize(direction);\\nvPositionW=rotate(yaxis,rotatedCorner);\\ngl_Position=projection*view*vec4(vPositionW,1.0);\\n#endif\\nvColor=color;\\n#ifdef ANIMATESHEET\\nfloat rowOffset=floor(cellIndex*particlesInfos.z);\\nfloat columnOffset=cellIndex-rowOffset/particlesInfos.z;\\nvec2 uvScale=particlesInfos.xy;\\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\\n#else\\nvUV=offset;\\n#endif\\n\\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\\nvec4 worldPos=vec4(vPositionW,1.0);\\n#endif\\n#include\\n}\";ai.a.ShadersStore.particlesVertexShader=hd;var dd=function(e){function t(t,i,n,r,c,l){void 0===r&&(r=null),void 0===c&&(c=!1),void 0===l&&(l=.01);var u=e.call(this,t)||this;return u._inheritedVelocityOffset=new a.e,u.onDisposeObservable=new o.c,u.onStoppedObservable=new o.c,u._particles=new Array,u._stockParticles=new Array,u._newPartsExcess=0,u._vertexBuffers={},u._scaledColorStep=new s.b(0,0,0,0),u._colorDiff=new s.b(0,0,0,0),u._scaledDirection=a.e.Zero(),u._scaledGravity=a.e.Zero(),u._currentRenderId=-1,u._useInstancing=!1,u._started=!1,u._stopped=!1,u._actualFrame=0,u._currentEmitRate1=0,u._currentEmitRate2=0,u._currentStartSize1=0,u._currentStartSize2=0,u._rawTextureWidth=256,u._useRampGradients=!1,u._disposeEmitterOnDispose=!1,u.isLocal=!1,u._onBeforeDrawParticlesObservable=null,u.recycleParticle=function(e){var t=u._particles.pop();t!==e&&t.copyTo(e),u._stockParticles.push(t)},u._createParticle=function(){var e;if(0!==u._stockParticles.length?(e=u._stockParticles.pop())._reset():e=new cd(u),u._subEmitters&&u._subEmitters.length>0){var t=u._subEmitters[Math.floor(Math.random()*u._subEmitters.length)];e._attachedSubEmitters=[],t.forEach((function(t){if(t.type===id.ATTACHED){var i=t.clone();e._attachedSubEmitters.push(i),i.particleSystem.start()}}))}return e},u._emitFromParticle=function(e){if(u._subEmitters&&0!==u._subEmitters.length){var t=Math.floor(Math.random()*u._subEmitters.length);u._subEmitters[t].forEach((function(t){if(t.type===id.END){var i=t.clone();e._inheritParticleInfoToSubEmitter(i),i.particleSystem._rootParticleSystem=u,u.activeSubSystems.push(i.particleSystem),i.particleSystem.start()}}))}},u._capacity=i,u._epsilon=l,u._isAnimationSheetEnabled=c,n&&\"Scene\"!==n.getClassName()?(u._engine=n,u.defaultProjectionMatrix=a.a.PerspectiveFovLH(.8,1,.1,100)):(u._scene=n||x.a.LastCreatedScene,u._engine=u._scene.getEngine(),u.uniqueId=u._scene.getUniqueId(),u._scene.particleSystems.push(u)),u._engine.getCaps().vertexArrayObject&&(u._vertexArrayObject=null),u._attachImageProcessingConfiguration(null),u._customEffect={0:r},u._useInstancing=u._engine.getCaps().instancedArrays,u._createIndexBuffer(),u._createVertexBuffers(),u.particleEmitterType=new Nl,u.updateFunction=function(e){var t=null,i=null;u.noiseTexture&&(t=u.noiseTexture.getSize(),i=u.noiseTexture.getContent());for(var n,r=function(){n=e[o];var r=u._scaledUpdateSpeed,c=n.age;if(n.age+=r,n.age>n.lifeTime){var l=n.age-c;r=(n.lifeTime-c)*r/l,n.age=n.lifeTime}var h=n.age/n.lifeTime;u._colorGradients&&u._colorGradients.length>0?sd.GetCurrentGradient(h,u._colorGradients,(function(e,t,i){e!==n._currentColorGradient&&(n._currentColor1.copyFrom(n._currentColor2),t.getColorToRef(n._currentColor2),n._currentColorGradient=e),s.b.LerpToRef(n._currentColor1,n._currentColor2,i,n.color)})):(n.colorStep.scaleToRef(r,u._scaledColorStep),n.color.addInPlace(u._scaledColorStep),n.color.a<0&&(n.color.a=0)),u._angularSpeedGradients&&u._angularSpeedGradients.length>0&&sd.GetCurrentGradient(h,u._angularSpeedGradients,(function(e,t,i){e!==n._currentAngularSpeedGradient&&(n._currentAngularSpeed1=n._currentAngularSpeed2,n._currentAngularSpeed2=t.getFactor(),n._currentAngularSpeedGradient=e),n.angularSpeed=L.a.Lerp(n._currentAngularSpeed1,n._currentAngularSpeed2,i)})),n.angle+=n.angularSpeed*r;var d=r;if(u._velocityGradients&&u._velocityGradients.length>0&&sd.GetCurrentGradient(h,u._velocityGradients,(function(e,t,i){e!==n._currentVelocityGradient&&(n._currentVelocity1=n._currentVelocity2,n._currentVelocity2=t.getFactor(),n._currentVelocityGradient=e),d*=L.a.Lerp(n._currentVelocity1,n._currentVelocity2,i)})),n.direction.scaleToRef(d,u._scaledDirection),u._limitVelocityGradients&&u._limitVelocityGradients.length>0&&sd.GetCurrentGradient(h,u._limitVelocityGradients,(function(e,t,i){e!==n._currentLimitVelocityGradient&&(n._currentLimitVelocity1=n._currentLimitVelocity2,n._currentLimitVelocity2=t.getFactor(),n._currentLimitVelocityGradient=e);var r=L.a.Lerp(n._currentLimitVelocity1,n._currentLimitVelocity2,i);n.direction.length()>r&&n.direction.scaleInPlace(u.limitVelocityDamping)})),u._dragGradients&&u._dragGradients.length>0&&sd.GetCurrentGradient(h,u._dragGradients,(function(e,t,i){e!==n._currentDragGradient&&(n._currentDrag1=n._currentDrag2,n._currentDrag2=t.getFactor(),n._currentDragGradient=e);var r=L.a.Lerp(n._currentDrag1,n._currentDrag2,i);u._scaledDirection.scaleInPlace(1-r)})),u.isLocal&&n._localPosition?(n._localPosition.addInPlace(u._scaledDirection),a.e.TransformCoordinatesToRef(n._localPosition,u._emitterWorldMatrix,n.position)):n.position.addInPlace(u._scaledDirection),i&&t&&n._randomNoiseCoordinates1){var f=u._fetchR(n._randomNoiseCoordinates1.x,n._randomNoiseCoordinates1.y,t.width,t.height,i),p=u._fetchR(n._randomNoiseCoordinates1.z,n._randomNoiseCoordinates2.x,t.width,t.height,i),_=u._fetchR(n._randomNoiseCoordinates2.y,n._randomNoiseCoordinates2.z,t.width,t.height,i),m=a.c.Vector3[0],g=a.c.Vector3[1];m.copyFromFloats((2*f-1)*u.noiseStrength.x,(2*p-1)*u.noiseStrength.y,(2*_-1)*u.noiseStrength.z),m.scaleToRef(r,g),n.direction.addInPlace(g)}if(u.gravity.scaleToRef(r,u._scaledGravity),n.direction.addInPlace(u._scaledGravity),u._sizeGradients&&u._sizeGradients.length>0&&sd.GetCurrentGradient(h,u._sizeGradients,(function(e,t,i){e!==n._currentSizeGradient&&(n._currentSize1=n._currentSize2,n._currentSize2=t.getFactor(),n._currentSizeGradient=e),n.size=L.a.Lerp(n._currentSize1,n._currentSize2,i)})),u._useRampGradients&&(u._colorRemapGradients&&u._colorRemapGradients.length>0&&sd.GetCurrentGradient(h,u._colorRemapGradients,(function(e,t,i){var r=L.a.Lerp(e.factor1,t.factor1,i),o=L.a.Lerp(e.factor2,t.factor2,i);n.remapData.x=r,n.remapData.y=o-r})),u._alphaRemapGradients&&u._alphaRemapGradients.length>0&&sd.GetCurrentGradient(h,u._alphaRemapGradients,(function(e,t,i){var r=L.a.Lerp(e.factor1,t.factor1,i),o=L.a.Lerp(e.factor2,t.factor2,i);n.remapData.z=r,n.remapData.w=o-r}))),u._isAnimationSheetEnabled&&n.updateCellIndex(),n._inheritParticleInfoToSubEmitters(),n.age>=n.lifeTime)return u._emitFromParticle(n),n._attachedSubEmitters&&(n._attachedSubEmitters.forEach((function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()})),n._attachedSubEmitters=null),u.recycleParticle(n),o--,\"continue\"},o=0;ot.gradient?1:0}))},t.prototype._removeFactorGradient=function(e,t){if(e)for(var i=0,n=0,r=e;nt.gradient?1:0})),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture())},t.prototype.addRampGradient=function(e,t){this._rampGradients||(this._rampGradients=[]);var i=new od(e,t);return this._rampGradients.push(i),this._syncRampGradientTexture(),this},t.prototype.removeRampGradient=function(e){return this._removeGradientAndTexture(e,this._rampGradients,this._rampGradientsTexture),this._rampGradientsTexture=null,this._rampGradients&&this._rampGradients.length>0&&this._createRampGradientTexture(),this},t.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var n=new rd(e,t,i);return this._colorGradients.push(n),this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var t=0,i=0,n=this._colorGradients;i0&&(this._currentEmitRateGradient=this._emitRateGradients[0],this._currentEmitRate1=this._currentEmitRateGradient.getFactor(),this._currentEmitRate2=this._currentEmitRate1),this._emitRateGradients.length>1&&(this._currentEmitRate2=this._emitRateGradients[1].getFactor())),this._startSizeGradients&&(this._startSizeGradients.length>0&&(this._currentStartSizeGradient=this._startSizeGradients[0],this._currentStartSize1=this._currentStartSizeGradient.getFactor(),this._currentStartSize2=this._currentStartSize1),this._startSizeGradients.length>1&&(this._currentStartSize2=this._startSizeGradients[1].getFactor())),this.preWarmCycles){-1!==(null===(t=this.emitter)||void 0===t?void 0:t.getClassName().indexOf(\"Mesh\"))&&this.emitter.computeWorldMatrix(!0);var n=this.noiseTexture;if(n&&n.onGeneratedObservable)n.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped||(this.onStoppedObservable.notifyObservers(this),this._stopped=!0,e&&this._stopSubEmitters())},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},t.prototype._appendParticleVertex=function(e,i,n,r){var o=e*this._vertexBufferSize;if(this._vertexData[o++]=i.position.x+this.worldOffset.x,this._vertexData[o++]=i.position.y+this.worldOffset.y,this._vertexData[o++]=i.position.z+this.worldOffset.z,this._vertexData[o++]=i.color.r,this._vertexData[o++]=i.color.g,this._vertexData[o++]=i.color.b,this._vertexData[o++]=i.color.a,this._vertexData[o++]=i.angle,this._vertexData[o++]=i.scale.x*i.size,this._vertexData[o++]=i.scale.y*i.size,this._isAnimationSheetEnabled&&(this._vertexData[o++]=i.cellIndex),this._isBillboardBased)this.billboardMode===t.BILLBOARDMODE_STRETCHED&&(this._vertexData[o++]=i.direction.x,this._vertexData[o++]=i.direction.y,this._vertexData[o++]=i.direction.z);else if(i._initialDirection){var s=i._initialDirection;this.isLocal&&(a.e.TransformNormalToRef(s,this._emitterWorldMatrix,a.c.Vector3[0]),s=a.c.Vector3[0]),0===s.x&&0===s.z&&(s.x=.001),this._vertexData[o++]=s.x,this._vertexData[o++]=s.y,this._vertexData[o++]=s.z}else{var c=i.direction;this.isLocal&&(a.e.TransformNormalToRef(c,this._emitterWorldMatrix,a.c.Vector3[0]),c=a.c.Vector3[0]),0===c.x&&0===c.z&&(c.x=.001),this._vertexData[o++]=c.x,this._vertexData[o++]=c.y,this._vertexData[o++]=c.z}this._useRampGradients&&i.remapData&&(this._vertexData[o++]=i.remapData.x,this._vertexData[o++]=i.remapData.y,this._vertexData[o++]=i.remapData.z,this._vertexData[o++]=i.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(0===n?n=this._epsilon:1===n&&(n=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon)),this._vertexData[o++]=n,this._vertexData[o++]=r)},t.prototype._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach((function(e){e.stop(!0)})),this.activeSubSystems=new Array)},t.prototype._removeFromRoot=function(){if(this._rootParticleSystem){var e=this._rootParticleSystem.activeSubSystems.indexOf(this);-1!==e&&this._rootParticleSystem.activeSubSystems.splice(e,1),this._rootParticleSystem=null}},t.prototype._update=function(e){var t,i=this;if(this._alive=this._particles.length>0,this.emitter.position){var n=this.emitter;this._emitterWorldMatrix=n.getWorldMatrix()}else{var r=this.emitter;this._emitterWorldMatrix=a.a.Translation(r.x,r.y,r.z)}this.updateFunction(this._particles);for(var o,c=function(){if(l._particles.length===l._capacity)return\"break\";if(t=l._createParticle(),l._particles.push(t),l.targetStopDuration&&l._lifeTimeGradients&&l._lifeTimeGradients.length>0){var e=L.a.Clamp(l._actualFrame/l.targetStopDuration);sd.GetCurrentGradient(e,l._lifeTimeGradients,(function(i,n){var r=i,o=n,a=r.getFactor(),s=o.getFactor(),c=(e-r.gradient)/(o.gradient-r.gradient);t.lifeTime=L.a.Lerp(a,s,c)}))}else t.lifeTime=L.a.RandomRange(l.minLifeTime,l.maxLifeTime);var n=L.a.RandomRange(l.minEmitPower,l.maxEmitPower);if(l.startPositionFunction?l.startPositionFunction(l._emitterWorldMatrix,t.position,t,l.isLocal):l.particleEmitterType.startPositionFunction(l._emitterWorldMatrix,t.position,t,l.isLocal),l.isLocal&&(t._localPosition?t._localPosition.copyFrom(t.position):t._localPosition=t.position.clone(),a.e.TransformCoordinatesToRef(t._localPosition,l._emitterWorldMatrix,t.position)),l.startDirectionFunction?l.startDirectionFunction(l._emitterWorldMatrix,t.direction,t,l.isLocal):l.particleEmitterType.startDirectionFunction(l._emitterWorldMatrix,t.direction,t,l.isLocal),0===n?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(n),l._sizeGradients&&0!==l._sizeGradients.length?(t._currentSizeGradient=l._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,l._sizeGradients.length>1?t._currentSize2=l._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=L.a.RandomRange(l.minSize,l.maxSize),t.scale.copyFromFloats(L.a.RandomRange(l.minScaleX,l.maxScaleX),L.a.RandomRange(l.minScaleY,l.maxScaleY)),l._startSizeGradients&&l._startSizeGradients[0]&&l.targetStopDuration){var r=l._actualFrame/l.targetStopDuration;sd.GetCurrentGradient(r,l._startSizeGradients,(function(e,n,r){e!==i._currentStartSizeGradient&&(i._currentStartSize1=i._currentStartSize2,i._currentStartSize2=n.getFactor(),i._currentStartSizeGradient=e);var o=L.a.Lerp(i._currentStartSize1,i._currentStartSize2,r);t.scale.scaleInPlace(o)}))}l._angularSpeedGradients&&0!==l._angularSpeedGradients.length?(t._currentAngularSpeedGradient=l._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,l._angularSpeedGradients.length>1?t._currentAngularSpeed2=l._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=L.a.RandomRange(l.minAngularSpeed,l.maxAngularSpeed),t.angle=L.a.RandomRange(l.minInitialRotation,l.maxInitialRotation),l._velocityGradients&&l._velocityGradients.length>0&&(t._currentVelocityGradient=l._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),l._velocityGradients.length>1?t._currentVelocity2=l._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=l._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),l._limitVelocityGradients.length>1?t._currentLimitVelocity2=l._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),l._dragGradients&&l._dragGradients.length>0&&(t._currentDragGradient=l._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),l._dragGradients.length>1?t._currentDrag2=l._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),l._colorGradients&&0!==l._colorGradients.length?(t._currentColorGradient=l._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),l._colorGradients.length>1?l._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color)):(o=L.a.RandomRange(0,1),s.b.LerpToRef(l.color1,l.color2,o,t.color),l.colorDead.subtractToRef(t.color,l._colorDiff),l._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)),l._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=l.startSpriteCellID,t._initialEndSpriteCellID=l.endSpriteCellID),t.direction.addInPlace(l._inheritedVelocityOffset),l._useRampGradients&&(t.remapData=new a.f(0,1,0,1)),l.noiseTexture&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(t._randomNoiseCoordinates1=new a.e(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new a.e(Math.random(),Math.random(),Math.random()))),t._inheritParticleInfoToSubEmitters()},l=this,u=0;u-1)n=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var r=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var o=this._actualFrame/this.targetStopDuration;sd.GetCurrentGradient(o,this._emitRateGradients,(function(e,t,n){e!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=t.getFactor(),i._currentEmitRateGradient=e),r=L.a.Lerp(i._currentEmitRate1,i._currentEmitRate2,n)}))}n=r*this._scaledUpdateSpeed>>0,this._newPartsExcess+=r*this._scaledUpdateSpeed-n}if(this._newPartsExcess>1&&(n+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?n=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(n),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene&&this._scene._toBeDisposed.push(this))),!e){for(var a=0,s=0;s=0&&(s.invertToRef(a.c.Matrix[0]),r.setMatrix(\"invView\",a.c.Matrix[0])),void 0!==this._vertexArrayObject?(this._vertexArrayObject||(this._vertexArrayObject=this._engine.recordVertexArrayObject(this._vertexBuffers,this._indexBuffer,r)),this._engine.bindVertexArrayObject(this._vertexArrayObject,this._indexBuffer)):o.bindBuffers(this._vertexBuffers,this._indexBuffer,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(r),e){case t.BLENDMODE_ADD:o.setAlphaMode(g.a.ALPHA_ADD);break;case t.BLENDMODE_ONEONE:o.setAlphaMode(g.a.ALPHA_ONEONE);break;case t.BLENDMODE_STANDARD:o.setAlphaMode(g.a.ALPHA_COMBINE);break;case t.BLENDMODE_MULTIPLY:o.setAlphaMode(g.a.ALPHA_MULTIPLY)}return this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(r),this._useInstancing?o.drawArraysType(g.a.MATERIAL_TriangleFanDrawMode,0,4,this._particles.length):o.drawElementsType(g.a.MATERIAL_TriangleFillMode,0,6*this._particles.length),this._particles.length},t.prototype.render=function(){if(!this.isReady()||!this._particles.length)return 0;var e=this._engine;e.setState&&(e.setState(!1),this.forceDepthWrite&&e.setDepthWrite(!0));var i=0;return i=this.blendMode===t.BLENDMODE_MULTIPLYADD?this._render(t.BLENDMODE_MULTIPLY)+this._render(t.BLENDMODE_ADD):this._render(this.blendMode),this._engine.unbindInstanceAttributes(),this._engine.setAlphaMode(g.a.ALPHA_DISABLE),i},t.prototype.dispose=function(e){if(void 0===e&&(e=!0),this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._removeFromRoot(),this._subEmitters&&this._subEmitters.length){for(var t=0;t-1&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose());this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onStoppedObservable.clear(),this.reset()},t.prototype.clone=function(e,i){var n=Object(h.a)({},this._customEffect),r=null,o=this._engine;if(o.createEffectForParticles&&null!=this.customShader){var a=(r=this.customShader).shaderOptions.defines.length>0?r.shaderOptions.defines.join(\"\\n\"):\"\";n[0]=o.createEffectForParticles(r.shaderPath.fragmentElement,r.shaderOptions.uniforms,r.shaderOptions.samplers,a)}var s=this.serialize(),c=t.Parse(s,this._scene||this._engine,\"\");return c.name=e,c.customShader=r,c._customEffect=n,void 0===i&&(i=this.emitter),this.noiseTexture&&(c.noiseTexture=this.noiseTexture.clone()),c.emitter=i,this.preventAutoStart||c.start(),c},t.prototype.serialize=function(e){void 0===e&&(e=!1);var i={};if(t._Serialize(i,this,e),i.textureMask=this.textureMask.asArray(),i.customShader=this.customShader,i.preventAutoStart=this.preventAutoStart,this.subEmitters){i.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var n=0,r=this._subEmitters;n0?l.shaderOptions.defines.join(\"\\n\"):\"\";c=o.createEffectForParticles(l.shaderPath.fragmentElement,l.shaderOptions.uniforms,l.shaderOptions.samplers,u)}var h=new t(a,e.capacity,i,c,e.isAnimationSheetEnabled);if(h.customShader=l,e.id&&(h.id=e.id),e.subEmitters){h.subEmitters=[];for(var d=0,f=e.subEmitters;d=life && stopFactor != 0.) {\\nvec3 newPosition;\\nvec3 newDirection;\\n\\nvec4 randoms=getRandomVec4(seed.x);\\n\\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\\noutAge=newAge-life;\\n\\noutSeed=seed;\\n\\n#ifdef SIZEGRADIENTS\\noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\\n#else\\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\\n#endif\\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;\\noutSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a;\\n#ifndef COLORGRADIENTS\\n\\noutColor=color1+(color2-color1)*randoms.b;\\n#endif\\n\\n#ifndef ANGULARSPEEDGRADIENTS\\noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;\\noutAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\\n#else\\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\\n#endif\\n\\n#ifdef POINTEMITTER\\nvec3 randoms2=getRandomVec3(seed.y);\\nvec3 randoms3=getRandomVec3(seed.z);\\nnewPosition=vec3(0,0,0);\\nnewDirection=direction1+(direction2-direction1)*randoms3;\\n#elif defined(BOXEMITTER)\\nvec3 randoms2=getRandomVec3(seed.y);\\nvec3 randoms3=getRandomVec3(seed.z);\\nnewPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\\nnewDirection=direction1+(direction2-direction1)*randoms3;\\n#elif defined(HEMISPHERICEMITTER)\\nvec3 randoms2=getRandomVec3(seed.y);\\nvec3 randoms3=getRandomVec3(seed.z);\\n\\nfloat phi=2.0*PI*randoms2.x;\\nfloat theta=acos(2.0*randoms2.y-1.0);\\nfloat randX=cos(phi)*sin(theta);\\nfloat randY=cos(theta);\\nfloat randZ=sin(phi)*sin(theta);\\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\\nnewDirection=newPosition+directionRandomizer*randoms3;\\n#elif defined(SPHEREEMITTER)\\nvec3 randoms2=getRandomVec3(seed.y);\\nvec3 randoms3=getRandomVec3(seed.z);\\n\\nfloat phi=2.0*PI*randoms2.x;\\nfloat theta=acos(2.0*randoms2.y-1.0);\\nfloat randX=cos(phi)*sin(theta);\\nfloat randY=cos(theta);\\nfloat randZ=sin(phi)*sin(theta);\\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\\n#ifdef DIRECTEDSPHEREEMITTER\\nnewDirection=direction1+(direction2-direction1)*randoms3;\\n#else\\n\\nnewDirection=newPosition+directionRandomizer*randoms3;\\n#endif\\n#elif defined(CYLINDEREMITTER)\\nvec3 randoms2=getRandomVec3(seed.y);\\nvec3 randoms3=getRandomVec3(seed.z);\\n\\nfloat yPos=(randoms2.x-0.5)*height;\\nfloat angle=randoms2.y*PI*2.;\\nfloat inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));\\nfloat positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));\\nfloat xPos=positionRadius*cos(angle);\\nfloat zPos=positionRadius*sin(angle);\\nnewPosition=vec3(xPos,yPos,zPos);\\n#ifdef DIRECTEDCYLINDEREMITTER\\nnewDirection=direction1+(direction2-direction1)*randoms3;\\n#else\\n\\nangle=angle+((randoms3.x-0.5)*PI);\\nnewDirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));\\nnewDirection=normalize(newDirection);\\n#endif\\n#elif defined(CONEEMITTER)\\nvec3 randoms2=getRandomVec3(seed.y);\\nfloat s=2.0*PI*randoms2.x;\\n#ifdef CONEEMITTERSPAWNPOINT\\nfloat h=0.0001;\\n#else\\nfloat h=randoms2.y*height.y;\\n\\nh=1.-h*h;\\n#endif\\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;\\nlRadius=lRadius*h;\\nfloat randX=lRadius*sin(s);\\nfloat randZ=lRadius*cos(s);\\nfloat randY=h*height.x;\\nnewPosition=vec3(randX,randY,randZ);\\n\\nif (abs(cos(coneAngle)) == 1.0) {\\nnewDirection=vec3(0.,1.0,0.);\\n} else {\\nvec3 randoms3=getRandomVec3(seed.z);\\nnewDirection=normalize(newPosition+directionRandomizer*randoms3);\\n}\\n#elif defined(CUSTOMEMITTER)\\nnewPosition=initialPosition;\\noutInitialPosition=initialPosition;\\n#else\\n\\nnewPosition=vec3(0.,0.,0.);\\n\\nnewDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\\n#endif\\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\\n#ifdef LOCAL\\noutPosition=newPosition;\\n#else\\noutPosition=(emitterWM*vec4(newPosition,1.)).xyz;\\n#endif\\n#ifdef CUSTOMEMITTER\\noutDirection=direction;\\n#ifndef BILLBOARD\\noutInitialDirection=direction;\\n#endif\\n#else\\n#ifdef LOCAL\\nvec3 initial=newDirection;\\n#else\\nvec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;\\n#endif\\noutDirection=initial*power;\\n#ifndef BILLBOARD\\noutInitialDirection=initial;\\n#endif\\n#endif\\n#ifdef ANIMATESHEET\\noutCellIndex=cellInfos.x;\\n#ifdef ANIMATESHEETRANDOMSTART\\noutCellStartOffset=randoms.a*outLife;\\n#endif\\n#endif\\n#ifdef NOISE\\noutNoiseCoordinates1=noiseCoordinates1;\\noutNoiseCoordinates2=noiseCoordinates2;\\n#endif\\n} else {\\nfloat directionScale=timeDelta;\\noutAge=newAge;\\nfloat ageGradient=newAge/life;\\n#ifdef VELOCITYGRADIENTS\\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\\n#endif\\n#ifdef DRAGGRADIENTS\\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\\n#endif\\n#if defined(CUSTOMEMITTER)\\noutPosition=position+(direction-position)*ageGradient;\\noutInitialPosition=initialPosition;\\n#else\\noutPosition=position+direction*directionScale;\\n#endif\\noutLife=life;\\noutSeed=seed;\\n#ifndef COLORGRADIENTS\\noutColor=color;\\n#endif\\n#ifdef SIZEGRADIENTS\\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;\\noutSize.yz=size.yz;\\n#else\\noutSize=size;\\n#endif\\n#ifndef BILLBOARD\\noutInitialDirection=initialDirection;\\n#endif\\n#ifdef CUSTOMEMITTER\\noutDirection=direction;\\n#else\\nvec3 updatedDirection=direction+gravity*timeDelta;\\n#ifdef LIMITVELOCITYGRADIENTS\\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;\\nfloat currentVelocity=length(updatedDirection);\\nif (currentVelocity>limitVelocity) {\\nupdatedDirection=updatedDirection*limitVelocityDamping;\\n}\\n#endif\\noutDirection=updatedDirection;\\n#ifdef NOISE\\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;\\nfloat fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;\\nfloat fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;\\nvec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;\\noutDirection=outDirection+force*timeDelta;\\noutNoiseCoordinates1=noiseCoordinates1;\\noutNoiseCoordinates2=noiseCoordinates2;\\n#endif\\n#endif\\n#ifdef ANGULARSPEEDGRADIENTS\\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;\\noutAngle=angle+angularSpeed*timeDelta;\\n#else\\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\\n#endif\\n#ifdef ANIMATESHEET\\nfloat offsetAge=outAge;\\nfloat dist=cellInfos.y-cellInfos.x;\\n#ifdef ANIMATESHEETRANDOMSTART\\noutCellStartOffset=cellStartOffset;\\noffsetAge+=cellStartOffset;\\n#else\\nfloat cellStartOffset=0.;\\n#endif\\nfloat ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);\\noutCellIndex=float(int(cellInfos.x+ratio*dist));\\n#endif\\n}\\n}\";ai.a.ShadersStore.gpuUpdateParticlesVertexShader=fd;var pd=\"#ifdef CLIPPLANE\\nin float fClipDistance;\\n#endif\\n#ifdef CLIPPLANE2\\nin float fClipDistance2;\\n#endif\\n#ifdef CLIPPLANE3\\nin float fClipDistance3;\\n#endif\\n#ifdef CLIPPLANE4\\nin float fClipDistance4;\\n#endif\\n#ifdef CLIPPLANE5\\nin float fClipDistance5;\\n#endif\\n#ifdef CLIPPLANE6\\nin float fClipDistance6;\\n#endif\";ai.a.IncludesShadersStore.clipPlaneFragmentDeclaration2=pd;var _d=\"#version 300 es\\nuniform sampler2D diffuseSampler;\\nin vec2 vUV;\\nin vec4 vColor;\\nout vec4 outFragColor;\\n#include\\n#include\\n#include\\n#include\\nvoid main() {\\n#include\\nvec4 textureColor=texture(diffuseSampler,vUV);\\noutFragColor=textureColor*vColor;\\n#ifdef BLENDMULTIPLYMODE\\nfloat alpha=vColor.a*textureColor.a;\\noutFragColor.rgb=outFragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);\\n#endif\\n\\n\\n#ifdef IMAGEPROCESSINGPOSTPROCESS\\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\\n#else\\n#ifdef IMAGEPROCESSING\\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\\noutFragColor=applyImageProcessing(outFragColor);\\n#endif\\n#endif\\n}\\n\";ai.a.ShadersStore.gpuRenderParticlesPixelShader=_d;var md=\"#ifdef CLIPPLANE\\nuniform vec4 vClipPlane;\\nout float fClipDistance;\\n#endif\\n#ifdef CLIPPLANE2\\nuniform vec4 vClipPlane2;\\nout float fClipDistance2;\\n#endif\\n#ifdef CLIPPLANE3\\nuniform vec4 vClipPlane3;\\nout float fClipDistance3;\\n#endif\\n#ifdef CLIPPLANE4\\nuniform vec4 vClipPlane4;\\nout float fClipDistance4;\\n#endif\\n#ifdef CLIPPLANE5\\nuniform vec4 vClipPlane5;\\nout float fClipDistance5;\\n#endif\\n#ifdef CLIPPLANE6\\nuniform vec4 vClipPlane6;\\nout float fClipDistance6;\\n#endif\";ai.a.IncludesShadersStore.clipPlaneVertexDeclaration2=md;var gd=\"#version 300 es\\nuniform mat4 view;\\nuniform mat4 projection;\\nuniform vec2 translationPivot;\\nuniform vec3 worldOffset;\\n#ifdef LOCAL\\nuniform mat4 emitterWM;\\n#endif\\n\\nin vec3 position;\\nin float age;\\nin float life;\\nin vec3 size;\\n#ifndef BILLBOARD\\nin vec3 initialDirection;\\n#endif\\n#ifdef BILLBOARDSTRETCHED\\nin vec3 direction;\\n#endif\\nin float angle;\\n#ifdef ANIMATESHEET\\nin float cellIndex;\\n#endif\\nin vec2 offset;\\nin vec2 uv;\\nout vec2 vUV;\\nout vec4 vColor;\\nout vec3 vPositionW;\\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\\nuniform mat4 invView;\\n#endif\\n#include\\n#ifdef COLORGRADIENTS\\nuniform sampler2D colorGradientSampler;\\n#else\\nuniform vec4 colorDead;\\nin vec4 color;\\n#endif\\n#ifdef ANIMATESHEET\\nuniform vec3 sheetInfos;\\n#endif\\n#ifdef BILLBOARD\\nuniform vec3 eyePosition;\\n#endif\\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\\nvec3 zaxis=normalize(cross(yaxis,xaxis));\\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\\nmat3 rotMatrix=mat3(row0,row1,row2);\\nvec3 alignedCorner=rotMatrix*rotatedCorner;\\n#ifdef LOCAL\\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\\n#else\\nreturn (position+worldOffset)+alignedCorner;\\n#endif\\n}\\n#ifdef BILLBOARDSTRETCHED\\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\\nvec3 normalizedToCamera=normalize(toCamera);\\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\\nmat3 rotMatrix=mat3(row0,row1,row2);\\nvec3 alignedCorner=rotMatrix*rotatedCorner;\\n#ifdef LOCAL\\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\\n#else\\nreturn (position+worldOffset)+alignedCorner;\\n#endif\\n}\\n#endif\\nvoid main() {\\n#ifdef ANIMATESHEET\\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\\nvec2 uvScale=sheetInfos.xy;\\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\\n#else\\nvUV=uv;\\n#endif\\nfloat ratio=age/life;\\n#ifdef COLORGRADIENTS\\nvColor=texture(colorGradientSampler,vec2(ratio,0));\\n#else\\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\\n#endif\\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\\n#ifdef BILLBOARD\\nvec4 rotatedCorner;\\nrotatedCorner.w=0.;\\n#ifdef BILLBOARDY\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nrotatedCorner.y=0.;\\nvec3 yaxis=(position+worldOffset)-eyePosition;\\nyaxis.y=0.;\\nvPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);\\nvec4 viewPosition=(view*vec4(vPositionW,1.0));\\n#elif defined(BILLBOARDSTRETCHED)\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nrotatedCorner.z=0.;\\nvec3 toCamera=(position+worldOffset)-eyePosition;\\nvPositionW=rotateAlign(toCamera,rotatedCorner.xyz);\\nvec4 viewPosition=(view*vec4(vPositionW,1.0));\\n#else\\n\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nrotatedCorner.z=0.;\\n\\n#ifdef LOCAL\\nvec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;\\n#else\\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\\n#endif\\nvPositionW=(invView*viewPosition).xyz;\\n#endif\\n#else\\n\\nvec3 rotatedCorner;\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.y=0.;\\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nvec3 yaxis=normalize(initialDirection);\\nvPositionW=rotate(yaxis,rotatedCorner);\\n\\nvec4 viewPosition=view*vec4(vPositionW,1.0);\\n#endif\\ngl_Position=projection*viewPosition;\\n\\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\\nvec4 worldPos=vec4(vPositionW,1.0);\\n#endif\\n#include\\n}\";ai.a.ShadersStore.gpuRenderParticlesVertexShader=gd;var vd=function(e){function t(t,i,n,r,s){void 0===r&&(r=!1),void 0===s&&(s=null);var c=e.call(this,t)||this;c.layerMask=268435455,c._accumulatedCount=0,c._targetIndex=0,c._currentRenderId=-1,c._started=!1,c._stopped=!1,c._timeDelta=0,c._actualFrame=0,c._rawTextureWidth=256,c.onDisposeObservable=new o.c,c.onStoppedObservable=new o.c,c.forceDepthWrite=!1,c._preWarmDone=!1,c.isLocal=!1,c._onBeforeDrawParticlesObservable=null,n&&\"Scene\"!==n.getClassName()?(c._engine=n,c.defaultProjectionMatrix=a.a.PerspectiveFovLH(.8,1,.1,100)):(c._scene=n||x.a.LastCreatedScene,c._engine=c._scene.getEngine(),c.uniqueId=c._scene.getUniqueId(),c._scene.particleSystems.push(c)),c._customEffect={0:s},c._attachImageProcessingConfiguration(null),i.randomTextureSize||delete i.randomTextureSize;var l=Object(h.a)({capacity:5e4,randomTextureSize:c._engine.getCaps().maxTextureSize},i),u=i;isFinite(u)&&(l.capacity=u),c._capacity=l.capacity,c._activeCount=l.capacity,c._currentActiveCount=0,c._isAnimationSheetEnabled=r,c._updateEffectOptions={attributes:[\"position\",\"initialPosition\",\"age\",\"life\",\"seed\",\"size\",\"color\",\"direction\",\"initialDirection\",\"angle\",\"cellIndex\",\"cellStartOffset\",\"noiseCoordinates1\",\"noiseCoordinates2\"],uniformsNames:[\"currentCount\",\"timeDelta\",\"emitterWM\",\"lifeTime\",\"color1\",\"color2\",\"sizeRange\",\"scaleRange\",\"gravity\",\"emitPower\",\"direction1\",\"direction2\",\"minEmitBox\",\"maxEmitBox\",\"radius\",\"directionRandomizer\",\"height\",\"coneAngle\",\"stopFactor\",\"angleRange\",\"radiusRange\",\"cellInfos\",\"noiseStrength\",\"limitVelocityDamping\"],uniformBuffersNames:[],samplers:[\"randomSampler\",\"randomSampler2\",\"sizeGradientSampler\",\"angularSpeedGradientSampler\",\"velocityGradientSampler\",\"limitVelocityGradientSampler\",\"noiseSampler\",\"dragGradientSampler\"],defines:\"\",fallbacks:null,onCompiled:null,onError:null,indexParameters:null,maxSimultaneousLights:0,transformFeedbackVaryings:[]},c.particleEmitterType=new Nl;for(var d=Math.min(c._engine.getCaps().maxTextureSize,l.randomTextureSize),f=[],p=0;p1},enumerable:!1,configurable:!0}),t.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(t.prototype,\"activeParticleCount\",{get:function(){return this._activeCount},set:function(e){this._activeCount=Math.min(e,this._capacity)},enumerable:!1,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&(!this._imageProcessingConfiguration||this._imageProcessingConfiguration.isReady())&&this._getEffect().isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.isStopped=function(){return this._stopped},t.prototype.isStopping=function(){return!1},t.prototype.getActiveCount=function(){return this._currentActiveCount},t.prototype.start=function(e){var t=this;if(void 0===e&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw\"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set\";e?setTimeout((function(){t.start(0)}),e):(this._started=!0,this._stopped=!1,this._preWarmDone=!1,this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){this._stopped||(this._stopped=!0)},t.prototype.reset=function(){this._releaseBuffers(),this._releaseVAOs(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return\"GPUParticleSystem\"},t.prototype.getCustomEffect=function(e){var t;return void 0===e&&(e=0),null!==(t=this._customEffect[e])&&void 0!==t?t:this._customEffect[0]},t.prototype.setCustomEffect=function(e,t){void 0===t&&(t=0),this._customEffect[t]=e},Object.defineProperty(t.prototype,\"onBeforeDrawParticlesObservable\",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new o.c),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"vertexShaderName\",{get:function(){return\"gpuRenderParticles\"},enumerable:!1,configurable:!0}),t.prototype._removeGradientAndTexture=function(t,i,n){return e.prototype._removeGradientAndTexture.call(this,t,i,n),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var n=new rd(e,t);return this._colorGradients.push(n),this._refreshColorGradient(!0),this._releaseBuffers(),this},t.prototype._refreshColorGradient=function(e){void 0===e&&(e=!1),this._colorGradients&&(e&&this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null))},t.prototype.forceRefreshGradients=function(){this._refreshColorGradient(),this._refreshFactorGradient(this._sizeGradients,\"_sizeGradientsTexture\"),this._refreshFactorGradient(this._angularSpeedGradients,\"_angularSpeedGradientsTexture\"),this._refreshFactorGradient(this._velocityGradients,\"_velocityGradientsTexture\"),this._refreshFactorGradient(this._limitVelocityGradients,\"_limitVelocityGradientsTexture\"),this._refreshFactorGradient(this._dragGradients,\"_dragGradientsTexture\"),this.reset()},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype._addFactorGradient=function(e,t,i){var n=new ad(t,i);e.push(n),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._refreshFactorGradient(this._sizeGradients,\"_sizeGradientsTexture\",!0),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype._refreshFactorGradient=function(e,t,i){if(void 0===i&&(i=!1),e){i&&e.sort((function(e,t){return e.gradientt.gradient?1:0}));this[t]&&(this[t].dispose(),this[t]=null)}},t.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._refreshFactorGradient(this._angularSpeedGradients,\"_angularSpeedGradientsTexture\",!0),this._releaseBuffers(),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeGradientAndTexture(e,this._angularSpeedGradients,this._angularSpeedGradientsTexture),this._angularSpeedGradientsTexture=null,this},t.prototype.addVelocityGradient=function(e,t){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t),this._refreshFactorGradient(this._velocityGradients,\"_velocityGradientsTexture\",!0),this._releaseBuffers(),this},t.prototype.removeVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._velocityGradients,this._velocityGradientsTexture),this._velocityGradientsTexture=null,this},t.prototype.addLimitVelocityGradient=function(e,t){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t),this._refreshFactorGradient(this._limitVelocityGradients,\"_limitVelocityGradientsTexture\",!0),this._releaseBuffers(),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._limitVelocityGradients,this._limitVelocityGradientsTexture),this._limitVelocityGradientsTexture=null,this},t.prototype.addDragGradient=function(e,t){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t),this._refreshFactorGradient(this._dragGradients,\"_dragGradientsTexture\",!0),this._releaseBuffers(),this},t.prototype.removeDragGradient=function(e){return this._removeGradientAndTexture(e,this._dragGradients,this._dragGradientsTexture),this._dragGradientsTexture=null,this},t.prototype.addEmitRateGradient=function(e,t,i){return this},t.prototype.removeEmitRateGradient=function(e){return this},t.prototype.addStartSizeGradient=function(e,t,i){return this},t.prototype.removeStartSizeGradient=function(e){return this},t.prototype.addColorRemapGradient=function(e,t,i){return this},t.prototype.removeColorRemapGradient=function(){return this},t.prototype.addAlphaRemapGradient=function(e,t,i){return this},t.prototype.removeAlphaRemapGradient=function(){return this},t.prototype.addRampGradient=function(e,t){return this},t.prototype.removeRampGradient=function(){return this},t.prototype.getRampGradients=function(){return null},Object.defineProperty(t.prototype,\"useRampGradients\",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.addLifeTimeGradient=function(e,t,i){return this},t.prototype.removeLifeTimeGradient=function(e){return this},t.prototype._reset=function(){this._releaseBuffers()},t.prototype._createUpdateVAO=function(e){var t={};t.position=e.createVertexBuffer(\"position\",0,3);var i=3;this.particleEmitterType instanceof zl&&(t.initialPosition=e.createVertexBuffer(\"initialPosition\",i,3),i+=3),t.age=e.createVertexBuffer(\"age\",i,1),i+=1,t.life=e.createVertexBuffer(\"life\",i,1),i+=1,t.seed=e.createVertexBuffer(\"seed\",i,4),i+=4,t.size=e.createVertexBuffer(\"size\",i,3),i+=3,this._colorGradientsTexture||(t.color=e.createVertexBuffer(\"color\",i,4),i+=4),t.direction=e.createVertexBuffer(\"direction\",i,3),i+=3,this._isBillboardBased||(t.initialDirection=e.createVertexBuffer(\"initialDirection\",i,3),i+=3),this._angularSpeedGradientsTexture?(t.angle=e.createVertexBuffer(\"angle\",i,1),i+=1):(t.angle=e.createVertexBuffer(\"angle\",i,2),i+=2),this._isAnimationSheetEnabled&&(t.cellIndex=e.createVertexBuffer(\"cellIndex\",i,1),i+=1,this.spriteRandomStartCell&&(t.cellStartOffset=e.createVertexBuffer(\"cellStartOffset\",i,1),i+=1)),this.noiseTexture&&(t.noiseCoordinates1=e.createVertexBuffer(\"noiseCoordinates1\",i,3),i+=3,t.noiseCoordinates2=e.createVertexBuffer(\"noiseCoordinates2\",i,3),i+=3);var n=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),n},t.prototype._createRenderVAO=function(e,t){var i={};i.position=e.createVertexBuffer(\"position\",0,3,this._attributesStrideSize,!0);var n=3;this.particleEmitterType instanceof zl&&(n+=3),i.age=e.createVertexBuffer(\"age\",n,1,this._attributesStrideSize,!0),n+=1,i.life=e.createVertexBuffer(\"life\",n,1,this._attributesStrideSize,!0),n+=5,i.size=e.createVertexBuffer(\"size\",n,3,this._attributesStrideSize,!0),n+=3,this._colorGradientsTexture||(i.color=e.createVertexBuffer(\"color\",n,4,this._attributesStrideSize,!0),n+=4),this.billboardMode===dd.BILLBOARDMODE_STRETCHED&&(i.direction=e.createVertexBuffer(\"direction\",n,3,this._attributesStrideSize,!0)),n+=3,this._isBillboardBased||(i.initialDirection=e.createVertexBuffer(\"initialDirection\",n,3,this._attributesStrideSize,!0),n+=3),i.angle=e.createVertexBuffer(\"angle\",n,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?n++:n+=2,this._isAnimationSheetEnabled&&(i.cellIndex=e.createVertexBuffer(\"cellIndex\",n,1,this._attributesStrideSize,!0),n+=1,this.spriteRandomStartCell&&(i.cellStartOffset=e.createVertexBuffer(\"cellStartOffset\",n,1,this._attributesStrideSize,!0),n+=1)),this.noiseTexture&&(i.noiseCoordinates1=e.createVertexBuffer(\"noiseCoordinates1\",n,3,this._attributesStrideSize,!0),n+=3,i.noiseCoordinates2=e.createVertexBuffer(\"noiseCoordinates2\",n,3,this._attributesStrideSize,!0),n+=3),i.offset=t.createVertexBuffer(\"offset\",0,2),i.uv=t.createVertexBuffer(\"uv\",2,2);var r=this._engine.recordVertexArrayObject(i,null,this._getEffect());return this._engine.bindArrayBuffer(null),r},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._engine,i=new Array;this._attributesStrideSize=21,this._targetIndex=0,this.particleEmitterType instanceof zl&&(this._attributesStrideSize+=3),this.isBillboardBased||(this._attributesStrideSize+=3),this._colorGradientsTexture&&(this._attributesStrideSize-=4),this._angularSpeedGradientsTexture&&(this._attributesStrideSize-=1),this._isAnimationSheetEnabled&&(this._attributesStrideSize+=1,this.spriteRandomStartCell&&(this._attributesStrideSize+=1)),this.noiseTexture&&(this._attributesStrideSize+=6);for(var n=this.particleEmitterType instanceof zl,r=a.c.Vector3[0],o=0;o=this.targetStopDuration&&this.stop()},t.prototype._createFactorGradientTexture=function(e,t){var i=this[t];if(e&&e.length&&!i){for(var n=new Float32Array(this._rawTextureWidth),r=0;r1){var r=0|this._accumulatedCount;this._accumulatedCount-=r,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+r)}if(!this._currentActiveCount)return 0;this._engine.enableEffect(this._updateEffect);var o,s=this._engine;if(!s.setState)throw new Error(\"GPU particles cannot work with a full Engine. ThinEngine is not supported\");if(this._updateEffect.setFloat(\"currentCount\",this._currentActiveCount),this._updateEffect.setFloat(\"timeDelta\",this._timeDelta),this._updateEffect.setFloat(\"stopFactor\",this._stopped?0:1),this._updateEffect.setTexture(\"randomSampler\",this._randomTexture),this._updateEffect.setTexture(\"randomSampler2\",this._randomTexture2),this._updateEffect.setFloat2(\"lifeTime\",this.minLifeTime,this.maxLifeTime),this._updateEffect.setFloat2(\"emitPower\",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateEffect.setDirectColor4(\"color1\",this.color1),this._updateEffect.setDirectColor4(\"color2\",this.color2)),this._updateEffect.setFloat2(\"sizeRange\",this.minSize,this.maxSize),this._updateEffect.setFloat4(\"scaleRange\",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateEffect.setFloat4(\"angleRange\",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateEffect.setVector3(\"gravity\",this.gravity),this._sizeGradientsTexture&&this._updateEffect.setTexture(\"sizeGradientSampler\",this._sizeGradientsTexture),this._angularSpeedGradientsTexture&&this._updateEffect.setTexture(\"angularSpeedGradientSampler\",this._angularSpeedGradientsTexture),this._velocityGradientsTexture&&this._updateEffect.setTexture(\"velocityGradientSampler\",this._velocityGradientsTexture),this._limitVelocityGradientsTexture&&(this._updateEffect.setTexture(\"limitVelocityGradientSampler\",this._limitVelocityGradientsTexture),this._updateEffect.setFloat(\"limitVelocityDamping\",this.limitVelocityDamping)),this._dragGradientsTexture&&this._updateEffect.setTexture(\"dragGradientSampler\",this._dragGradientsTexture),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateEffect),this._isAnimationSheetEnabled&&this._updateEffect.setFloat3(\"cellInfos\",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed),this.noiseTexture&&(this._updateEffect.setTexture(\"noiseSampler\",this.noiseTexture),this._updateEffect.setVector3(\"noiseStrength\",this.noiseStrength)),this.emitter.position){o=this.emitter.getWorldMatrix()}else{var c=this.emitter;o=a.a.Translation(c.x,c.y,c.z)}if(this.isLocal||this._updateEffect.setMatrix(\"emitterWM\",o),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),s.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),s.setRasterizerState(!1),s.beginTransformFeedback(!0),s.drawArraysType(g.a.MATERIAL_PointListDrawMode,0,this._currentActiveCount),s.endTransformFeedback(),s.setRasterizerState(!0),s.bindTransformFeedbackBuffer(null),!e){var l=this._getEffect();this._engine.enableEffect(l);var u=(null===(t=this._scene)||void 0===t?void 0:t.getViewMatrix())||a.a.IdentityReadOnly;if(l.setMatrix(\"view\",u),l.setMatrix(\"projection\",null!==(i=this.defaultProjectionMatrix)&&void 0!==i?i:this._scene.getProjectionMatrix()),l.setTexture(\"diffuseSampler\",this.particleTexture),l.setVector2(\"translationPivot\",this.translationPivot),l.setVector3(\"worldOffset\",this.worldOffset),this.isLocal&&l.setMatrix(\"emitterWM\",o),this._colorGradientsTexture?l.setTexture(\"colorGradientSampler\",this._colorGradientsTexture):l.setDirectColor4(\"colorDead\",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var h=this.particleTexture.getBaseSize();l.setFloat3(\"sheetInfos\",this.spriteCellWidth/h.width,this.spriteCellHeight/h.height,h.width/this.spriteCellWidth)}if(this._isBillboardBased&&this._scene){var d=this._scene.activeCamera;l.setVector3(\"eyePosition\",d.globalPosition)}var f=l.defines;if(this._scene&&(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6)&&ro.a.BindClipPlane(l,this._scene),f.indexOf(\"#define BILLBOARDMODE_ALL\")>=0){var p=u.clone();p.invert(),l.setMatrix(\"invView\",p)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(l),this.blendMode){case dd.BLENDMODE_ADD:this._engine.setAlphaMode(g.a.ALPHA_ADD);break;case dd.BLENDMODE_ONEONE:this._engine.setAlphaMode(g.a.ALPHA_ONEONE);break;case dd.BLENDMODE_STANDARD:this._engine.setAlphaMode(g.a.ALPHA_COMBINE);break;case dd.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(g.a.ALPHA_MULTIPLY)}this.forceDepthWrite&&s.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(l),this._engine.drawArraysType(g.a.MATERIAL_TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(g.a.ALPHA_DISABLE)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var _=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=_,this._currentActiveCount},t.prototype.rebuild=function(){this._initialize(!0)},t.prototype._releaseBuffers=function(){this._buffer0&&(this._buffer0.dispose(),this._buffer0=null),this._buffer1&&(this._buffer1.dispose(),this._buffer1=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null)},t.prototype._releaseVAOs=function(){if(this._updateVAO){for(var e=0;e-1&&this._scene.particleSystems.splice(t,1)}this._releaseBuffers(),this._releaseVAOs(),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._randomTexture&&(this._randomTexture.dispose(),this._randomTexture=null),this._randomTexture2&&(this._randomTexture2.dispose(),this._randomTexture2=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this.onStoppedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,i){var n=this.serialize(),r=t.Parse(n,this._scene||this._engine,\"\"),o=Object(h.a)({},this._customEffect);return r.name=e,r._customEffect=o,void 0===i&&(i=this.emitter),r.emitter=i,r.noiseTexture=this.noiseTexture,r},t.prototype.serialize=function(e){void 0===e&&(e=!1);var t={};return dd._Serialize(t,this,e),t.activeParticleCount=this.activeParticleCount,t.randomTextureSize=this._randomTextureSize,t},t.Parse=function(e,i,n,r){void 0===r&&(r=!1);var o=new t(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},i);return e.activeParticleCount&&(o.activeParticleCount=e.activeParticleCount),dd._Parse(e,o,i,n),e.preventAutoStart&&(o.preventAutoStart=e.preventAutoStart),r||o.preventAutoStart||o.start(),o},t}(jl),bd=function(){function e(){this.systems=new Array}return Object.defineProperty(e.prototype,\"emitterNode\",{get:function(){return this._emitterNode},enumerable:!1,configurable:!0}),e.prototype.setEmitterAsSphere=function(e,t,i){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:\"Sphere\",options:e,renderingGroupId:t};var n=xr.a.CreateSphere(\"emitterSphere\",{diameter:e.diameter,segments:e.segments},i);n.renderingGroupId=t;var r=new Wi.a(\"emitterSphereMaterial\",i);r.emissiveColor=e.color,n.material=r;for(var o=0,a=this.systems;o0&&i.set(this._uvs32,Qi.b.UVKind),this._colors32.length>0&&i.set(this._colors32,Qi.b.ColorKind),i.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,this._pickable)for(var n=0,r=0;rf?f:n,i=Math.round(f/n),r=0):i=i>f?f:i;for(var p=[],_=[],m=[],g=[],v=[],b=a.e.Zero(),y=i;df-(i=y+Math.floor((1+r)*Math.random()))&&(i=f-d),p.length=0,_.length=0,m.length=0,g.length=0,v.length=0;for(var T=0,E=3*d;E<3*(d+i);E++){m.push(T);var S=s[E],A=3*S;if(p.push(o[A],o[A+1],o[A+2]),_.push(u[A],u[A+1],u[A+2]),c){var P=2*S;g.push(c[P],c[P+1])}if(l){var C=4*S;v.push(l[C],l[C+1],l[C+2],l[C+3])}T++}var R,x=this.nbParticles,O=this._posToShape(p),M=this._uvsToShapeUV(g),I=Ce.b.Slice(m),D=Ce.b.Slice(v),N=Ce.b.Slice(_);for(b.copyFromFloats(0,0,0),R=0;R65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var U=null!==T.materialIndex?T.materialIndex:0;this.depthSortedParticles.push(new Ad(f,t,r.length,U))}return T},e.prototype._posToShape=function(e){for(var t=[],i=0;i=this.nbParticles||!this._updatable)return[];var n=this.particles,r=this.nbParticles;if(t=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var L=this.mesh._boundingInfo;L&&(v.copyFrom(L.minimum),b.copyFrom(L.maximum))}var w=(x=this.particles[e]._pos)/3|0;M=4*w,D=2*w;for(var F=e;F<=t;F++){var B=this.particles[F];this.updateParticle(B);var U=B._model._shape,V=B._model._shapeUV,k=B._rotationMatrix,z=B.position,G=B.rotation,j=B.scaling,W=B._globalPosition;if(this._depthSort&&this._depthSortParticles){var H=this.depthSortedParticles[F];H.idx=B.idx,H.ind=B._ind,H.indicesLength=B._model._indicesLength,H.sqDistance=a.e.DistanceSquared(B.position,y)}if(!B.alive||B._stillInvisible&&!B.isVisible)x+=3*(N=U.length),M+=4*N,D+=2*N;else{if(B.isVisible){B._stillInvisible=!1;var X=p[12];if(B.pivot.multiplyToRef(j,X),this.billboard&&(G.x=0,G.y=0),(this._computeParticleRotation||this.billboard)&&B.getRotationMatrix(n),null!==B.parentId){var Y=this.getParticleById(B.parentId);if(Y){var K=Y._rotationMatrix,Q=Y._globalPosition,q=z.x*K[1]+z.y*K[4]+z.z*K[7],Z=z.x*K[0]+z.y*K[3]+z.z*K[6],$=z.x*K[2]+z.y*K[5]+z.z*K[8];if(W.x=Q.x+Z,W.y=Q.y+q,W.z=Q.z+$,this._computeParticleRotation||this.billboard){var ee=n.m;k[0]=ee[0]*K[0]+ee[1]*K[3]+ee[2]*K[6],k[1]=ee[0]*K[1]+ee[1]*K[4]+ee[2]*K[7],k[2]=ee[0]*K[2]+ee[1]*K[5]+ee[2]*K[8],k[3]=ee[4]*K[0]+ee[5]*K[3]+ee[6]*K[6],k[4]=ee[4]*K[1]+ee[5]*K[4]+ee[6]*K[7],k[5]=ee[4]*K[2]+ee[5]*K[5]+ee[6]*K[8],k[6]=ee[8]*K[0]+ee[9]*K[3]+ee[10]*K[6],k[7]=ee[8]*K[1]+ee[9]*K[4]+ee[10]*K[7],k[8]=ee[8]*K[2]+ee[9]*K[5]+ee[10]*K[8]}}else B.parentId=null}else if(W.x=z.x,W.y=z.y,W.z=z.z,this._computeParticleRotation||this.billboard){ee=n.m;k[0]=ee[0],k[1]=ee[1],k[2]=ee[2],k[3]=ee[4],k[4]=ee[5],k[5]=ee[6],k[6]=ee[8],k[7]=ee[9],k[8]=ee[10]}var te=p[11];for(B.translateFromPivot?te.setAll(0):te.copyFrom(X),N=0;N0)for(var t=0;t0&&e.set(this._uvs32,Qi.b.UVKind);var t=0;this._colors32.length>0&&(t=1,e.set(this._colors32,Qi.b.ColorKind));var i=new be.a(this.name,this._scene);e.applyToMesh(i,this._updatable),this.mesh=i,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var n=new Wi.a(\"point cloud material\",this._scene);return n.emissiveColor=new s.a(t,t,t),n.disableLighting=!0,n.pointsCloud=!0,n.pointSize=this._size,i.material=n,new Promise((function(e){return e(i)}))},e.prototype._addParticle=function(e,t,i,n){var r=new Rd(e,t,i,n,this);return this.particles.push(r),r},e.prototype._randomUnitVector=function(e){e.position=new a.e(Math.random(),Math.random(),Math.random()),e.color=new s.b(1,1,1,1)},e.prototype._getColorIndicesForCoord=function(e,t,i,n){var r=e._groupImageData,o=i*(4*n)+4*t,a=[o,o+1,o+2,o+3],c=a[1],l=a[2],u=a[3],h=r[a[0]],d=r[c],f=r[l],p=r[u];return new s.b(h/255,d/255,f/255,p)},e.prototype._setPointsColorOrUV=function(e,t,i,n,r,o,c){i&&e.updateFacetData();var l=2*e.getBoundingInfo().boundingSphere.radius,u=e.getVerticesData(Qi.b.PositionKind),h=e.getIndices(),d=e.getVerticesData(Qi.b.UVKind),f=e.getVerticesData(Qi.b.ColorKind),p=a.e.Zero();e.computeWorldMatrix();var _=e.getWorldMatrix();if(!_.isIdentity())for(var m=0;m1&&(Ie=1),(De=Ne.b+Oe)<0&&(De=0),De>1&&(De=1),s.a.HSVtoRGBToRef(Me,Ie,De,Be),me.set(Be.r,Be.g,Be.b,1)):me=ce.set(Math.random(),Math.random(),Math.random(),1),we.color=new s.b(me.x,me.y,me.z,me.w),this._colors.push(me.x,me.y,me.z,me.w))}},e.prototype._colorFromTexture=function(e,t,i){var n=this;if(null===e.material)return m.a.Warn(e.name+\"has no material.\"),t._groupImageData=null,void this._setPointsColorOrUV(e,t,i,!0,!1);var r=e.material.getActiveTextures();if(0===r.length)return m.a.Warn(e.name+\"has no useable texture.\"),t._groupImageData=null,void this._setPointsColorOrUV(e,t,i,!0,!1);var o=e.clone();o.setEnabled(!1),this._promises.push(new Promise((function(e){Zn.a.WhenAllReady(r,(function(){var a=t._textureNb;return a<0&&(a=0),a>r.length-1&&(a=r.length-1),t._groupImageData=r[a].readPixels(),t._groupImgWidth=r[a].getSize().width,t._groupImgHeight=r[a].getSize().height,n._setPointsColorOrUV(o,t,i,!0,!0),o.dispose(),e()}))})))},e.prototype._calculateDensity=function(e,t,i){for(var n,r,o,s,c,l,u,h,d,f,p,_,m,g,v,b,y,T=new Array,E=a.e.Zero(),S=a.e.Zero(),A=a.e.Zero(),P=a.e.Zero(),C=a.e.Zero(),R=a.e.Zero(),x=new Array,O=0,M=i.length/3,I=0;I0&&(T=T.map((function(e){return e+L})));for(I=0;I3)&&(o=Td.Random);var a=e.getVerticesData(Qi.b.PositionKind),c=e.getIndices();this._groups.push(this._groupCounter);var l=new xd(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,c),o===Td.Color?l._textureNb=n||0:n=n||new s.b(1,1,1,1),o){case Td.Color:this._colorFromTexture(e,l,!1);break;case Td.UV:this._setPointsColorOrUV(e,l,!1,!1,!1);break;case Td.Random:this._setPointsColorOrUV(e,l,!1);break;case Td.Stated:this._setPointsColorOrUV(e,l,!1,void 0,void 0,n,r)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.addVolumePoints=function(e,t,i,n,r){var o=i||Td.Random;(isNaN(o)||o<0||o>3)&&(o=Td.Random);var a=e.getVerticesData(Qi.b.PositionKind),c=e.getIndices();this._groups.push(this._groupCounter);var l=new xd(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,c),o===Td.Color?l._textureNb=n||0:n=n||new s.b(1,1,1,1),o){case Td.Color:this._colorFromTexture(e,l,!0);break;case Td.UV:this._setPointsColorOrUV(e,l,!0,!1,!1);break;case Td.Random:this._setPointsColorOrUV(e,l,!0);break;case Td.Stated:this._setPointsColorOrUV(e,l,!0,void 0,void 0,n,r)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.setParticles=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=this.nbParticles-1),void 0===i&&(i=!0),!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(e,t,i);var n=a.c.Matrix[0],r=this.mesh,o=this._colors32,s=this._positions32,c=this._uvs32,l=a.c.Vector3,u=l[5].copyFromFloats(1,0,0),h=l[6].copyFromFloats(0,1,0),d=l[7].copyFromFloats(0,0,1),f=l[8].setAll(Number.MAX_VALUE),p=l[9].setAll(-Number.MAX_VALUE);a.a.IdentityToRef(n);var _=0;if(this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),t=t>=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var m=this.mesh._boundingInfo;m&&(f.copyFrom(m.minimum),p.copyFrom(m.maximum))}_=0;for(var g=0,v=0,b=0,y=e;y<=t;y++){var T=this.particles[y];g=3*(_=T.idx),v=4*_,b=2*_,this.updateParticle(T);var E=T._rotationMatrix,S=T.position,A=T._globalPosition;if(this._computeParticleRotation&&T.getRotationMatrix(n),null!==T.parentId){var P=this.particles[T.parentId],C=P._rotationMatrix,R=P._globalPosition,x=S.x*C[1]+S.y*C[4]+S.z*C[7],O=S.x*C[0]+S.y*C[3]+S.z*C[6],M=S.x*C[2]+S.y*C[5]+S.z*C[8];if(A.x=R.x+O,A.y=R.y+x,A.z=R.z+M,this._computeParticleRotation){var I=n.m;E[0]=I[0]*C[0]+I[1]*C[3]+I[2]*C[6],E[1]=I[0]*C[1]+I[1]*C[4]+I[2]*C[7],E[2]=I[0]*C[2]+I[1]*C[5]+I[2]*C[8],E[3]=I[4]*C[0]+I[5]*C[3]+I[6]*C[6],E[4]=I[4]*C[1]+I[5]*C[4]+I[6]*C[7],E[5]=I[4]*C[2]+I[5]*C[5]+I[6]*C[8],E[6]=I[8]*C[0]+I[9]*C[3]+I[10]*C[6],E[7]=I[8]*C[1]+I[9]*C[4]+I[10]*C[7],E[8]=I[8]*C[2]+I[9]*C[5]+I[10]*C[8]}}else if(A.x=0,A.y=0,A.z=0,this._computeParticleRotation){I=n.m;E[0]=I[0],E[1]=I[1],E[2]=I[2],E[3]=I[4],E[4]=I[5],E[5]=I[6],E[6]=I[8],E[7]=I[9],E[8]=I[10]}var D=l[11];T.translateFromPivot?D.setAll(0):D.copyFrom(T.pivot);var N=l[0];N.copyFrom(T.position);var L=N.x-T.pivot.x,w=N.y-T.pivot.y,F=N.z-T.pivot.z,B=L*E[0]+w*E[3]+F*E[6],U=L*E[1]+w*E[4]+F*E[7],V=L*E[2]+w*E[5]+F*E[8];B+=D.x,U+=D.y,V+=D.z;var k=s[g]=A.x+u.x*B+h.x*U+d.x*V,z=s[g+1]=A.y+u.y*B+h.y*U+d.y*V,G=s[g+2]=A.z+u.z*B+h.z*U+d.z*V;if(this._computeBoundingBox&&(f.minimizeInPlaceFromFloats(k,z,G),p.maximizeInPlaceFromFloats(k,z,G)),this._computeParticleColor&&T.color){var j=T.color,W=this._colors32;W[v]=j.r,W[v+1]=j.g,W[v+2]=j.b,W[v+3]=j.a}if(this._computeParticleTexture&&T.uv){var H=T.uv,X=this._uvs32;X[b]=H.x,X[b+1]=H.y}}return i&&(this._computeParticleColor&&r.updateVerticesData(Qi.b.ColorKind,o,!1,!1),this._computeParticleTexture&&r.updateVerticesData(Qi.b.UVKind,c,!1,!1),r.updateVerticesData(Qi.b.PositionKind,s,!1,!1)),this._computeBoundingBox&&(r._boundingInfo?r._boundingInfo.reConstruct(f,p,r._worldMatrix):r._boundingInfo=new Tn.a(f,p,r._worldMatrix)),this.afterUpdateParticles(e,t,i),this},e.prototype.dispose=function(){this.mesh.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._uvs32=null,this._colors32=null},e.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},e.prototype.setVisibilityBox=function(e){var t=e/2;this.mesh._boundingInfo=new Tn.a(new a.e(-t,-t,-t),new a.e(t,t,t))},Object.defineProperty(e.prototype,\"isAlwaysVisible\",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"computeParticleRotation\",{set:function(e){this._computeParticleRotation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"computeParticleColor\",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"computeParticleTexture\",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"computeBoundingBox\",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!1,configurable:!0}),e.prototype.initParticles=function(){},e.prototype.recycleParticle=function(e){return e},e.prototype.updateParticle=function(e){return e},e.prototype.beforeUpdateParticles=function(e,t,i){},e.prototype.afterUpdateParticles=function(e,t,i){},e}();Q.a.prototype.getPhysicsEngine=function(){return this._physicsEngine},Q.a.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var i=this._getComponent(Me.a.NAME_PHYSICSENGINE);i||(i=new Dd(this),this._addComponent(i));try{return this._physicsEngine=new pc(e,t),this._physicsTimeAccumulator=0,!0}catch(e){return m.a.Error(e.message),!1}},Q.a.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},Q.a.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},Q.a.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},Q.a.prototype._advancePhysicsEngineStep=function(e){if(this._physicsEngine){var t=this._physicsEngine.getSubTimeStep();if(t>0)for(this._physicsTimeAccumulator+=e;this._physicsTimeAccumulator>t;)this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(t/1e3),this.onAfterPhysicsObservable.notifyObservers(this),this._physicsTimeAccumulator-=t;else this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(e/1e3),this.onAfterPhysicsObservable.notifyObservers(this)}},Object.defineProperty(Ge.a.prototype,\"physicsImpostor\",{get:function(){return this._physicsImpostor},set:function(e){var t=this;this._physicsImpostor!==e&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsImpostor=e,e&&(this._disposePhysicsObserver=this.onDisposeObservable.add((function(){t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)}))))},enumerable:!0,configurable:!0}),Ge.a.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},Ge.a.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},Ge.a.prototype.setPhysicsLinkWith=function(e,t,i,n){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,fc.e.HingeJoint,{mainPivot:t,connectedPivot:i,nativeParams:n}),this):this};var Md,Id,Dd=function(){function e(e){var t=this;this.name=Me.a.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new o.c,this.scene.onAfterPhysicsObservable=new o.c,this.scene.getDeterministicFrameTime=function(){return t.scene._physicsEngine?1e3*t.scene._physicsEngine.getTimeStep():1e3/60}}return e.prototype.register=function(){},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},e}(),Nd=function(){function e(e){this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||m.a.Warn(\"Physics engine not enabled. Please enable the physics before you can use the methods.\")}return e.prototype.applyRadialExplosionImpulse=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn(\"Physics engine not enabled. Please enable the physics before you call this method.\"),null;var r=this._physicsEngine.getImpostors();if(0===r.length)return null;\"number\"==typeof t&&((t=new Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var o=new Ld(this._scene,t),a=Array();return r.forEach((function(t){var i=o.getImpostorHitData(t,e);i&&(t.applyImpulse(i.force,i.contactPoint),a.push({impostor:t,hitData:i}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.applyRadialExplosionForce=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn(\"Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.\"),null;var r=this._physicsEngine.getImpostors();if(0===r.length)return null;\"number\"==typeof t&&((t=new Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var o=new Ld(this._scene,t),a=Array();return r.forEach((function(t){var i=o.getImpostorHitData(t,e);i&&(t.applyForce(i.force,i.contactPoint),a.push({impostor:t,hitData:i}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.gravitationalField=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn(\"Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.\"),null;if(0===this._physicsEngine.getImpostors().length)return null;\"number\"==typeof t&&((t=new Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var r=new wd(this,this._scene,e,t);return r.dispose(!1),r},e.prototype.updraft=function(e,t,i,n,r){if(!this._physicsEngine)return m.a.Warn(\"Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.\"),null;if(0===this._physicsEngine.getImpostors().length)return null;\"number\"==typeof t&&((t=new Vd).radius=t,t.strength=i||t.strength,t.height=n||t.height,t.updraftMode=r||t.updraftMode);var o=new Fd(this._scene,e,t);return o.dispose(!1),o},e.prototype.vortex=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn(\"Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.\"),null;if(0===this._physicsEngine.getImpostors().length)return null;\"number\"==typeof t&&((t=new kd).radius=t,t.strength=i||t.strength,t.height=n||t.height);var r=new Bd(this._scene,e,t);return r.dispose(!1),r},e}(),Ld=function(){function e(e,t){this._scene=e,this._options=t,this._dataFetched=!1,this._options=Object(h.a)(Object(h.a)({},new Ud),this._options)}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.getImpostorHitData=function(e,t){if(0===e.mass)return null;if(!this._intersectsWithSphere(e,t,this._options.radius))return null;if(\"Mesh\"!==e.object.getClassName()&&\"InstancedMesh\"!==e.object.getClassName())return null;var i=e.getObjectCenter().subtract(t),n=new Xt.a(t,i,this._options.radius).intersectsMesh(e.object).pickedPoint;if(!n)return null;var r=a.e.Distance(t,n);if(r>this._options.radius)return null;var o=this._options.falloff===Md.Constant?this._options.strength:this._options.strength*(1-r/this._options.radius);return{force:i.multiplyByFloats(o,o,o),contactPoint:n,distanceFromOrigin:r}},e.prototype.triggerAffectedImpostorsCallback=function(e){this._options.affectedImpostorsCallback&&this._options.affectedImpostorsCallback(e)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0)},e.prototype._prepareSphere=function(){this._sphere||(this._sphere=xr.a.CreateSphere(\"radialExplosionEventSphere\",this._options.sphere,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,i){var n=e.object;return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling=new a.e(2*i,2*i,2*i),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(n,!0)},e}(),wd=function(){function e(e,t,i,n){this._physicsHelper=e,this._scene=t,this._origin=i,this._options=n,this._dataFetched=!1,this._options=Object(h.a)(Object(h.a)({},new Ud),this._options),this._tickCallback=this._tick.bind(this),this._options.strength=-1*this._options.strength}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0)},e.prototype._tick=function(){if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);else{var e=this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);e&&(this._sphere=e.getData().sphere.clone(\"radialExplosionEventSphereClone\"))}},e}(),Fd=function(){function e(e,t,i){this._scene=e,this._origin=t,this._options=i,this._originTop=a.e.Zero(),this._originDirection=a.e.Zero(),this._cylinderPosition=a.e.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(h.a)(Object(h.a)({},new Vd),this._options),this._origin.addToRef(new a.e(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new a.e(0,this._options.height,0),this._originTop),this._options.updraftMode===Id.Perpendicular&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=this._tick.bind(this),this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),this._cylinder&&(e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0))},e.prototype.getImpostorHitData=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;var t=e.getObjectCenter();if(this._options.updraftMode===Id.Perpendicular)var i=this._originDirection;else i=t.subtract(this._originTop);var n=a.e.Distance(this._origin,t),r=-1*this._options.strength;return{force:i.multiplyByFloats(r,r,r),contactPoint:t,distanceFromOrigin:n}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var i=e.getImpostorHitData(t);i&&t.applyForce(i.force,i.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=nn.a.CreateCylinder(\"updraftEventCylinder\",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),Bd=function(){function e(e,t,i){this._scene=e,this._origin=t,this._options=i,this._originTop=a.e.Zero(),this._cylinderPosition=a.e.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(h.a)(Object(h.a)({},new kd),this._options),this._origin.addToRef(new a.e(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new a.e(0,this._options.height,0),this._originTop),this._tickCallback=this._tick.bind(this),this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0)},e.prototype.getImpostorHitData=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;if(\"Mesh\"!==e.object.getClassName()&&\"InstancedMesh\"!==e.object.getClassName())return null;var t=e.getObjectCenter(),i=new a.e(this._origin.x,t.y,this._origin.z),n=t.subtract(i),r=new Xt.a(i,n,this._options.radius).intersectsMesh(e.object),o=r.pickedPoint;if(!o)return null;var s=r.distance/this._options.radius,c=o.normalize();if(s>this._options.centripetalForceThreshold&&(c=c.negate()),s>this._options.centripetalForceThreshold)var l=c.x*this._options.centripetalForceMultiplier,u=c.y*this._options.updraftForceMultiplier,h=c.z*this._options.centripetalForceMultiplier;else{var d=a.e.Cross(i,t).normalize();l=(d.x+c.x)*this._options.centrifugalForceMultiplier,u=this._originTop.y*this._options.updraftForceMultiplier,h=(d.z+c.z)*this._options.centrifugalForceMultiplier}var f=new a.e(l,u,h);return{force:f=f.multiplyByFloats(this._options.strength,this._options.strength,this._options.strength),contactPoint:t,distanceFromOrigin:s}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var i=e.getImpostorHitData(t);i&&t.applyForce(i.force,i.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=nn.a.CreateCylinder(\"vortexEventCylinder\",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),Ud=function(){this.radius=5,this.strength=10,this.falloff=Md.Constant,this.sphere={segments:32,diameter:1}},Vd=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=Id.Center},kd=function(){this.radius=5,this.strength=10,this.height=10,this.centripetalForceThreshold=.7,this.centripetalForceMultiplier=5,this.centrifugalForceMultiplier=.5,this.updraftForceMultiplier=.02};!function(e){e[e.Constant=0]=\"Constant\",e[e.Linear=1]=\"Linear\"}(Md||(Md={})),function(e){e[e.Center=0]=\"Center\",e[e.Perpendicular=1]=\"Perpendicular\"}(Id||(Id={}));var zd=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\nuniform float degree;\\nvoid main(void)\\n{\\nvec3 color=texture2D(textureSampler,vUV).rgb;\\nfloat luminance=dot(color,vec3(0.3,0.59,0.11));\\nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\\n}\";ai.a.ShadersStore.blackAndWhitePixelShader=zd;var Gd=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,\"blackAndWhite\",[\"degree\"],null,i,n,r,o,a)||this;return s.degree=1,s.onApplyObservable.add((function(e){e.setFloat(\"degree\",s.degree)})),s}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"BlackAndWhitePostProcess\"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,\"degree\",void 0),t}(li);c.a.RegisteredTypes[\"BABYLON.BlackAndWhitePostProcess\"]=Gd;var jd=function(){function e(e,t,i,n){this._name=t,this._singleInstance=n||!0,this._getPostProcesses=i,this._cameras={},this._indicesForCamera={},this._postProcesses={}}return Object.defineProperty(e.prototype,\"isSupported\",{get:function(){for(var e in this._postProcesses)if(this._postProcesses.hasOwnProperty(e))for(var t=this._postProcesses[e],i=0;i\\n\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\nuniform float threshold;\\nuniform float exposure;\\nvoid main(void)\\n{\\ngl_FragColor=texture2D(textureSampler,vUV);\\nfloat luma=getLuminance(gl_FragColor.rgb*exposure);\\ngl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;\\n}\";ai.a.ShadersStore.extractHighlightsPixelShader=Wd;var Hd=function(e){function t(t,i,n,r,o,a,s,c){void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,\"extractHighlights\",[\"threshold\",\"exposure\"],null,i,n,r,o,a,null,s,void 0,null,c)||this;return l.threshold=.9,l._exposure=1,l._inputPostProcess=null,l.onApplyObservable.add((function(e){l._inputPostProcess&&e.setTextureFromPostProcess(\"textureSampler\",l._inputPostProcess),e.setFloat(\"threshold\",Math.pow(l.threshold,Nt.b)),e.setFloat(\"exposure\",l._exposure)})),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"ExtractHighlightsPostProcess\"},Object(h.c)([Object(w.c)()],t.prototype,\"threshold\",void 0),t}(li);c.a.RegisteredTypes[\"BABYLON.ExtractHighlightsPostProcess\"]=Hd;var Xd=\"uniform sampler2D textureSampler;\\nuniform sampler2D bloomBlur;\\nvarying vec2 vUV;\\nuniform float bloomWeight;\\nvoid main(void)\\n{\\ngl_FragColor=texture2D(textureSampler,vUV);\\nvec3 blurred=texture2D(bloomBlur,vUV).rgb;\\ngl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight);\\n}\\n\";ai.a.ShadersStore.bloomMergePixelShader=Xd;var Yd=function(e){function t(t,i,n,r,o,a,s,c,l,u,h){void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var d=e.call(this,t,\"bloomMerge\",[\"bloomWeight\"],[\"circleOfConfusionSampler\",\"blurStep0\",\"blurStep1\",\"blurStep2\",\"bloomBlur\"],o,a,s,c,l,null,u,void 0,null,!0)||this;return d.weight=1,d.weight=r,d.onApplyObservable.add((function(e){e.setTextureFromPostProcess(\"textureSampler\",i),e.setTextureFromPostProcessOutput(\"bloomBlur\",n),e.setFloat(\"bloomWeight\",d.weight)})),h||d.updateEffect(),d}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"BloomMergePostProcess\"},Object(h.c)([Object(w.c)()],t.prototype,\"weight\",void 0),t}(li);c.a.RegisteredTypes[\"BABYLON.BloomMergePostProcess\"]=Yd;var Kd=function(e){function t(t,i,n,r,o,s){void 0===o&&(o=0),void 0===s&&(s=!1);var c=e.call(this,t.getEngine(),\"bloom\",(function(){return c._effects}),!0)||this;return c.bloomScale=i,c._effects=[],c._downscale=new Hd(\"highlights\",1,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,s),c._blurX=new eo(\"horizontal blur\",new a.d(1,0),10,i,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,void 0,s),c._blurX.alwaysForcePOT=!0,c._blurX.autoClear=!1,c._blurY=new eo(\"vertical blur\",new a.d(0,1),10,i,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,void 0,s),c._blurY.alwaysForcePOT=!0,c._blurY.autoClear=!1,c.kernel=r,c._effects=[c._downscale,c._blurX,c._blurY],c._merge=new Yd(\"bloomMerge\",c._downscale,c._blurY,n,i,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,s),c._merge.autoClear=!1,c._effects.push(c._merge),c}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"threshold\",{get:function(){return this._downscale.threshold},set:function(e){this._downscale.threshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"weight\",{get:function(){return this._merge.weight},set:function(e){this._merge.weight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"kernel\",{get:function(){return this._blurX.kernel/this.bloomScale},set:function(e){this._blurX.kernel=e*this.bloomScale,this._blurY.kernel=e*this.bloomScale},enumerable:!1,configurable:!0}),t.prototype.disposeEffects=function(e){for(var t=0;t0\\nuniform sampler2D blurStep1;\\n#endif\\n#if BLUR_LEVEL>1\\nuniform sampler2D blurStep2;\\n#endif\\nvoid main(void)\\n{\\nfloat coc=texture2D(circleOfConfusionSampler,vUV).r;\\n#if BLUR_LEVEL == 0\\nvec4 original=texture2D(textureSampler,vUV);\\nvec4 blurred0=texture2D(blurStep0,vUV);\\ngl_FragColor=mix(original,blurred0,coc);\\n#endif\\n#if BLUR_LEVEL == 1\\nif(coc<0.5){\\nvec4 original=texture2D(textureSampler,vUV);\\nvec4 blurred1=texture2D(blurStep1,vUV);\\ngl_FragColor=mix(original,blurred1,coc/0.5);\\n}else{\\nvec4 blurred0=texture2D(blurStep0,vUV);\\nvec4 blurred1=texture2D(blurStep1,vUV);\\ngl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);\\n}\\n#endif\\n#if BLUR_LEVEL == 2\\nif(coc<0.33){\\nvec4 original=texture2D(textureSampler,vUV);\\nvec4 blurred2=texture2D(blurStep2,vUV);\\ngl_FragColor=mix(original,blurred2,coc/0.33);\\n}else if(coc<0.66){\\nvec4 blurred1=texture2D(blurStep1,vUV);\\nvec4 blurred2=texture2D(blurStep2,vUV);\\ngl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);\\n}else{\\nvec4 blurred0=texture2D(blurStep0,vUV);\\nvec4 blurred1=texture2D(blurStep1,vUV);\\ngl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);\\n}\\n#endif\\n}\\n\";ai.a.ShadersStore.depthOfFieldMergePixelShader=of;var af,sf=function(){},cf=function(e){function t(t,i,n,r,o,a,s,c,l,u,h){void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var d=e.call(this,t,\"depthOfFieldMerge\",[],[\"circleOfConfusionSampler\",\"blurStep0\",\"blurStep1\",\"blurStep2\"],o,a,s,c,l,null,u,void 0,null,!0)||this;return d.blurSteps=r,d.onApplyObservable.add((function(e){e.setTextureFromPostProcess(\"textureSampler\",i),e.setTextureFromPostProcessOutput(\"circleOfConfusionSampler\",n),r.forEach((function(t,i){e.setTextureFromPostProcessOutput(\"blurStep\"+(r.length-i-1),t)}))})),h||d.updateEffect(),d}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"DepthOfFieldMergePostProcess\"},t.prototype.updateEffect=function(t,i,n,r,o,a){void 0===t&&(t=null),void 0===i&&(i=null),void 0===n&&(n=null),t||(t=\"\",t+=\"#define BLUR_LEVEL \"+(this.blurSteps.length-1)+\"\\n\"),e.prototype.updateEffect.call(this,t,i,n,r,o,a)},t}(li);!function(e){e[e.Low=0]=\"Low\",e[e.Medium=1]=\"Medium\",e[e.High=2]=\"High\"}(af||(af={}));var lf=function(e){function t(t,i,n,r,o){void 0===n&&(n=af.Low),void 0===r&&(r=0),void 0===o&&(o=!1);var s=e.call(this,t.getEngine(),\"depth of field\",(function(){return s._effects}),!0)||this;s._effects=[],s._circleOfConfusion=new Jd(\"circleOfConfusion\",i,1,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o),s._depthOfFieldBlurY=[],s._depthOfFieldBlurX=[];var c=1,l=15;switch(n){case af.High:c=3,l=51;break;case af.Medium:c=2,l=31;break;default:l=15,c=1}for(var u=l/Math.pow(2,c-1),h=1,d=0;d=edgeVert;\\nfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\\nif (!horzSpan)\\n{\\nlumaN=lumaW;\\n}\\nif (!horzSpan)\\n{\\nlumaS=lumaE;\\n}\\nif (horzSpan)\\n{\\nlengthSign=texelSize.y;\\n}\\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\\nfloat gradientN=lumaN-lumaM;\\nfloat gradientS=lumaS-lumaM;\\nfloat lumaNN=lumaN+lumaM;\\nfloat lumaSS=lumaS+lumaM;\\nbool pairN=abs(gradientN)>=abs(gradientS);\\nfloat gradient=max(abs(gradientN),abs(gradientS));\\nif (pairN)\\n{\\nlengthSign=-lengthSign;\\n}\\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\\nvec2 posB;\\nposB.x=posM.x;\\nposB.y=posM.y;\\nvec2 offNP;\\noffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\\noffNP.y=(horzSpan) ? 0.0 : texelSize.y;\\nif (!horzSpan)\\n{\\nposB.x+=lengthSign*0.5;\\n}\\nif (horzSpan)\\n{\\nposB.y+=lengthSign*0.5;\\n}\\nvec2 posN;\\nposN.x=posB.x-offNP.x*1.5;\\nposN.y=posB.y-offNP.y*1.5;\\nvec2 posP;\\nposP.x=posB.x+offNP.x*1.5;\\nposP.y=posB.y+offNP.y*1.5;\\nfloat subpixD=((-2.0)*subpixC)+3.0;\\nfloat lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));\\nfloat subpixE=subpixC*subpixC;\\nfloat lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));\\nif (!pairN)\\n{\\nlumaNN=lumaSS;\\n}\\nfloat gradientScaled=gradient*1.0/4.0;\\nfloat lumaMM=lumaM-lumaNN*0.5;\\nfloat subpixF=subpixD*subpixE;\\nbool lumaMLTZero=lumaMM<0.0;\\nlumaEndN-=lumaNN*0.5;\\nlumaEndP-=lumaNN*0.5;\\nbool doneN=abs(lumaEndN)>=gradientScaled;\\nbool doneP=abs(lumaEndP)>=gradientScaled;\\nif (!doneN)\\n{\\nposN.x-=offNP.x*3.0;\\n}\\nif (!doneN)\\n{\\nposN.y-=offNP.y*3.0;\\n}\\nbool doneNP=(!doneN) || (!doneP);\\nif (!doneP)\\n{\\nposP.x+=offNP.x*3.0;\\n}\\nif (!doneP)\\n{\\nposP.y+=offNP.y*3.0;\\n}\\nif (doneNP)\\n{\\nif (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));\\nif (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));\\nif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\\nif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\\ndoneN=abs(lumaEndN)>=gradientScaled;\\ndoneP=abs(lumaEndP)>=gradientScaled;\\nif (!doneN) posN.x-=offNP.x*12.0;\\nif (!doneN) posN.y-=offNP.y*12.0;\\ndoneNP=(!doneN) || (!doneP);\\nif (!doneP) posP.x+=offNP.x*12.0;\\nif (!doneP) posP.y+=offNP.y*12.0;\\n}\\nfloat dstN=posM.x-posN.x;\\nfloat dstP=posP.x-posM.x;\\nif (!horzSpan)\\n{\\ndstN=posM.y-posN.y;\\n}\\nif (!horzSpan)\\n{\\ndstP=posP.y-posM.y;\\n}\\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\\nfloat spanLength=(dstP+dstN);\\nbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\\nfloat spanLengthRcp=1.0/spanLength;\\nbool directionN=dstN-1?\"#define MALI 1\\n\":null},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);c.a.RegisteredTypes[\"BABYLON.FxaaPostProcess\"]=mf;var gf=\"#include\\n\\nuniform sampler2D textureSampler;\\n\\nuniform float intensity;\\nuniform float animatedSeed;\\n\\nvarying vec2 vUV;\\nvoid main(void)\\n{\\ngl_FragColor=texture2D(textureSampler,vUV);\\nvec2 seed=vUV*(animatedSeed);\\nfloat grain=dither(seed,intensity);\\n\\nfloat lum=getLuminance(gl_FragColor.rgb);\\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\\ngl_FragColor.rgb+=grain*grainAmount;\\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\\n}\";ai.a.ShadersStore.grainPixelShader=gf;var vf=function(e){function t(t,i,n,r,o,a,s,c){void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,\"grain\",[\"intensity\",\"animatedSeed\"],[],i,n,r,o,a,null,s,void 0,null,c)||this;return l.intensity=30,l.animated=!1,l.onApplyObservable.add((function(e){e.setFloat(\"intensity\",l.intensity),e.setFloat(\"animatedSeed\",l.animated?Math.random()+1:1)})),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"GrainPostProcess\"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,\"intensity\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"animated\",void 0),t}(li);c.a.RegisteredTypes[\"BABYLON.GrainPostProcess\"]=vf;var bf=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\\nvoid main(void)\\n{\\nvec4 tex=texture2D(textureSampler,vUV);\\nvec3 c=tex.rgb;\\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\\n\\n\\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a);\\n}\";ai.a.ShadersStore.highlightsPixelShader=bf;var yf=function(e){function t(t,i,n,r,o,a,s){return void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),e.call(this,t,\"highlights\",null,null,i,n,r,o,a,null,s)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"HighlightsPostProcess\"},t}(li);ai.a.IncludesShadersStore.mrtFragmentDeclaration=\"#if __VERSION__>=200\\nlayout(location=0) out vec4 glFragData[{X}];\\n#endif\\n\";var Tf=\"#extension GL_EXT_draw_buffers : require\\n#if defined(BUMP) || !defined(NORMAL)\\n#extension GL_OES_standard_derivatives : enable\\n#endif\\nprecision highp float;\\nprecision highp int;\\n#ifdef BUMP\\nvarying mat4 vWorldView;\\nvarying vec3 vNormalW;\\n#else\\nvarying vec3 vNormalV;\\n#endif\\nvarying vec4 vViewPos;\\n#if defined(POSITION) || defined(BUMP)\\nvarying vec3 vPositionW;\\n#endif\\n#ifdef VELOCITY\\nvarying vec4 vCurrentPosition;\\nvarying vec4 vPreviousPosition;\\n#endif\\n#ifdef NEED_UV\\nvarying vec2 vUV;\\n#endif\\n#ifdef BUMP\\nuniform vec3 vBumpInfos;\\nuniform vec2 vTangentSpaceParams;\\n#endif\\n#ifdef REFLECTIVITY\\nvarying vec2 vReflectivityUV;\\nuniform sampler2D reflectivitySampler;\\n#endif\\n#ifdef ALPHATEST\\nuniform sampler2D diffuseSampler;\\n#endif\\n#include[RENDER_TARGET_COUNT]\\n#include\\n#include\\nvoid main() {\\n#ifdef ALPHATEST\\nif (texture2D(diffuseSampler,vUV).a<0.4)\\ndiscard;\\n#endif\\nvec3 normalOutput;\\n#ifdef BUMP\\nvec3 normalW=normalize(vNormalW);\\n#include\\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\\n#else\\nnormalOutput=normalize(vNormalV);\\n#endif\\n#ifdef PREPASS\\n#ifdef PREPASS_DEPTHNORMAL\\ngl_FragData[DEPTHNORMAL_INDEX]=vec4(vViewPos.z/vViewPos.w,normalOutput);\\n#endif\\n#else\\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\\ngl_FragData[1]=vec4(normalOutput,1.0);\\n#endif\\n#ifdef POSITION\\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\\n#endif\\n#ifdef VELOCITY\\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\\nvec2 velocity=abs(a-b);\\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\\n#endif\\n#ifdef REFLECTIVITY\\n#ifdef HAS_SPECULAR\\n\\nvec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV);\\n#elif HAS_REFLECTIVITY\\n\\nvec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0);\\n#else\\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\\n#endif\\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\\n#endif\\n}\";ai.a.ShadersStore.geometryPixelShader=Tf;var Ef=\"precision highp float;\\nprecision highp int;\\n#include\\n#include\\n#include[0..maxSimultaneousMorphTargets]\\n#include\\nattribute vec3 position;\\nattribute vec3 normal;\\n#ifdef NEED_UV\\nvarying vec2 vUV;\\n#ifdef ALPHATEST\\nuniform mat4 diffuseMatrix;\\n#endif\\n#ifdef BUMP\\nuniform mat4 bumpMatrix;\\nvarying vec2 vBumpUV;\\n#endif\\n#ifdef REFLECTIVITY\\nuniform mat4 reflectivityMatrix;\\nvarying vec2 vReflectivityUV;\\n#endif\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#endif\\n\\nuniform mat4 viewProjection;\\nuniform mat4 view;\\n#ifdef BUMP\\nvarying mat4 vWorldView;\\n#endif\\n#ifdef BUMP\\nvarying vec3 vNormalW;\\n#else\\nvarying vec3 vNormalV;\\n#endif\\nvarying vec4 vViewPos;\\n#if defined(POSITION) || defined(BUMP)\\nvarying vec3 vPositionW;\\n#endif\\n#ifdef VELOCITY\\nuniform mat4 previousWorld;\\nuniform mat4 previousViewProjection;\\n#ifdef BONES_VELOCITY_ENABLED\\n#if NUM_BONE_INFLUENCERS>0\\nuniform mat4 mPreviousBones[BonesPerMesh];\\n#endif\\n#endif\\nvarying vec4 vCurrentPosition;\\nvarying vec4 vPreviousPosition;\\n#endif\\nvoid main(void)\\n{\\nvec3 positionUpdated=position;\\nvec3 normalUpdated=normal;\\n#ifdef UV1\\nvec2 uvUpdated=uv;\\n#endif\\n#include[0..maxSimultaneousMorphTargets]\\n#include\\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\\n\\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\\n#endif\\n#include\\nvec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));\\n#ifdef BUMP\\nvWorldView=view*finalWorld;\\nvNormalW=normalUpdated;\\n#else\\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\\n#endif\\nvViewPos=view*pos;\\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\\n#if NUM_BONE_INFLUENCERS>0\\nmat4 previousInfluence;\\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\\n#if NUM_BONE_INFLUENCERS>1\\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\\n#endif\\n#if NUM_BONE_INFLUENCERS>2\\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\\n#endif\\n#if NUM_BONE_INFLUENCERS>3\\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\\n#endif\\n#if NUM_BONE_INFLUENCERS>4\\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\\n#endif\\n#if NUM_BONE_INFLUENCERS>5\\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\\n#endif\\n#if NUM_BONE_INFLUENCERS>6\\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\\n#endif\\n#if NUM_BONE_INFLUENCERS>7\\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\\n#endif\\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);\\n#else\\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\\n#endif\\n#endif\\n#if defined(POSITION) || defined(BUMP)\\nvPositionW=pos.xyz/pos.w;\\n#endif\\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\\n#ifdef NEED_UV\\n#ifdef UV1\\n#ifdef ALPHATEST\\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\\n#else\\nvUV=uv;\\n#endif\\n#ifdef BUMP\\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#ifdef REFLECTIVITY\\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#endif\\n#ifdef UV2\\n#ifdef ALPHATEST\\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n#else\\nvUV=uv2;\\n#endif\\n#ifdef BUMP\\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#ifdef REFLECTIVITY\\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#endif\\n#endif\\n#include\\n}\\n\";ai.a.ShadersStore.geometryVertexShader=Ef;var Sf=function(){function e(t,i){void 0===i&&(i=1),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._depthNormalIndex=-1,this._linkedWithPrePass=!1,this._scene=t,this._ratio=i,e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return e.prototype._linkPrePassRenderer=function(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add((function(e){})))},e.prototype._unlinkPrePassRenderer=function(){this._linkedWithPrePass=!1,this._createRenderTargets()},e.prototype._resetLayout=function(){this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._attachments=[]},e.prototype._forceTextureType=function(t,i){t===e.POSITION_TEXTURE_TYPE?(this._positionIndex=i,this._enablePosition=!0):t===e.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=i,this._enableVelocity=!0):t===e.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=i,this._enableReflectivity=!0):t===e.DEPTHNORMAL_TEXTURE_TYPE&&(this._depthNormalIndex=i)},e.prototype._setAttachments=function(e){this._attachments=e},e.prototype._linkInternalTexture=function(e){this._multiRenderTarget._texture=e},Object.defineProperty(e.prototype,\"renderList\",{get:function(){return this._multiRenderTarget.renderList},set:function(e){this._multiRenderTarget.renderList=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isSupported\",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!1,configurable:!0}),e.prototype.getTextureIndex=function(t){switch(t){case e.POSITION_TEXTURE_TYPE:return this._positionIndex;case e.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case e.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;default:return-1}},Object.defineProperty(e.prototype,\"enablePosition\",{get:function(){return this._enablePosition},set:function(e){this._enablePosition=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"enableVelocity\",{get:function(){return this._enableVelocity},set:function(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"enableReflectivity\",{get:function(){return this._enableReflectivity},set:function(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"scene\",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"ratio\",{get:function(){return this._ratio},enumerable:!1,configurable:!0}),e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;var n=[],r=[Qi.b.PositionKind,Qi.b.NormalKind],o=e.getMesh();if(i){var a=!1;i.needAlphaTesting()&&(n.push(\"#define ALPHATEST\"),a=!0),i.bumpTexture&&Wi.a.BumpTextureEnabled&&(n.push(\"#define BUMP\"),n.push(\"#define BUMPDIRECTUV 0\"),a=!0),this._enableReflectivity&&(i instanceof Wi.a&&i.specularTexture?(n.push(\"#define HAS_SPECULAR\"),a=!0):i instanceof ma&&i.reflectivityTexture&&(n.push(\"#define HAS_REFLECTIVITY\"),a=!0)),a&&(n.push(\"#define NEED_UV\"),o.isVerticesDataPresent(Qi.b.UVKind)&&(r.push(Qi.b.UVKind),n.push(\"#define UV1\")),o.isVerticesDataPresent(Qi.b.UV2Kind)&&(r.push(Qi.b.UV2Kind),n.push(\"#define UV2\")))}this._linkedWithPrePass&&(n.push(\"#define PREPASS\"),-1!==this._depthNormalIndex&&(n.push(\"#define DEPTHNORMAL_INDEX \"+this._depthNormalIndex),n.push(\"#define PREPASS_DEPTHNORMAL\"))),this._enablePosition&&(n.push(\"#define POSITION\"),n.push(\"#define POSITION_INDEX \"+this._positionIndex)),this._enableVelocity&&(n.push(\"#define VELOCITY\"),n.push(\"#define VELOCITY_INDEX \"+this._velocityIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(o)&&n.push(\"#define BONES_VELOCITY_ENABLED\")),this._enableReflectivity&&(n.push(\"#define REFLECTIVITY\"),n.push(\"#define REFLECTIVITY_INDEX \"+this._reflectivityIndex)),o.useBones&&o.computeBonesUsingShaders?(r.push(Qi.b.MatricesIndicesKind),r.push(Qi.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(r.push(Qi.b.MatricesIndicesExtraKind),r.push(Qi.b.MatricesWeightsExtraKind)),n.push(\"#define NUM_BONE_INFLUENCERS \"+o.numBoneInfluencers),n.push(\"#define BonesPerMesh \"+(o.skeleton?o.skeleton.bones.length+1:0))):n.push(\"#define NUM_BONE_INFLUENCERS 0\");var s=o.morphTargetManager,c=0;s&&s.numInfluencers>0&&(c=s.numInfluencers,n.push(\"#define MORPHTARGETS\"),n.push(\"#define NUM_MORPH_INFLUENCERS \"+c),ro.a.PrepareAttributesForMorphTargetsInfluencers(r,o,c)),t&&(n.push(\"#define INSTANCES\"),ro.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&n.push(\"#define THIN_INSTANCES\")),this._linkedWithPrePass?n.push(\"#define RENDER_TARGET_COUNT \"+this._attachments.length):n.push(\"#define RENDER_TARGET_COUNT \"+this._multiRenderTarget.textures.length);var l=n.join(\"\\n\");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this._scene.getEngine().createEffect(\"geometry\",r,[\"world\",\"mBones\",\"viewProjection\",\"diffuseMatrix\",\"view\",\"previousWorld\",\"previousViewProjection\",\"mPreviousBones\",\"morphTargetInfluences\",\"bumpMatrix\",\"reflectivityMatrix\",\"vTangentSpaceParams\",\"vBumpInfos\"],[\"diffuseSampler\",\"bumpSampler\",\"reflectivitySampler\"],l,void 0,void 0,void 0,{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:c})),this._effect.isReady()},e.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(e.prototype,\"samples\",{get:function(){return this._multiRenderTarget.samples},set:function(e){this._multiRenderTarget.samples=e},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null);this.getGBuffer().dispose()},e.prototype._assignRenderTargetIndices=function(){var e=2;return this._enablePosition&&(this._positionIndex=e,e++),this._enableVelocity&&(this._velocityIndex=e,e++),this._enableReflectivity&&(this._reflectivityIndex=e,e++),e},e.prototype._createRenderTargets=function(){var e=this,t=this._scene.getEngine(),i=this._assignRenderTargetIndices();if(this._multiRenderTarget=new Hc(\"gBuffer\",{width:t.getRenderWidth()*this._ratio,height:t.getRenderHeight()*this._ratio},i,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:g.a.TEXTURETYPE_FLOAT}),this.isSupported){this._multiRenderTarget.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(e){e.clear(new s.b(0,0,0,1),!0,!0,!0)})),this._resizeObserver=t.onResizeObservable.add((function(){e._multiRenderTarget&&e._multiRenderTarget.resize({width:t.getRenderWidth()*e._ratio,height:t.getRenderHeight()*e._ratio})}));var n=function(t){var i=t.getRenderingMesh(),n=t.getEffectiveMesh(),r=e._scene,o=r.getEngine(),s=t.getMaterial();if(s){if(n._internalAbstractMeshDataInfo._isActiveIntermediate=!1,e._enableVelocity&&!e._previousTransformationMatrices[n.uniqueId]&&(e._previousTransformationMatrices[n.uniqueId]={world:a.a.Identity(),viewProjection:r.getTransformMatrix()},i.skeleton)){var c=i.skeleton.getTransformMatrices(i);e._previousBonesTransformationMatrices[i.uniqueId]=e._copyBonesTransformationMatrices(c,new Float32Array(c.length))}var l=i._getInstancesRenderList(t._id,!!t.getReplacementMesh());if(!l.mustReturn){var u=o.getCaps().instancedArrays&&(null!==l.visibleInstances[t._id]||i.hasThinInstances),h=n.getWorldMatrix();if(e.isReady(t,u)){if(o.enableEffect(e._effect),i._bind(t,e._effect,s.fillMode),e._effect.setMatrix(\"viewProjection\",r.getTransformMatrix()),e._effect.setMatrix(\"view\",r.getViewMatrix()),s){var d,f=n._instanceDataStorage;if(f.isFrozen||!s.backFaceCulling&&null===s.overrideMaterialSideOrientation)d=f.sideOrientation;else{var p=n._getWorldMatrixDeterminant();null==(d=s.overrideMaterialSideOrientation)&&(d=s.sideOrientation),p<0&&(d=d===xo.a.ClockWiseSideOrientation?xo.a.CounterClockWiseSideOrientation:xo.a.ClockWiseSideOrientation)}if(s._preBind(e._effect,d),s.needAlphaTesting()){var _=s.getAlphaTestTexture();_&&(e._effect.setTexture(\"diffuseSampler\",_),e._effect.setMatrix(\"diffuseMatrix\",_.getTextureMatrix()))}s.bumpTexture&&r.getEngine().getCaps().standardDerivatives&&Wi.a.BumpTextureEnabled&&(e._effect.setFloat3(\"vBumpInfos\",s.bumpTexture.coordinatesIndex,1/s.bumpTexture.level,s.parallaxScaleBias),e._effect.setMatrix(\"bumpMatrix\",s.bumpTexture.getTextureMatrix()),e._effect.setTexture(\"bumpSampler\",s.bumpTexture),e._effect.setFloat2(\"vTangentSpaceParams\",s.invertNormalMapX?-1:1,s.invertNormalMapY?-1:1)),e._enableReflectivity&&(s instanceof Wi.a&&s.specularTexture?(e._effect.setMatrix(\"reflectivityMatrix\",s.specularTexture.getTextureMatrix()),e._effect.setTexture(\"reflectivitySampler\",s.specularTexture)):s instanceof ma&&s.reflectivityTexture&&(e._effect.setMatrix(\"reflectivityMatrix\",s.reflectivityTexture.getTextureMatrix()),e._effect.setTexture(\"reflectivitySampler\",s.reflectivityTexture)))}i.useBones&&i.computeBonesUsingShaders&&i.skeleton&&(e._effect.setMatrices(\"mBones\",i.skeleton.getTransformMatrices(i)),e._enableVelocity&&e._effect.setMatrices(\"mPreviousBones\",e._previousBonesTransformationMatrices[i.uniqueId])),ro.a.BindMorphTargetParameters(i,e._effect),e._enableVelocity&&(e._effect.setMatrix(\"previousWorld\",e._previousTransformationMatrices[n.uniqueId].world),e._effect.setMatrix(\"previousViewProjection\",e._previousTransformationMatrices[n.uniqueId].viewProjection)),i._processRendering(n,t,e._effect,s.fillMode,l,u,(function(t,i){return e._effect.setMatrix(\"world\",i)}))}e._enableVelocity&&(e._previousTransformationMatrices[n.uniqueId].world=h.clone(),e._previousTransformationMatrices[n.uniqueId].viewProjection=e._scene.getTransformMatrix().clone(),i.skeleton&&e._copyBonesTransformationMatrices(i.skeleton.getTransformMatrices(i),e._previousBonesTransformationMatrices[n.uniqueId]))}}};this._multiRenderTarget.customRenderFunction=function(i,r,o,a){var s;if(e._linkedWithPrePass){if(!e._prePassRenderer.enabled)return;e._scene.getEngine().bindAttachments(e._attachments)}if(a.length){for(t.setColorWrite(!1),s=0;s=samplesCount)\\nbreak;\\nvec2 offset=vUV+velocity*(hlim+float(i));\\nresult+=texture2D(textureSampler,offset);\\n}\\ngl_FragColor=result/float(samplesCount);\\ngl_FragColor.a=1.0;\\n#else\\nvec2 texelSize=1.0/screenSize;\\nfloat depth=texture2D(depthSampler,vUV).r;\\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\\ncpos=cpos*inverseViewProjection;\\nvec4 ppos=cpos*prevViewProjection;\\nppos.xyz/=ppos.w;\\nppos.xy=ppos.xy*0.5+0.5;\\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\\nfloat speed=length(velocity/texelSize);\\nint nSamples=int(clamp(speed,1.0,SAMPLES));\\nvec4 result=texture2D(textureSampler,vUV);\\nfor (int i=1; i=nSamples)\\nbreak;\\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\\nresult+=texture2D(textureSampler,offset1);\\n}\\ngl_FragColor=result/float(nSamples);\\n#endif\\n#else\\ngl_FragColor=texture2D(textureSampler,vUV);\\n#endif\\n}\\n\";ai.a.ShadersStore.motionBlurPixelShader=Cf;var Rf=function(e){function t(t,i,n,r,o,a,s,c,l,u){void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),void 0===u&&(u=!0);var h=e.call(this,t,\"motionBlur\",[\"motionStrength\",\"motionScale\",\"screenSize\",\"inverseViewProjection\",\"prevViewProjection\"],[\"velocitySampler\"],n,r,o,a,s,\"#define GEOMETRY_SUPPORTED\\n#define SAMPLES 64.0\\n#define OBJECT_BASED\",c,void 0,null,l)||this;return h.motionStrength=1,h._motionBlurSamples=32,h._isObjectBased=!0,h._forceGeometryBuffer=!1,h._geometryBufferRenderer=null,h._prePassRenderer=null,h._invViewProjection=null,h._previousViewProjection=null,h._forceGeometryBuffer=u,h._forceGeometryBuffer?(h._geometryBufferRenderer=i.enableGeometryBufferRenderer(),h._geometryBufferRenderer&&(h._geometryBufferRenderer.enableVelocity=!0)):(h._prePassRenderer=i.enablePrePassRenderer(),h._prePassRenderer&&(h._prePassRenderer.markAsDirty(),h._prePassEffectConfiguration=new Af)),h._applyMode(),h}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"motionBlurSamples\",{get:function(){return this._motionBlurSamples},set:function(e){this._motionBlurSamples=e,this._updateEffect()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"isObjectBased\",{get:function(){return this._isObjectBased},set:function(e){this._isObjectBased!==e&&(this._isObjectBased=e,this._applyMode())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"MotionBlurPostProcess\"},t.prototype.excludeSkinnedMesh=function(e){if(e.skeleton){var t=void 0;if(this._geometryBufferRenderer)t=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else{if(!this._prePassRenderer)return;t=this._prePassRenderer.excludedSkinnedMesh}t.push(e)}},t.prototype.removeExcludedSkinnedMesh=function(e){if(e.skeleton){var t=void 0;if(this._geometryBufferRenderer)t=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else{if(!this._prePassRenderer)return;t=this._prePassRenderer.excludedSkinnedMesh}var i=t.indexOf(e);-1!==i&&t.splice(i,1)}},t.prototype.dispose=function(t){this._geometryBufferRenderer&&(this._geometryBufferRenderer._previousTransformationMatrices={},this._geometryBufferRenderer._previousBonesTransformationMatrices={},this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity=[]),e.prototype.dispose.call(this,t)},t.prototype._applyMode=function(){var e=this;if(!this._geometryBufferRenderer&&!this._prePassRenderer)return m.a.Warn(\"Multiple Render Target support needed to compute object based motion blur\"),this.updateEffect();this._updateEffect(),this._invViewProjection=null,this._previousViewProjection=null,this.isObjectBased?(this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=g.a.PREPASS_VELOCITY_TEXTURE_TYPE),this.onApply=function(t){return e._onApplyObjectBased(t)}):(this._invViewProjection=a.a.Identity(),this._previousViewProjection=a.a.Identity(),this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE),this.onApply=function(t){return e._onApplyScreenBased(t)})},t.prototype._onApplyObjectBased=function(e){if(e.setVector2(\"screenSize\",new a.d(this.width,this.height)),e.setFloat(\"motionScale\",this._scene.getAnimationRatio()),e.setFloat(\"motionStrength\",this.motionStrength),this._geometryBufferRenderer){var t=this._geometryBufferRenderer.getTextureIndex(Sf.VELOCITY_TEXTURE_TYPE);e.setTexture(\"velocitySampler\",this._geometryBufferRenderer.getGBuffer().textures[t])}else if(this._prePassRenderer){t=this._prePassRenderer.getIndex(g.a.PREPASS_VELOCITY_TEXTURE_TYPE);e.setTexture(\"velocitySampler\",this._prePassRenderer.prePassRT.textures[t])}},t.prototype._onApplyScreenBased=function(e){var t=this._scene.getProjectionMatrix().multiply(this._scene.getViewMatrix());if(t.invertToRef(this._invViewProjection),e.setMatrix(\"inverseViewProjection\",this._invViewProjection),e.setMatrix(\"prevViewProjection\",this._previousViewProjection),this._previousViewProjection=t,e.setVector2(\"screenSize\",new a.d(this.width,this.height)),e.setFloat(\"motionScale\",this._scene.getAnimationRatio()),e.setFloat(\"motionStrength\",this.motionStrength),this._geometryBufferRenderer){var i=this._geometryBufferRenderer.getTextureIndex(Sf.DEPTHNORMAL_TEXTURE_TYPE);e.setTexture(\"depthSampler\",this._geometryBufferRenderer.getGBuffer().textures[i])}else if(this._prePassRenderer){i=this._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE);e.setTexture(\"depthSampler\",this._prePassRenderer.prePassRT.textures[i])}},t.prototype._updateEffect=function(){if(this._geometryBufferRenderer||this._prePassRenderer){var e=[\"#define GEOMETRY_SUPPORTED\",\"#define SAMPLES \"+this._motionBlurSamples.toFixed(1),this._isObjectBased?\"#define OBJECT_BASED\":\"#define SCREEN_BASED\"];this.updateEffect(e.join(\"\\n\"))}},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,!1)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,\"motionStrength\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"motionBlurSamples\",null),Object(h.c)([Object(w.c)()],t.prototype,\"isObjectBased\",null),t}(li);c.a.RegisteredTypes[\"BABYLON.MotionBlurPostProcess\"]=Rf;var xf=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\nuniform sampler2D refractionSampler;\\n\\nuniform vec3 baseColor;\\nuniform float depth;\\nuniform float colorLevel;\\nvoid main() {\\nfloat ref=1.0-texture2D(refractionSampler,vUV).r;\\nvec2 uv=vUV-vec2(0.5);\\nvec2 offset=uv*depth*ref;\\nvec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;\\ngl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);\\n}\";ai.a.ShadersStore.refractionPixelShader=xf;var Of=function(e){function t(t,i,n,r,o,a,s,c,l,u){var h=e.call(this,t,\"refraction\",[\"baseColor\",\"depth\",\"colorLevel\"],[\"refractionSampler\"],a,s,c,l,u)||this;return h._ownRefractionTexture=!0,h.color=n,h.depth=r,h.colorLevel=o,h.refractionTextureUrl=i,h.onActivateObservable.add((function(e){h._refTexture=h._refTexture||new Ke.a(i,e.getScene())})),h.onApplyObservable.add((function(e){e.setColor3(\"baseColor\",h.color),e.setFloat(\"depth\",h.depth),e.setFloat(\"colorLevel\",h.colorLevel),e.setTexture(\"refractionSampler\",h._refTexture)})),h}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"refractionTexture\",{get:function(){return this._refTexture},set:function(e){this._refTexture&&this._ownRefractionTexture&&this._refTexture.dispose(),this._refTexture=e,this._ownRefractionTexture=!1},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"RefractionPostProcess\"},t.prototype.dispose=function(t){this._refTexture&&this._ownRefractionTexture&&(this._refTexture.dispose(),this._refTexture=null),e.prototype.dispose.call(this,t)},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.refractionTextureUrl,e.color,e.depth,e.colorLevel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,\"color\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"depth\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"colorLevel\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"refractionTextureUrl\",void 0),t}(li);c.a.RegisteredTypes[\"BABYLON.RefractionPostProcess\"]=Of;var Mf=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\nuniform vec2 screenSize;\\nuniform vec2 sharpnessAmounts;\\nvoid main(void)\\n{\\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\\nvec4 color=texture2D(textureSampler,vUV);\\nvec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\\ncolor*4.0;\\ngl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);\\n}\";ai.a.ShadersStore.sharpenPixelShader=Mf;var If=function(e){function t(t,i,n,r,o,a,s,c){void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,\"sharpen\",[\"sharpnessAmounts\",\"screenSize\"],null,i,n,r,o,a,null,s,void 0,null,c)||this;return l.colorAmount=1,l.edgeAmount=.3,l.onApply=function(e){e.setFloat2(\"screenSize\",l.width,l.height),e.setFloat2(\"sharpnessAmounts\",l.edgeAmount,l.colorAmount)},l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"SharpenPostProcess\"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,\"colorAmount\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"edgeAmount\",void 0),t}(li);c.a.RegisteredTypes[\"BABYLON.SharpenPostProcess\"]=If;var Df=function(){function e(e,t){this.engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}return Object.defineProperty(e.prototype,\"name\",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"cameras\",{get:function(){return this._cameras},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return\"PostProcessRenderPipeline\"},Object.defineProperty(e.prototype,\"isSupported\",{get:function(){for(var e in this._renderEffects)if(this._renderEffects.hasOwnProperty(e)&&!this._renderEffects[e].isSupported)return!1;return!0},enumerable:!1,configurable:!0}),e.prototype.addEffect=function(e){this._renderEffects[e._name]=e},e.prototype._rebuild=function(){},e.prototype._enableEffect=function(e,t){var i=this._renderEffects[e];i&&i._enable(Ce.b.MakeArray(t||this._cameras))},e.prototype._disableEffect=function(e,t){var i=this._renderEffects[e];i&&i._disable(Ce.b.MakeArray(t||this._cameras))},e.prototype._attachCameras=function(e,t){var i=Ce.b.MakeArray(e||this._cameras);if(i){var n,r=[];for(n=0;n0){var i=this._renderEffects[t[0]].getPostProcesses();i&&(i[0].samples=e)}return!0},e.prototype.setPrePassRenderer=function(e){return!1},e.prototype.dispose=function(){},Object(h.c)([Object(w.c)()],e.prototype,\"_name\",void 0),e}(),Nf=function(){function e(){this._renderPipelines={}}return Object.defineProperty(e.prototype,\"supportedPipelines\",{get:function(){var e=[];for(var t in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(t)){var i=this._renderPipelines[t];i.isSupported&&e.push(i)}return e},enumerable:!1,configurable:!0}),e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){void 0===i&&(i=!1);var n=this._renderPipelines[e];n&&n._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var n=this._renderPipelines[e];n&&n._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var n=this._renderPipelines[e];n&&n._disableEffect(t,i)},e.prototype.update=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e.prototype._rebuild=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e]._rebuild()}},e.prototype.dispose=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e].dispose()}},e}();Object.defineProperty(Q.a.prototype,\"postProcessRenderPipelineManager\",{get:function(){if(!this._postProcessRenderPipelineManager){var e=this._getComponent(Me.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new Lf(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new Nf}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var Lf=function(){function e(e){this.name=Me.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Me.a.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)},e.prototype.rebuild=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()},e.prototype.dispose=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()},e.prototype._gatherRenderTargets=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()},e}(),wf=function(e){function t(t,i,n,r,a){void 0===t&&(t=\"\"),void 0===i&&(i=!0),void 0===n&&(n=x.a.LastCreatedScene),void 0===a&&(a=!0);var s=e.call(this,n.getEngine(),t)||this;s._camerasToBeAttached=[],s.SharpenPostProcessId=\"SharpenPostProcessEffect\",s.ImageProcessingPostProcessId=\"ImageProcessingPostProcessEffect\",s.FxaaPostProcessId=\"FxaaPostProcessEffect\",s.ChromaticAberrationPostProcessId=\"ChromaticAberrationPostProcessEffect\",s.GrainPostProcessId=\"GrainPostProcessEffect\",s._glowLayer=null,s.animations=[],s._imageProcessingConfigurationObserver=null,s._sharpenEnabled=!1,s._bloomEnabled=!1,s._depthOfFieldEnabled=!1,s._depthOfFieldBlurLevel=af.Low,s._fxaaEnabled=!1,s._imageProcessingEnabled=!0,s._bloomScale=.5,s._chromaticAberrationEnabled=!1,s._grainEnabled=!1,s._buildAllowed=!0,s.onBuildObservable=new o.c,s._resizeObserver=null,s._hardwareScaleLevel=1,s._bloomKernel=64,s._bloomWeight=.15,s._bloomThreshold=.9,s._samples=1,s._hasCleared=!1,s._prevPostProcess=null,s._prevPrevPostProcess=null,s._depthOfFieldSceneObserver=null,s._cameras=r||n.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._buildAllowed=a,s._scene=n;var c=s._scene.getEngine().getCaps();s._hdr=i&&(c.textureHalfFloatRender||c.textureFloatRender),s._hdr?c.textureHalfFloatRender?s._defaultPipelineTextureType=g.a.TEXTURETYPE_HALF_FLOAT:c.textureFloatRender&&(s._defaultPipelineTextureType=g.a.TEXTURETYPE_FLOAT):s._defaultPipelineTextureType=g.a.TEXTURETYPE_UNSIGNED_INT,n.postProcessRenderPipelineManager.addPipeline(s);var l=s._scene.getEngine();return s.sharpen=new If(\"sharpen\",1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._sharpenEffect=new jd(l,s.SharpenPostProcessId,(function(){return s.sharpen}),!0),s.depthOfField=new lf(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),s.bloom=new Kd(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),s.chromaticAberration=new qd(\"ChromaticAberration\",l.getRenderWidth(),l.getRenderHeight(),1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._chromaticAberrationEffect=new jd(l,s.ChromaticAberrationPostProcessId,(function(){return s.chromaticAberration}),!0),s.grain=new vf(\"Grain\",1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._grainEffect=new jd(l,s.GrainPostProcessId,(function(){return s.grain}),!0),s._resizeObserver=l.onResizeObservable.add((function(){s._hardwareScaleLevel=l.getHardwareScalingLevel(),s.bloomKernel=s.bloomKernel})),s._imageProcessingConfigurationObserver=s._scene.imageProcessingConfiguration.onUpdateParameters.add((function(){s.bloom._downscale._exposure=s._scene.imageProcessingConfiguration.exposure,s.imageProcessingEnabled!==s._scene.imageProcessingConfiguration.isEnabled&&(s._imageProcessingEnabled=s._scene.imageProcessingConfiguration.isEnabled,s._buildPipeline())})),s._buildPipeline(),s}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"scene\",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"sharpenEnabled\",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"bloomKernel\",{get:function(){return this._bloomKernel},set:function(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"bloomWeight\",{get:function(){return this._bloomWeight},set:function(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"bloomThreshold\",{get:function(){return this._bloomThreshold},set:function(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"bloomScale\",{get:function(){return this._bloomScale},set:function(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"bloomEnabled\",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new Kd(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var t=0;t1){for(var i=0,n=this._cameras;i-1&&(e.depthOfField.depthTexture=t.enableDepthRenderer(t.activeCamera).getDepthMap())}))}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);var o=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=o.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new Yi(\"imageProcessing\",1,null,Ke.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new jd(t,this.ImageProcessingPostProcessId,(function(){return e.imageProcessing}),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,this.cameras&&0!==this.cameras.length||(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new mf(\"fxaa\",1,null,Ke.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new jd(t,this.FxaaPostProcessId,(function(){return e.fxaa}),!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),this._scene.activeCameras&&this._scene.activeCameras.length>1&&(this._scene.autoClear=!0),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&m.a.Warn(\"MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0\"),this.onBuildObservable.notifyObservers(this)}},t.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t1.0) { lum_threshold=0.94+0.01*threshold; }\\nelse { lum_threshold=0.5+0.44*threshold; }\\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\\nhighlight*=luminance*gain;\\nhighlight.a=1.0;\\nreturn highlight;\\n}\\nvoid main(void)\\n{\\nvec4 original=texture2D(textureSampler,vUV);\\n\\nif (gain == -1.0) {\\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\\nreturn;\\n}\\nfloat w=2.0/screen_width;\\nfloat h=2.0/screen_height;\\nfloat weight=1.0;\\n\\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\\n#ifdef PENTAGON\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\\n#else\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\\n#endif\\nblurred/=39.0;\\ngl_FragColor=blurred;\\n\\n}\";ai.a.ShadersStore.lensHighlightsPixelShader=Ff;var Bf=\"\\n\\n\\n\\n\\nuniform sampler2D textureSampler;\\nuniform sampler2D highlightsSampler;\\nuniform sampler2D depthSampler;\\nuniform sampler2D grainSampler;\\n\\nuniform float grain_amount;\\nuniform bool blur_noise;\\nuniform float screen_width;\\nuniform float screen_height;\\nuniform float distortion;\\nuniform bool dof_enabled;\\n\\nuniform float screen_distance;\\nuniform float aperture;\\nuniform float darken;\\nuniform float edge_blur;\\nuniform bool highlights;\\n\\nuniform float near;\\nuniform float far;\\n\\nvarying vec2 vUV;\\n\\n#define PI 3.14159265\\n#define TWOPI 6.28318530\\n#define inverse_focal_length 0.1\\n\\nvec2 centered_screen_pos;\\nvec2 distorted_coords;\\nfloat radius2;\\nfloat radius;\\n\\nvec2 rand(vec2 co)\\n{\\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\\n}\\n\\nvec2 getDistortedCoords(vec2 coords) {\\nif (distortion == 0.0) { return coords; }\\nvec2 direction=1.0*normalize(centered_screen_pos);\\nvec2 dist_coords=vec2(0.5,0.5);\\ndist_coords.x=0.5+direction.x*radius2*1.0;\\ndist_coords.y=0.5+direction.y*radius2*1.0;\\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\\ndist_coords=mix(coords,dist_coords,dist_amount);\\nreturn dist_coords;\\n}\\n\\nfloat sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {\\n\\nvec2 coords=distorted_coords;\\nfloat angle=rand(coords*100.0).x*TWOPI;\\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\\ncolor+=texture2D(textureSampler,coords)*weight;\\nreturn weight;\\n}\\n\\nfloat getBlurLevel(float size) {\\nreturn min(3.0,ceil(size/1.0));\\n}\\n\\nvec4 getBlurColor(float size) {\\nvec4 col=texture2D(textureSampler,distorted_coords);\\nif (size == 0.0) { return col; }\\n\\n\\nfloat blur_level=getBlurLevel(size);\\nfloat w=(size/screen_width);\\nfloat h=(size/screen_height);\\nfloat total_weight=1.0;\\nvec2 sample_coords;\\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\\nif (blur_level>1.0) {\\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\\n}\\nif (blur_level>2.0) {\\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\\n}\\ncol/=total_weight;\\n\\nif (darken>0.0) {\\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\\n}\\n\\n\\n\\n\\nreturn col;\\n}\\nvoid main(void)\\n{\\n\\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\\nradius=sqrt(radius2);\\ndistorted_coords=getDistortedCoords(vUV);\\nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height);\\nfloat depth=texture2D(depthSampler,distorted_coords).r;\\nfloat distance=near+(far-near)*depth;\\nvec4 color=texture2D(textureSampler,vUV);\\n\\n\\nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\\n\\nif (dof_enabled == false || coc<0.07) { coc=0.0; }\\n\\nfloat edge_blur_amount=0.0;\\nif (edge_blur>0.0) {\\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\\n}\\n\\nfloat blur_amount=max(edge_blur_amount,coc);\\n\\nif (blur_amount == 0.0) {\\ngl_FragColor=texture2D(textureSampler,distorted_coords);\\n}\\nelse {\\n\\ngl_FragColor=getBlurColor(blur_amount*1.7);\\n\\nif (highlights) {\\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\\n}\\nif (blur_noise) {\\n\\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\\n}\\n}\\n\\nif (grain_amount>0.0) {\\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\\n}\\n}\\n\";ai.a.ShadersStore.depthOfFieldPixelShader=Bf;var Uf=function(e){function t(t,i,n,r,o){void 0===r&&(r=1);var a=e.call(this,n.getEngine(),t)||this;return a.LensChromaticAberrationEffect=\"LensChromaticAberrationEffect\",a.HighlightsEnhancingEffect=\"HighlightsEnhancingEffect\",a.LensDepthOfFieldEffect=\"LensDepthOfFieldEffect\",a._pentagonBokehIsEnabled=!1,a._scene=n,a._depthTexture=n.enableDepthRenderer().getDepthMap(),i.grain_texture?a._grainTexture=i.grain_texture:a._createGrainTexture(),a._edgeBlur=i.edge_blur?i.edge_blur:0,a._grainAmount=i.grain_amount?i.grain_amount:0,a._chromaticAberration=i.chromatic_aberration?i.chromatic_aberration:0,a._distortion=i.distortion?i.distortion:0,a._highlightsGain=void 0!==i.dof_gain?i.dof_gain:-1,a._highlightsThreshold=i.dof_threshold?i.dof_threshold:1,a._dofDistance=void 0!==i.dof_focus_distance?i.dof_focus_distance:-1,a._dofAperture=i.dof_aperture?i.dof_aperture:1,a._dofDarken=i.dof_darken?i.dof_darken:0,a._dofPentagon=void 0===i.dof_pentagon||i.dof_pentagon,a._blurNoise=void 0===i.blur_noise||i.blur_noise,a._createChromaticAberrationPostProcess(r),a._createHighlightsPostProcess(r),a._createDepthOfFieldPostProcess(r/4),a.addEffect(new jd(n.getEngine(),a.LensChromaticAberrationEffect,(function(){return a._chromaticAberrationPostProcess}),!0)),a.addEffect(new jd(n.getEngine(),a.HighlightsEnhancingEffect,(function(){return a._highlightsPostProcess}),!0)),a.addEffect(new jd(n.getEngine(),a.LensDepthOfFieldEffect,(function(){return a._depthOfFieldPostProcess}),!0)),-1===a._highlightsGain&&a._disableEffect(a.HighlightsEnhancingEffect,null),n.postProcessRenderPipelineManager.addPipeline(a),o&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t,o),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"LensRenderingPipeline\"},Object.defineProperty(t.prototype,\"scene\",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"edgeBlur\",{get:function(){return this._edgeBlur},set:function(e){this.setEdgeBlur(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"grainAmount\",{get:function(){return this._grainAmount},set:function(e){this.setGrainAmount(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"chromaticAberration\",{get:function(){return this._chromaticAberration},set:function(e){this.setChromaticAberration(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dofAperture\",{get:function(){return this._dofAperture},set:function(e){this.setAperture(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"edgeDistortion\",{get:function(){return this._distortion},set:function(e){this.setEdgeDistortion(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"dofDistortion\",{get:function(){return this._dofDistance},set:function(e){this.setFocusDistance(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"darkenOutOfFocus\",{get:function(){return this._dofDarken},set:function(e){this.setDarkenOutOfFocus(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"blurNoise\",{get:function(){return this._blurNoise},set:function(e){this._blurNoise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"pentagonBokeh\",{get:function(){return this._pentagonBokehIsEnabled},set:function(e){e?this.enablePentagonBokeh():this.disablePentagonBokeh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"highlightsGain\",{get:function(){return this._highlightsGain},set:function(e){this.setHighlightsGain(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"highlightsThreshold\",{get:function(){return this._highlightsThreshold},set:function(e){this.setHighlightsThreshold(e)},enumerable:!1,configurable:!0}),t.prototype.setEdgeBlur=function(e){this._edgeBlur=e},t.prototype.disableEdgeBlur=function(){this._edgeBlur=0},t.prototype.setGrainAmount=function(e){this._grainAmount=e},t.prototype.disableGrain=function(){this._grainAmount=0},t.prototype.setChromaticAberration=function(e){this._chromaticAberration=e},t.prototype.disableChromaticAberration=function(){this._chromaticAberration=0},t.prototype.setEdgeDistortion=function(e){this._distortion=e},t.prototype.disableEdgeDistortion=function(){this._distortion=0},t.prototype.setFocusDistance=function(e){this._dofDistance=e},t.prototype.disableDepthOfField=function(){this._dofDistance=-1},t.prototype.setAperture=function(e){this._dofAperture=e},t.prototype.setDarkenOutOfFocus=function(e){this._dofDarken=e},t.prototype.enablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect(\"#define PENTAGON\\n\"),this._pentagonBokehIsEnabled=!0},t.prototype.disablePentagonBokeh=function(){this._pentagonBokehIsEnabled=!1,this._highlightsPostProcess.updateEffect()},t.prototype.enableNoiseBlur=function(){this._blurNoise=!0},t.prototype.disableNoiseBlur=function(){this._blurNoise=!1},t.prototype.setHighlightsGain=function(e){this._highlightsGain=e},t.prototype.setHighlightsThreshold=function(e){-1===this._highlightsGain&&(this._highlightsGain=1),this._highlightsThreshold=e},t.prototype.disableHighlights=function(){this._highlightsGain=-1},t.prototype.dispose=function(e){void 0===e&&(e=!1),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._chromaticAberrationPostProcess=null,this._highlightsPostProcess=null,this._depthOfFieldPostProcess=null,this._grainTexture.dispose(),e&&this._scene.disableDepthRenderer()},t.prototype._createChromaticAberrationPostProcess=function(e){var t=this;this._chromaticAberrationPostProcess=new li(\"LensChromaticAberration\",\"chromaticAberration\",[\"chromatic_aberration\",\"screen_width\",\"screen_height\",\"direction\",\"radialIntensity\",\"centerPosition\"],[],e,null,Ke.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._chromaticAberrationPostProcess.onApply=function(e){e.setFloat(\"chromatic_aberration\",t._chromaticAberration),e.setFloat(\"screen_width\",t._scene.getEngine().getRenderWidth()),e.setFloat(\"screen_height\",t._scene.getEngine().getRenderHeight()),e.setFloat(\"radialIntensity\",1),e.setFloat2(\"direction\",17,17),e.setFloat2(\"centerPosition\",.5,.5)}},t.prototype._createHighlightsPostProcess=function(e){var t=this;this._highlightsPostProcess=new li(\"LensHighlights\",\"lensHighlights\",[\"gain\",\"threshold\",\"screen_width\",\"screen_height\"],[],e,null,Ke.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon?\"#define PENTAGON\\n\":\"\"),this._highlightsPostProcess.onApply=function(e){e.setFloat(\"gain\",t._highlightsGain),e.setFloat(\"threshold\",t._highlightsThreshold),e.setTextureFromPostProcess(\"textureSampler\",t._chromaticAberrationPostProcess),e.setFloat(\"screen_width\",t._scene.getEngine().getRenderWidth()),e.setFloat(\"screen_height\",t._scene.getEngine().getRenderHeight())}},t.prototype._createDepthOfFieldPostProcess=function(e){var t=this;this._depthOfFieldPostProcess=new li(\"LensDepthOfField\",\"depthOfField\",[\"grain_amount\",\"blur_noise\",\"screen_width\",\"screen_height\",\"distortion\",\"dof_enabled\",\"screen_distance\",\"aperture\",\"darken\",\"edge_blur\",\"highlights\",\"near\",\"far\"],[\"depthSampler\",\"grainSampler\",\"highlightsSampler\"],e,null,Ke.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._depthOfFieldPostProcess.onApply=function(e){e.setTexture(\"depthSampler\",t._depthTexture),e.setTexture(\"grainSampler\",t._grainTexture),e.setTextureFromPostProcess(\"textureSampler\",t._highlightsPostProcess),e.setTextureFromPostProcess(\"highlightsSampler\",t._depthOfFieldPostProcess),e.setFloat(\"grain_amount\",t._grainAmount),e.setBool(\"blur_noise\",t._blurNoise),e.setFloat(\"screen_width\",t._scene.getEngine().getRenderWidth()),e.setFloat(\"screen_height\",t._scene.getEngine().getRenderHeight()),e.setFloat(\"distortion\",t._distortion),e.setBool(\"dof_enabled\",-1!==t._dofDistance),e.setFloat(\"screen_distance\",1/(.1-1/t._dofDistance)),e.setFloat(\"aperture\",t._dofAperture),e.setFloat(\"darken\",t._dofDarken),e.setFloat(\"edge_blur\",t._edgeBlur),e.setBool(\"highlights\",-1!==t._highlightsGain),t._scene.activeCamera&&(e.setFloat(\"near\",t._scene.activeCamera.minZ),e.setFloat(\"far\",t._scene.activeCamera.maxZ))}},t.prototype._createGrainTexture=function(){this._grainTexture=new Hi.a(\"LensNoiseTexture\",512,this._scene,!1,Ke.a.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=Ke.a.WRAP_ADDRESSMODE,this._grainTexture.wrapV=Ke.a.WRAP_ADDRESSMODE;for(var e,t,i,n=this._grainTexture.getContext(),r=0;r<512;r++)for(var o=0;o<512;o++)e=Math.floor(255*(t=.42,i=.58,Math.random()*(i-t)+t)),n.fillStyle=\"rgb(\"+e+\", \"+e+\", \"+e+\")\",n.fillRect(r,o,1,1);this._grainTexture.update(!1)},t}(Df),Vf=function(){this.enabled=!1,this.name=\"ssao2\",this.texturesRequired=[g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE]},kf=\"\\nprecision highp float;\\nuniform sampler2D textureSampler;\\nuniform float near;\\nuniform float far;\\nuniform float radius;\\nfloat scales[16]=float[16](\\n0.1,\\n0.11406250000000001,\\n0.131640625,\\n0.15625,\\n0.187890625,\\n0.2265625,\\n0.272265625,\\n0.325,\\n0.384765625,\\n0.4515625,\\n0.525390625,\\n0.60625,\\n0.694140625,\\n0.7890625,\\n0.891015625,\\n1.0\\n);\\nvarying vec2 vUV;\\nfloat perspectiveDepthToViewZ( const in float invClipZ,const in float near,const in float far ) {\\nreturn ( near*far )/( ( far-near )*invClipZ-far );\\n}\\nfloat viewZToPerspectiveDepth( const in float viewZ,const in float near,const in float far ) {\\nreturn ( near*far/viewZ+far)/( far-near );\\n}\\nfloat viewZToOrthographicDepth( const in float viewZ,const in float near,const in float far ) {\\nreturn ( viewZ+near )/( near-far );\\n}\\n#ifdef SSAO\\nuniform sampler2D randomSampler;\\n#ifndef GEOMETRYBUFFER\\nuniform sampler2D depthNormalSampler;\\n#else\\nuniform sampler2D depthSampler;\\nuniform sampler2D normalSampler;\\n#endif\\nuniform float randTextureTiles;\\nuniform float samplesFactor;\\nuniform vec3 sampleSphere[SAMPLES];\\nuniform float totalStrength;\\nuniform float base;\\nuniform float xViewport;\\nuniform float yViewport;\\nuniform float maxZ;\\nuniform float minZAspect;\\nuniform vec2 texelSize;\\nuniform mat4 projection;\\nvoid main()\\n{\\nvec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;\\n#ifndef GEOMETRYBUFFER\\nfloat depth=texture2D(depthNormalSampler,vUV).r;\\n#else\\nfloat depth=texture2D(depthSampler,vUV).r;\\n#endif\\nfloat depthSign=depth/abs(depth);\\ndepth=depth*depthSign;\\n#ifndef GEOMETRYBUFFER\\nvec3 normal=texture2D(depthNormalSampler,vUV).gba;\\n#else\\nvec3 normal=texture2D(normalSampler,vUV).rgb;\\n#endif\\nfloat occlusion=0.0;\\nfloat correctedRadius=min(radius,minZAspect*depth/near);\\nvec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);\\nvec3 origin=vViewRay*depth;\\nvec3 rvec=random*2.0-1.0;\\nrvec.z=0.0;\\n\\nfloat dotProduct=dot(rvec,normal);\\nrvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);\\nvec3 tangent=normalize(rvec-normal*dot(rvec,normal));\\nvec3 bitangent=cross(normal,tangent);\\nmat3 tbn=mat3(tangent,bitangent,normal);\\nfloat difference;\\nfor (int i=0; i1.0 || offset.y>1.0) {\\ncontinue;\\n}\\n\\n#ifndef GEOMETRYBUFFER\\nfloat sampleDepth=abs(texture2D(depthNormalSampler,offset.xy).r);\\n#else\\nfloat sampleDepth=abs(texture2D(depthSampler,offset.xy).r);\\n#endif\\n\\ndifference=depthSign*samplePosition.z-sampleDepth;\\nfloat rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);\\nocclusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;\\n}\\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));\\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\\nfloat result=clamp(ao+base,0.0,1.0);\\ngl_FragColor=vec4(vec3(result),1.0);\\n}\\n#endif\\n#ifdef BILATERAL_BLUR\\nuniform sampler2D depthNormalSampler;\\nuniform float outSize;\\nuniform float samplerOffsets[SAMPLES];\\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\\nvec4 color=vec4(0.0);\\nvec2 off1=vec2(1.3846153846)*direction;\\nvec2 off2=vec2(3.2307692308)*direction;\\ncolor+=texture2D(image,uv)*0.2270270270;\\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\\nreturn color;\\n}\\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\\nvec4 color=vec4(0.0);\\nvec2 off1=vec2(1.411764705882353)*direction;\\nvec2 off2=vec2(3.2941176470588234)*direction;\\nvec2 off3=vec2(5.176470588235294)*direction;\\ncolor+=texture2D(image,uv)*0.1964825501511404;\\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\\nreturn color;\\n}\\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\\nvec4 color=vec4(0.0);\\nvec2 off1=vec2(1.411764705882353)*direction;\\nvec2 off2=vec2(3.2941176470588234)*direction;\\nvec2 off3=vec2(5.176470588235294)*direction;\\nfloat compareDepth=abs(texture2D(depthNormalSampler,uv).r);\\nfloat sampleDepth;\\nfloat weight;\\nfloat weightSum=30.0;\\ncolor+=texture2D(image,uv)*30.0;\\nsampleDepth=abs(texture2D(depthNormalSampler,uv+(off1/resolution)).r);\\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\\nweightSum+=weight;\\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\\nsampleDepth=abs(texture2D(depthNormalSampler,uv-(off1/resolution)).r);\\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\\nweightSum+=weight;\\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\\nsampleDepth=abs(texture2D(depthNormalSampler,uv+(off2/resolution)).r);\\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\\nweightSum+=weight;\\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\\nsampleDepth=abs(texture2D(depthNormalSampler,uv-(off2/resolution)).r);\\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\\nweightSum+=weight;\\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\\nsampleDepth=abs(texture2D(depthNormalSampler,uv+(off3/resolution)).r);\\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\\nweightSum+=weight;\\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\\nsampleDepth=abs(texture2D(depthNormalSampler,uv-(off3/resolution)).r);\\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\\nweightSum+=weight;\\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\\nreturn color/weightSum;\\n}\\nvoid main()\\n{\\n#if EXPENSIVE\\nfloat compareDepth=abs(texture2D(depthNormalSampler,vUV).r);\\nfloat texelsize=1.0/outSize;\\nfloat result=0.0;\\nfloat weightSum=0.0;\\nfor (int i=0; i=2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"scene\",{get:function(){return this._scene},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"SSAO2RenderingPipeline\"},t.prototype.dispose=function(t){void 0===t&&(t=!1);for(var i=0;i0?i._ssaoCombinePostProcess.width:i._originalColorPostProcess.width),e.setFloat(\"near\",i._scene.activeCamera.minZ),e.setFloat(\"far\",i._scene.activeCamera.maxZ),e.setFloat(\"radius\",i.radius),i._forceGeometryBuffer?e.setTexture(\"depthNormalSampler\",i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]):e.setTexture(\"depthNormalSampler\",i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),e.setArray(\"samplerOffsets\",i._samplerOffsets))},this._blurVPostProcess=new li(\"BlurV\",\"ssao2\",[\"outSize\",\"samplerOffsets\",\"near\",\"far\",\"radius\"],[\"depthNormalSampler\"],t,null,Ke.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,\"#define BILATERAL_BLUR\\n#define BILATERAL_BLUR_V\\n#define SAMPLES 16\\n#define EXPENSIVE \"+(n?\"1\":\"0\")+\"\\n\"),this._blurVPostProcess.onApply=function(e){i._scene.activeCamera&&(e.setFloat(\"outSize\",i._ssaoCombinePostProcess.height>0?i._ssaoCombinePostProcess.height:i._originalColorPostProcess.height),e.setFloat(\"near\",i._scene.activeCamera.minZ),e.setFloat(\"far\",i._scene.activeCamera.maxZ),e.setFloat(\"radius\",i.radius),i._forceGeometryBuffer?e.setTexture(\"depthNormalSampler\",i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]):e.setTexture(\"depthNormalSampler\",i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),e.setArray(\"samplerOffsets\",i._samplerOffsets))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},t.prototype._rebuild=function(){e.prototype._rebuild.call(this)},t.prototype._radicalInverse_VdC=function(e){return this._bits[0]=e,this._bits[0]=(this._bits[0]<<16|this._bits[0]>>16)>>>0,this._bits[0]=(1431655765&this._bits[0])<<1|(2863311530&this._bits[0])>>>1>>>0,this._bits[0]=(858993459&this._bits[0])<<2|(3435973836&this._bits[0])>>>2>>>0,this._bits[0]=(252645135&this._bits[0])<<4|(4042322160&this._bits[0])>>>4>>>0,this._bits[0]=(16711935&this._bits[0])<<8|(4278255360&this._bits[0])>>>8>>>0,2.3283064365386963e-10*this._bits[0]},t.prototype._hammersley=function(e,t){return[e/t,this._radicalInverse_VdC(e)]},t.prototype._hemisphereSample_uniform=function(e,t){var i=2*t*Math.PI,n=1-(.85*e+.15),r=Math.sqrt(1-n*n);return new a.e(Math.cos(i)*r,Math.sin(i)*r,n)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,i=[],n=0;n0.0)\\nhitCoord-=dir;\\nelse\\nhitCoord+=dir;\\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\\n}\\nprojectedCoord=projection*vec4(hitCoord,1.0);\\nprojectedCoord.xy/=projectedCoord.w;\\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\\n\\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,1.0);\\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\\ninfo.color/=float(SMOOTH_STEPS+1);\\nreturn info;\\n}\\n\\nReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)\\n{\\nReflectionInfo info;\\nvec4 projectedCoord;\\nfloat sampledDepth;\\ndir*=step;\\nfor(int i=0; i>0)),e.push(\"#define SMOOTH_STEPS \"+(this._smoothSteps>>0)),this.updateEffect(e.join(\"\\n\"))},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,\"threshold\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"strength\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"reflectionSpecularFalloffExponent\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"step\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"roughnessFactor\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"enableSmoothReflections\",null),Object(h.c)([Object(w.c)()],t.prototype,\"reflectionSamples\",null),Object(h.c)([Object(w.c)()],t.prototype,\"smoothSteps\",null),t}(li);c.a.RegisteredTypes[\"BABYLON.ScreenSpaceReflectionPostProcess\"]=Yf;var Kf=\"uniform sampler2D textureSampler;\\nvarying vec2 vUV;\\n#if defined(PASS_POST_PROCESS)\\nvoid main(void)\\n{\\nvec4 color=texture2D(textureSampler,vUV);\\ngl_FragColor=color;\\n}\\n#endif\\n#if defined(DOWN_SAMPLE_X4)\\nuniform vec2 dsOffsets[16];\\nvoid main(void)\\n{\\nvec4 average=vec4(0.0,0.0,0.0,0.0);\\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\\naverage/=16.0;\\ngl_FragColor=average;\\n}\\n#endif\\n#if defined(BRIGHT_PASS)\\nuniform vec2 dsOffsets[4];\\nuniform float brightThreshold;\\nvoid main(void)\\n{\\nvec4 average=vec4(0.0,0.0,0.0,0.0);\\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\\naverage*=0.25;\\nfloat luminance=length(average.rgb);\\nif (luminanceshadowPixelDepth)\\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\\ncurrentPosition+=stepL;\\n}\\naccumFog/=NB_STEPS;\\nvec3 color=accumFog*scatteringPower;\\ngl_FragColor=vec4(color*exp(color) ,1.0);\\n}\\n#endif\\n#if defined(VLSMERGE)\\nuniform sampler2D originalSampler;\\nvoid main(void)\\n{\\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\\n}\\n#endif\\n#if defined(LUMINANCE)\\nuniform vec2 lumOffsets[4];\\nvoid main()\\n{\\nfloat average=0.0;\\nvec4 color=vec4(0.0);\\nfloat maximum=-1e20;\\nvec3 weight=vec3(0.299,0.587,0.114);\\nfor (int i=0; i<4; i++)\\n{\\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\\n\\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\\n\\n#ifdef WEIGHTED_AVERAGE\\nfloat GreyValue=dot(color.rgb,weight);\\n#endif\\n#ifdef BRIGHTNESS\\nfloat GreyValue=max(color.r,max(color.g,color.b));\\n#endif\\n#ifdef HSL_COMPONENT\\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\\n#endif\\n#ifdef MAGNITUDE\\nfloat GreyValue=length(color.rgb);\\n#endif\\nmaximum=max(maximum,GreyValue);\\naverage+=(0.25*log(1e-5+GreyValue));\\n}\\naverage=exp(average);\\ngl_FragColor=vec4(average,maximum,0.0,1.0);\\n}\\n#endif\\n#if defined(LUMINANCE_DOWN_SAMPLE)\\nuniform vec2 dsOffsets[9];\\nuniform float halfDestPixelSize;\\n#ifdef FINAL_DOWN_SAMPLER\\n#include\\n#endif\\nvoid main()\\n{\\nvec4 color=vec4(0.0);\\nfloat average=0.0;\\nfor (int i=0; i<9; i++)\\n{\\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\\naverage+=color.r;\\n}\\naverage/=9.0;\\n#ifdef FINAL_DOWN_SAMPLER\\ngl_FragColor=pack(average);\\n#else\\ngl_FragColor=vec4(average,average,0.0,1.0);\\n#endif\\n}\\n#endif\\n#if defined(HDR)\\nuniform sampler2D textureAdderSampler;\\nuniform float averageLuminance;\\nvoid main()\\n{\\nvec4 color=texture2D(textureAdderSampler,vUV);\\n#ifndef AUTO_EXPOSURE\\nvec4 adjustedColor=color/averageLuminance;\\ncolor=adjustedColor;\\ncolor.a=1.0;\\n#endif\\ngl_FragColor=color;\\n}\\n#endif\\n#if defined(LENS_FLARE)\\n#define GHOSTS 3\\nuniform sampler2D lensColorSampler;\\nuniform float strength;\\nuniform float ghostDispersal;\\nuniform float haloWidth;\\nuniform vec2 resolution;\\nuniform float distortionStrength;\\nfloat hash(vec2 p)\\n{\\nfloat h=dot(p,vec2(127.1,311.7));\\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\\n}\\nfloat noise(in vec2 p)\\n{\\nvec2 i=floor(p);\\nvec2 f=fract(p);\\nvec2 u=f*f*(3.0-2.0*f);\\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\\nhash(i+vec2(1.0,0.0)),u.x),\\nmix(hash(i+vec2(0.0,1.0)),\\nhash(i+vec2(1.0,1.0)),u.x),u.y);\\n}\\nfloat fbm(vec2 p)\\n{\\nfloat f=0.0;\\nf+=0.5000*noise(p); p*=2.02;\\nf+=0.2500*noise(p); p*=2.03;\\nf+=0.1250*noise(p); p*=2.01;\\nf+=0.0625*noise(p); p*=2.04;\\nf/=0.9375;\\nreturn f;\\n}\\nvec3 pattern(vec2 uv)\\n{\\nvec2 p=-1.0+2.0*uv;\\nfloat p2=dot(p,p);\\nfloat f=fbm(vec2(15.0*p2))/2.0;\\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\\nreturn (1.0-f)*vec3(r,g,b);\\n}\\nfloat luminance(vec3 color)\\n{\\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\\n}\\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\\n{\\nreturn vec4(\\ntexture2D(tex,texcoord+direction*distortion.r).r,\\ntexture2D(tex,texcoord+direction*distortion.g).g,\\ntexture2D(tex,texcoord+direction*distortion.b).b,\\n1.0\\n);\\n}\\nvoid main(void)\\n{\\nvec2 uv=-vUV+vec2(1.0);\\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\\nvec2 texelSize=1.0/resolution;\\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\\nvec4 result=vec4(0.0);\\nfloat ghostIndice=1.0;\\nfor (int i=0; i=nSamples)\\nbreak;\\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\\nresult+=texture2D(textureSampler,offset1);\\n}\\ngl_FragColor=result/float(nSamples);\\n}\\n#endif\\n\";ai.a.ShadersStore.standardPixelShader=Kf;var Qf=function(e){function t(t,i,n,r,o){void 0===r&&(r=null);var a=e.call(this,i.getEngine(),t)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.blurHPostProcesses=[],a.blurVPostProcesses=[],a.textureAdderPostProcess=null,a.volumetricLightPostProcess=null,a.volumetricLightSmoothXPostProcess=null,a.volumetricLightSmoothYPostProcess=null,a.volumetricLightMergePostProces=null,a.volumetricLightFinalPostProcess=null,a.luminancePostProcess=null,a.luminanceDownSamplePostProcesses=[],a.hdrPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlareFinalPostProcess=null,a.hdrFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.motionBlurPostProcess=null,a.depthOfFieldPostProcess=null,a.fxaaPostProcess=null,a.screenSpaceReflectionPostProcess=null,a.brightThreshold=1,a.blurWidth=512,a.horizontalBlur=!1,a.lensTexture=null,a.volumetricLightCoefficient=.2,a.volumetricLightPower=4,a.volumetricLightBlurScale=64,a.sourceLight=null,a.hdrMinimumLuminance=1,a.hdrDecreaseRate=.5,a.hdrIncreaseRate=.5,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensFlareBlurWidth=512,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.depthOfFieldBlurWidth=64,a.animations=[],a._currentDepthOfFieldSource=null,a._fixedExposure=1,a._currentExposure=1,a._hdrAutoExposure=!1,a._hdrCurrentLuminance=1,a._motionStrength=1,a._isObjectBasedMotionBlur=!1,a._camerasToBeAttached=[],a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._vlsEnabled=!1,a._lensFlareEnabled=!1,a._hdrEnabled=!1,a._motionBlurEnabled=!1,a._fxaaEnabled=!1,a._screenSpaceReflectionsEnabled=!1,a._motionBlurSamples=64,a._volumetricLightStepsCount=50,a._samples=1,a._cameras=o||i.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._scene=i,a._basePostProcess=r,a._ratio=n,a._floatTextureType=i.getEngine().getCaps().textureFloatRender?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_HALF_FLOAT,i.postProcessRenderPipelineManager.addPipeline(a),a._buildPipeline(),a}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"exposure\",{get:function(){return this._fixedExposure},set:function(e){this._fixedExposure=e,this._currentExposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"hdrAutoExposure\",{get:function(){return this._hdrAutoExposure},set:function(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){var t=[\"#define HDR\"];e&&t.push(\"#define AUTO_EXPOSURE\"),this.hdrPostProcess.updateEffect(t.join(\"\\n\"))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"motionStrength\",{get:function(){return this._motionStrength},set:function(e){this._motionStrength=e,this._isObjectBasedMotionBlur&&this.motionBlurPostProcess&&(this.motionBlurPostProcess.motionStrength=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"objectBasedMotionBlur\",{get:function(){return this._isObjectBasedMotionBlur},set:function(e){var t=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,t&&this._buildPipeline()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"BloomEnabled\",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"DepthOfFieldEnabled\",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"LensFlareEnabled\",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"HDREnabled\",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"VLSEnabled\",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e)if(!this._scene.enableGeometryBufferRenderer())return void m.a.Warn(\"Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline\");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"MotionBlurEnabled\",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"fxaaEnabled\",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"screenSpaceReflectionsEnabled\",{get:function(){return this._screenSpaceReflectionsEnabled},set:function(e){this._screenSpaceReflectionsEnabled!==e&&(this._screenSpaceReflectionsEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"volumetricLightStepsCount\",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect(\"#define VLS\\n#define NB_STEPS \"+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"motionBlurSamples\",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&(this._isObjectBasedMotionBlur?this.motionBlurPostProcess.motionBlurSamples=e:this.motionBlurPostProcess.updateEffect(\"#define MOTION_BLUR\\n#define MAX_MOTION_SAMPLES \"+e.toFixed(1))),this._motionBlurSamples=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"samples\",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._buildPipeline=function(){var e=this,t=this._ratio,i=this._scene;this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._screenSpaceReflectionsEnabled&&(this.screenSpaceReflectionPostProcess=new Yf(\"HDRPass\",i,t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess})),this.addEffect(new jd(i.getEngine(),\"HDRScreenSpaceReflections\",(function(){return e.screenSpaceReflectionPostProcess}),!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new li(\"HDRPass\",\"standard\",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,\"#define PASS_POST_PROCESS\",this._floatTextureType),this.originalPostProcess.autoClear=!this.screenSpaceReflectionPostProcess,this.originalPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.originalPostProcess})),this.addEffect(new jd(i.getEngine(),\"HDRPassPostProcess\",(function(){return e.originalPostProcess}),!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(i,t/4),this._createBrightPassPostProcess(i,t/4),this._createBlurPostProcesses(i,t/4,1),this._createTextureAdderPostProcess(i,t),this.textureAdderFinalPostProcess=new li(\"HDRDepthOfFieldSource\",\"standard\",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,\"#define PASS_POST_PROCESS\",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),\"HDRBaseDepthOfFieldSource\",(function(){return e.textureAdderFinalPostProcess}),!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(i,t),this.volumetricLightFinalPostProcess=new li(\"HDRVLSFinal\",\"standard\",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,\"#define PASS_POST_PROCESS\",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),\"HDRVLSFinal\",(function(){return e.volumetricLightFinalPostProcess}),!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(i,t),this.lensFlareFinalPostProcess=new li(\"HDRPostLensFlareDepthOfFieldSource\",\"standard\",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,\"#define PASS_POST_PROCESS\",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),\"HDRPostLensFlareDepthOfFieldSource\",(function(){return e.lensFlareFinalPostProcess}),!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(i,this._floatTextureType),this._createHdrPostProcess(i,t),this.hdrFinalPostProcess=new li(\"HDRPostHDReDepthOfFieldSource\",\"standard\",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,\"#define PASS_POST_PROCESS\",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),\"HDRPostHDReDepthOfFieldSource\",(function(){return e.hdrFinalPostProcess}),!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(i,t/2,3,\"depthOfFieldBlurWidth\"),this._createDepthOfFieldPostProcess(i,t)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(i,t),this._fxaaEnabled&&(this.fxaaPostProcess=new mf(\"fxaa\",1,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),\"HDRFxaa\",(function(){return e.fxaaPostProcess}),!0))),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&this._samples>1&&m.a.Warn(\"MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0\")},t.prototype._createDownSampleX4PostProcess=function(e,t){var i=this,n=new Array(32);this.downSampleX4PostProcess=new li(\"HDRDownSampleX4\",\"standard\",[\"dsOffsets\"],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define DOWN_SAMPLE_X4\",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,r=i.downSampleX4PostProcess.width,o=i.downSampleX4PostProcess.height,a=-2;a<2;a++)for(var s=-2;s<2;s++)n[t]=(a+.5)*(1/r),n[t+1]=(s+.5)*(1/o),t+=2;e.setArray2(\"dsOffsets\",n)},this.addEffect(new jd(e.getEngine(),\"HDRDownSampleX4\",(function(){return i.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var i=this,n=new Array(8);this.brightPassPostProcess=new li(\"HDRBrightPass\",\"standard\",[\"dsOffsets\",\"brightThreshold\"],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define BRIGHT_PASS\",this._floatTextureType),this.brightPassPostProcess.onApply=function(e){var t=1/i.brightPassPostProcess.width,r=1/i.brightPassPostProcess.height;n[0]=-.5*t,n[1]=.5*r,n[2]=.5*t,n[3]=.5*r,n[4]=-.5*t,n[5]=-.5*r,n[6]=.5*t,n[7]=-.5*r,e.setArray2(\"dsOffsets\",n),e.setFloat(\"brightThreshold\",i.brightThreshold)},this.addEffect(new jd(e.getEngine(),\"HDRBrightPass\",(function(){return i.brightPassPostProcess}),!0))},t.prototype._createBlurPostProcesses=function(e,t,i,n){var r=this;void 0===n&&(n=\"blurWidth\");var o=e.getEngine(),s=new eo(\"HDRBlurH_\"+i,new a.d(1,0),this[n],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),c=new eo(\"HDRBlurV_\"+i,new a.d(0,1),this[n],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);s.onActivateObservable.add((function(){var e=s.width/o.getRenderWidth();s.kernel=r[n]*e})),c.onActivateObservable.add((function(){var e=c.height/o.getRenderHeight();c.kernel=r.horizontalBlur?64*e:r[n]*e})),this.addEffect(new jd(e.getEngine(),\"HDRBlurH\"+i,(function(){return s}),!0)),this.addEffect(new jd(e.getEngine(),\"HDRBlurV\"+i,(function(){return c}),!0)),this.blurHPostProcesses.push(s),this.blurVPostProcesses.push(c)},t.prototype._createTextureAdderPostProcess=function(e,t){var i=this;this.textureAdderPostProcess=new li(\"HDRTextureAdder\",\"standard\",[\"exposure\"],[\"otherSampler\",\"lensSampler\"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define TEXTURE_ADDER\",this._floatTextureType),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess(\"otherSampler\",i._vlsEnabled?i._currentDepthOfFieldSource:i.originalPostProcess),e.setTexture(\"lensSampler\",i.lensTexture),e.setFloat(\"exposure\",i._currentExposure),i._currentDepthOfFieldSource=i.textureAdderFinalPostProcess},this.addEffect(new jd(e.getEngine(),\"HDRTextureAdder\",(function(){return i.textureAdderPostProcess}),!0))},t.prototype._createVolumetricLightPostProcess=function(e,t){var i=this,n=e.enableGeometryBufferRenderer();n.enablePosition=!0;var r=n.getGBuffer();this.volumetricLightPostProcess=new li(\"HDRVLS\",\"standard\",[\"shadowViewProjection\",\"cameraPosition\",\"sunDirection\",\"sunColor\",\"scatteringCoefficient\",\"scatteringPower\",\"depthValues\"],[\"shadowMapSampler\",\"positionSampler\"],t/8,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define VLS\\n#define NB_STEPS \"+this._volumetricLightStepsCount.toFixed(1));var o=a.d.Zero();this.volumetricLightPostProcess.onApply=function(e){if(i.sourceLight&&i.sourceLight.getShadowGenerator()&&i._scene.activeCamera){var t=i.sourceLight.getShadowGenerator();e.setTexture(\"shadowMapSampler\",t.getShadowMap()),e.setTexture(\"positionSampler\",r.textures[2]),e.setColor3(\"sunColor\",i.sourceLight.diffuse),e.setVector3(\"sunDirection\",i.sourceLight.getShadowDirection()),e.setVector3(\"cameraPosition\",i._scene.activeCamera.globalPosition),e.setMatrix(\"shadowViewProjection\",t.getTransformMatrix()),e.setFloat(\"scatteringCoefficient\",i.volumetricLightCoefficient),e.setFloat(\"scatteringPower\",i.volumetricLightPower),o.x=i.sourceLight.getDepthMinZ(i._scene.activeCamera),o.y=i.sourceLight.getDepthMaxZ(i._scene.activeCamera),e.setVector2(\"depthValues\",o)}},this.addEffect(new jd(e.getEngine(),\"HDRVLS\",(function(){return i.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,\"volumetricLightBlurScale\"),this.volumetricLightMergePostProces=new li(\"HDRVLSMerge\",\"standard\",[],[\"originalSampler\"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define VLSMERGE\"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess(\"originalSampler\",i._bloomEnabled?i.textureAdderFinalPostProcess:i.originalPostProcess),i._currentDepthOfFieldSource=i.volumetricLightFinalPostProcess},this.addEffect(new jd(e.getEngine(),\"HDRVLSMerge\",(function(){return i.volumetricLightMergePostProces}),!0))},t.prototype._createLuminancePostProcesses=function(e,i){var n=this,r=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new li(\"HDRLuminance\",\"standard\",[\"lumOffsets\"],[],{width:r,height:r},null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define LUMINANCE\",i);var o=[];this.luminancePostProcess.onApply=function(e){var t=1/n.luminancePostProcess.width,i=1/n.luminancePostProcess.height;o[0]=-.5*t,o[1]=.5*i,o[2]=.5*t,o[3]=.5*i,o[4]=-.5*t,o[5]=-.5*i,o[6]=.5*t,o[7]=-.5*i,e.setArray2(\"lumOffsets\",o)},this.addEffect(new jd(e.getEngine(),\"HDRLuminance\",(function(){return n.luminancePostProcess}),!0));for(var s=t.LuminanceSteps-1;s>=0;s--){r=Math.pow(3,s);var c=\"#define LUMINANCE_DOWN_SAMPLE\\n\";0===s&&(c+=\"#define FINAL_DOWN_SAMPLER\");var l=new li(\"HDRLuminanceDownSample\"+s,\"standard\",[\"dsOffsets\",\"halfDestPixelSize\"],[],{width:r,height:r},null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,c,i);this.luminanceDownSamplePostProcesses.push(l)}var u=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(t,i){var r=new Array(18);t.onApply=function(e){if(u){for(var o=0,a=-1;a<2;a++)for(var s=-1;s<2;s++)r[o]=a/u.width,r[o+1]=s/u.height,o+=2;e.setArray2(\"dsOffsets\",r),e.setFloat(\"halfDestPixelSize\",.5/u.width),u=i===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:t}},i===n.luminanceDownSamplePostProcesses.length-1&&(t.onAfterRender=function(){var t=e.getEngine().readPixels(0,0,1,1),i=new a.f(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(t[0]*i.x+t[1]*i.y+t[2]*i.z+t[3]*i.w)/100}),n.addEffect(new jd(e.getEngine(),\"HDRLuminanceDownSample\"+i,(function(){return t}),!0))}))},t.prototype._createHdrPostProcess=function(e,t){var i=this,n=[\"#define HDR\"];this._hdrAutoExposure&&n.push(\"#define AUTO_EXPOSURE\"),this.hdrPostProcess=new li(\"HDR\",\"standard\",[\"averageLuminance\"],[\"textureAdderSampler\"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n.join(\"\\n\"),g.a.TEXTURETYPE_UNSIGNED_INT);var r=1,o=0,a=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess(\"textureAdderSampler\",i._currentDepthOfFieldSource),o+=e.getEngine().getDeltaTime(),r<0)r=i._hdrCurrentLuminance;else{var n=(a-o)/1e3;i._hdrCurrentLuminancer-i.hdrIncreaseRate*n?r-=i.hdrIncreaseRate*n:r=i._hdrCurrentLuminance}i.hdrAutoExposure?i._currentExposure=i._fixedExposure/r:(r=L.a.Clamp(r,i.hdrMinimumLuminance,1e20),t.setFloat(\"averageLuminance\",r)),a=o,i._currentDepthOfFieldSource=i.hdrFinalPostProcess},this.addEffect(new jd(e.getEngine(),\"HDR\",(function(){return i.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var i=this;this.lensFlarePostProcess=new li(\"HDRLensFlare\",\"standard\",[\"strength\",\"ghostDispersal\",\"haloWidth\",\"resolution\",\"distortionStrength\"],[\"lensColorSampler\"],t/2,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define LENS_FLARE\",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(e.getEngine(),\"HDRLensFlare\",(function(){return i.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2,\"lensFlareBlurWidth\"),this.lensFlareComposePostProcess=new li(\"HDRLensFlareCompose\",\"standard\",[\"lensStarMatrix\"],[\"otherSampler\",\"lensDirtSampler\",\"lensStarSampler\"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define LENS_FLARE_COMPOSE\",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(e.getEngine(),\"HDRLensFlareCompose\",(function(){return i.lensFlareComposePostProcess}),!0));var n=new a.d(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess(\"textureSampler\",i._bloomEnabled?i.blurHPostProcesses[0]:i.originalPostProcess),e.setTexture(\"lensColorSampler\",i.lensColorTexture),e.setFloat(\"strength\",i.lensFlareStrength),e.setFloat(\"ghostDispersal\",i.lensFlareGhostDispersal),e.setFloat(\"haloWidth\",i.lensFlareHaloWidth),n.x=i.lensFlarePostProcess.width,n.y=i.lensFlarePostProcess.height,e.setVector2(\"resolution\",n),e.setFloat(\"distortionStrength\",i.lensFlareDistortionStrength)};var r=a.a.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),o=a.a.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(e){if(i._scene.activeCamera){e.setTextureFromPostProcess(\"otherSampler\",i.lensFlarePostProcess),e.setTexture(\"lensDirtSampler\",i.lensFlareDirtTexture),e.setTexture(\"lensStarSampler\",i.lensStarTexture);var t=i._scene.activeCamera.getViewMatrix().getRow(0),n=i._scene.activeCamera.getViewMatrix().getRow(2),s=a.e.Dot(t.toVector3(),new a.e(1,0,0))+a.e.Dot(n.toVector3(),new a.e(0,0,1));s*=4;var c=a.a.FromValues(.5*Math.cos(s),-Math.sin(s),0,0,Math.sin(s),.5*Math.cos(s),0,0,0,0,1,0,0,0,0,1),l=o.multiply(c).multiply(r);e.setMatrix(\"lensStarMatrix\",l),i._currentDepthOfFieldSource=i.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var i=this;this.depthOfFieldPostProcess=new li(\"HDRDepthOfField\",\"standard\",[\"distance\"],[\"otherSampler\",\"depthSampler\"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define DEPTH_OF_FIELD\",g.a.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess(\"otherSampler\",i._currentDepthOfFieldSource),e.setTexture(\"depthSampler\",i._getDepthTexture()),e.setFloat(\"distance\",i.depthOfFieldDistance)},this.addEffect(new jd(e.getEngine(),\"HDRDepthOfField\",(function(){return i.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var i=this;if(this._isObjectBasedMotionBlur){var n=new Rf(\"HDRMotionBlur\",e,t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT);n.motionStrength=this.motionStrength,n.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=n}else{this.motionBlurPostProcess=new li(\"HDRMotionBlur\",\"standard\",[\"inverseViewProjection\",\"prevViewProjection\",\"screenSize\",\"motionScale\",\"motionStrength\"],[\"depthSampler\"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,\"#define MOTION_BLUR\\n#define MAX_MOTION_SAMPLES \"+this.motionBlurSamples.toFixed(1),g.a.TEXTURETYPE_UNSIGNED_INT);var r=0,o=a.a.Identity(),s=a.a.Identity(),c=a.a.Identity(),l=a.d.Zero();this.motionBlurPostProcess.onApply=function(t){(c=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(s),t.setMatrix(\"inverseViewProjection\",s),t.setMatrix(\"prevViewProjection\",o),o=c,l.x=i.motionBlurPostProcess.width,l.y=i.motionBlurPostProcess.height,t.setVector2(\"screenSize\",l),r=e.getEngine().getFps()/60,t.setFloat(\"motionScale\",r),t.setFloat(\"motionStrength\",i.motionStrength),t.setTexture(\"depthSampler\",i._getDepthTexture())}}this.addEffect(new jd(e.getEngine(),\"HDRMotionBlur\",(function(){return i.motionBlurPostProcess}),!0))},t.prototype._getDepthTexture=function(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},t.prototype._disposePostProcesses=function(){for(var e=0;e0.5;\\nuseCamA=!useCamB;\\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\\n#else\\n#ifdef IS_STEREOSCOPIC_INTERLACED\\nfloat rowNum=floor(vUV.y/stepSize.y);\\nuseCamA=mod(rowNum,2.0) == 1.0;\\nuseCamB=mod(rowNum,2.0) == 0.0;\\ntexCoord1=vec2(vUV.x,vUV.y);\\ntexCoord2=vec2(vUV.x,vUV.y);\\n#else\\nuseCamB=vUV.y>0.5;\\nuseCamA=!useCamB;\\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\\n#endif\\n#endif\\n\\nif (useCamB){\\nfrag1=texture2D(textureSampler,texCoord1).rgb;\\nfrag2=texture2D(textureSampler,texCoord2).rgb;\\n}else if (useCamA){\\nfrag1=texture2D(camASampler ,texCoord1).rgb;\\nfrag2=texture2D(camASampler ,texCoord2).rgb;\\n}else {\\ndiscard;\\n}\\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\\n}\\n\";ai.a.ShadersStore.stereoscopicInterlacePixelShader=qf;var Zf=function(e){function t(t,i,n,r,o,s,c){var l=e.call(this,t,\"stereoscopicInterlace\",[\"stepSize\"],[\"camASampler\"],1,i[1],o,s,c,r?\"#define IS_STEREOSCOPIC_INTERLACED 1\":n?\"#define IS_STEREOSCOPIC_HORIZ 1\":void 0)||this;return l._passedProcess=i[0]._rigPostProcess,l._stepSize=new a.d(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new a.d(1/l.width,1/l.height)})),l.onApplyObservable.add((function(e){e.setTextureFromPostProcess(\"camASampler\",l._passedProcess),e.setFloat2(\"stepSize\",l._stepSize.x,l._stepSize.y)})),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"StereoscopicInterlacePostProcessI\"},t}(li),Jf=function(e){function t(t,i,n,r,o,s){var c=e.call(this,t,\"stereoscopicInterlace\",[\"stepSize\"],[\"camASampler\"],1,i[1],r,o,s,n?\"#define IS_STEREOSCOPIC_HORIZ 1\":void 0)||this;return c._passedProcess=i[0]._rigPostProcess,c._stepSize=new a.d(1/c.width,1/c.height),c.onSizeChangedObservable.add((function(){c._stepSize=new a.d(1/c.width,1/c.height)})),c.onApplyObservable.add((function(e){e.setTextureFromPostProcess(\"camASampler\",c._passedProcess),e.setFloat2(\"stepSize\",c._stepSize.x,c._stepSize.y)})),c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"StereoscopicInterlacePostProcess\"},t}(li),$f=\"\\nvarying vec2 vUV;\\nuniform sampler2D textureSampler;\\n\\nuniform float _ExposureAdjustment;\\n#if defined(HABLE_TONEMAPPING)\\nconst float A=0.15;\\nconst float B=0.50;\\nconst float C=0.10;\\nconst float D=0.20;\\nconst float E=0.02;\\nconst float F=0.30;\\nconst float W=11.2;\\n#endif\\nfloat Luminance(vec3 c)\\n{\\nreturn dot(c,vec3(0.22,0.707,0.071));\\n}\\nvoid main(void)\\n{\\nvec3 colour=texture2D(textureSampler,vUV).rgb;\\n#if defined(REINHARD_TONEMAPPING)\\nfloat lum=Luminance(colour.rgb);\\nfloat lumTm=lum*_ExposureAdjustment;\\nfloat scale=lumTm/(1.0+lumTm);\\ncolour*=scale/lum;\\n#elif defined(HABLE_TONEMAPPING)\\ncolour*=_ExposureAdjustment;\\nconst float ExposureBias=2.0;\\nvec3 x=ExposureBias*colour;\\nvec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\\nx=vec3(W,W,W);\\nvec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);\\ncolour=curr*whiteScale;\\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\\ncolour*=_ExposureAdjustment;\\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\\ncolour=retColor*retColor;\\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\\ncolour=vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);\\n#endif\\ngl_FragColor=vec4(colour.rgb,1.0);\\n}\";ai.a.ShadersStore.tonemapPixelShader=$f;var ep;!function(e){e[e.Hable=0]=\"Hable\",e[e.Reinhard=1]=\"Reinhard\",e[e.HejiDawson=2]=\"HejiDawson\",e[e.Photographic=3]=\"Photographic\"}(ep||(ep={}));var tp=function(e){function t(t,i,n,r,o,a,s){void 0===o&&(o=g.a.TEXTURE_BILINEAR_SAMPLINGMODE),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT);var c=e.call(this,t,\"tonemap\",[\"_ExposureAdjustment\"],null,1,r,o,a,!0,null,s)||this;c._operator=i,c.exposureAdjustment=n;var l=\"#define \";return c._operator===ep.Hable?l+=\"HABLE_TONEMAPPING\":c._operator===ep.Reinhard?l+=\"REINHARD_TONEMAPPING\":c._operator===ep.HejiDawson?l+=\"OPTIMIZED_HEJIDAWSON_TONEMAPPING\":c._operator===ep.Photographic&&(l+=\"PHOTOGRAPHIC_TONEMAPPING\"),c.updateEffect(l),c.onApply=function(e){e.setFloat(\"_ExposureAdjustment\",c.exposureAdjustment)},c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return\"TonemapPostProcess\"},t}(li),ip=\"uniform sampler2D textureSampler;\\nuniform sampler2D lightScatteringSampler;\\nuniform float decay;\\nuniform float exposure;\\nuniform float weight;\\nuniform float density;\\nuniform vec2 meshPositionOnScreen;\\nvarying vec2 vUV;\\nvoid main(void) {\\nvec2 tc=vUV;\\nvec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);\\ndeltaTexCoord*=1.0/float(NUM_SAMPLES)*density;\\nfloat illuminationDecay=1.0;\\nvec4 color=texture2D(lightScatteringSampler,tc)*0.4;\\nfor(int i=0; i\\n#include\\n#include[0..maxSimultaneousMorphTargets]\\n\\n#include\\nuniform mat4 viewProjection;\\nuniform vec2 depthValues;\\n#if defined(ALPHATEST) || defined(NEED_UV)\\nvarying vec2 vUV;\\nuniform mat4 diffuseMatrix;\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#endif\\nvoid main(void)\\n{\\nvec3 positionUpdated=position;\\n#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)\\nvec2 uvUpdated=uv;\\n#endif\\n#include[0..maxSimultaneousMorphTargets]\\n#include\\n#include\\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\\n#ifdef UV1\\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#ifdef UV2\\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#endif\\n}\\n\";ai.a.ShadersStore.volumetricLightScatteringPassVertexShader=np;var rp=\"#if defined(ALPHATEST) || defined(NEED_UV)\\nvarying vec2 vUV;\\n#endif\\n#if defined(ALPHATEST)\\nuniform sampler2D diffuseSampler;\\n#endif\\nvoid main(void)\\n{\\n#if defined(ALPHATEST)\\nvec4 diffuseColor=texture2D(diffuseSampler,vUV);\\nif (diffuseColor.a<0.4)\\ndiscard;\\n#endif\\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\\n}\\n\";ai.a.ShadersStore.volumetricLightScatteringPassPixelShader=rp;var op=function(e){function t(i,n,r,o,s,c,l,u,h){void 0===s&&(s=100),void 0===c&&(c=Ke.a.BILINEAR_SAMPLINGMODE);var d=e.call(this,i,\"volumetricLightScattering\",[\"decay\",\"exposure\",\"weight\",\"meshPositionOnScreen\",\"density\"],[\"lightScatteringSampler\"],n.postProcessRatio||n,r,c,l,u,\"#define NUM_SAMPLES \"+s)||this;return d._screenCoordinates=a.d.Zero(),d.customMeshPosition=a.e.Zero(),d.useCustomMeshPosition=!1,d.invert=!0,d.excludedMeshes=new Array,d.exposure=.3,d.decay=.96815,d.weight=.58767,d.density=.926,l=(h=null===r?h:r.getScene()).getEngine(),d._viewPort=new yi.a(0,0,1,1).toGlobal(l.getRenderWidth(),l.getRenderHeight()),d.mesh=null!==o?o:t.CreateDefaultMesh(\"VolumetricLightScatteringMesh\",h),d._createPass(h,n.passRatio||n),d.onActivate=function(e){d.isSupported||d.dispose(e),d.onActivate=null},d.onApplyObservable.add((function(e){d._updateMeshScreenCoordinates(h),e.setTexture(\"lightScatteringSampler\",d._volumetricLightScatteringRTT),e.setFloat(\"exposure\",d.exposure),e.setFloat(\"decay\",d.decay),e.setFloat(\"weight\",d.weight),e.setFloat(\"density\",d.density),e.setVector2(\"meshPositionOnScreen\",d._screenCoordinates)})),d}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"useDiffuseColor\",{get:function(){return m.a.Warn(\"VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead\"),!1},set:function(e){m.a.Warn(\"VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead\")},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"VolumetricLightScatteringPostProcess\"},t.prototype._isReady=function(e,t){var i=e.getMesh();if(i===this.mesh&&i.material)return i.material.isReady(i);var n=[],r=[Qi.b.PositionKind],o=e.getMaterial();o&&(o.needAlphaTesting()&&n.push(\"#define ALPHATEST\"),i.isVerticesDataPresent(Qi.b.UVKind)&&(r.push(Qi.b.UVKind),n.push(\"#define UV1\")),i.isVerticesDataPresent(Qi.b.UV2Kind)&&(r.push(Qi.b.UV2Kind),n.push(\"#define UV2\"))),i.useBones&&i.computeBonesUsingShaders?(r.push(Qi.b.MatricesIndicesKind),r.push(Qi.b.MatricesWeightsKind),n.push(\"#define NUM_BONE_INFLUENCERS \"+i.numBoneInfluencers),n.push(\"#define BonesPerMesh \"+(i.skeleton?i.skeleton.bones.length+1:0))):n.push(\"#define NUM_BONE_INFLUENCERS 0\"),t&&(n.push(\"#define INSTANCES\"),ro.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&n.push(\"#define THIN_INSTANCES\"));var a=n.join(\"\\n\");return this._cachedDefines!==a&&(this._cachedDefines=a,this._volumetricLightScatteringPass=i.getScene().getEngine().createEffect(\"volumetricLightScatteringPass\",r,[\"world\",\"mBones\",\"viewProjection\",\"diffuseMatrix\"],[\"diffuseSampler\"],a,void 0,void 0,void 0,{maxSimultaneousMorphTargets:i.numBoneInfluencers})),this._volumetricLightScatteringPass.isReady()},t.prototype.setCustomMeshPosition=function(e){this.customMeshPosition=e},t.prototype.getCustomMeshPosition=function(){return this.customMeshPosition},t.prototype.dispose=function(t){var i=t.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);-1!==i&&t.getScene().customRenderTargets.splice(i,1),this._volumetricLightScatteringRTT.dispose(),e.prototype.dispose.call(this,t)},t.prototype.getPass=function(){return this._volumetricLightScatteringRTT},t.prototype._meshExcluded=function(e){return this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)},t.prototype._createPass=function(e,t){var i=this,n=e.getEngine();this._volumetricLightScatteringRTT=new Ni(\"volumetricLightScatteringMap\",{width:n.getRenderWidth()*t,height:n.getRenderHeight()*t},e,!1,!0,g.a.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var r=this.getCamera();r?r.customRenderTargets.push(this._volumetricLightScatteringRTT):e.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,a=function(e){var t=e.getRenderingMesh(),n=e.getEffectiveMesh();if(!i._meshExcluded(t)){n._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var r=e.getMaterial();if(r){var o=t.getScene(),a=o.getEngine();a.setState(r.backFaceCulling);var s=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(!s.mustReturn){var c=a.getCaps().instancedArrays&&(null!==s.visibleInstances[e._id]||t.hasThinInstances);if(i._isReady(e,c)){var l=i._volumetricLightScatteringPass;if(t===i.mesh&&(l=e.effect?e.effect:r.getEffect()),a.enableEffect(l),t._bind(e,l,r.fillMode),t===i.mesh)r.bind(n.getWorldMatrix(),t);else{if(i._volumetricLightScatteringPass.setMatrix(\"viewProjection\",o.getTransformMatrix()),r&&r.needAlphaTesting()){var u=r.getAlphaTestTexture();i._volumetricLightScatteringPass.setTexture(\"diffuseSampler\",u),u&&i._volumetricLightScatteringPass.setMatrix(\"diffuseMatrix\",u.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&i._volumetricLightScatteringPass.setMatrices(\"mBones\",t.skeleton.getTransformMatrices(t))}t._processRendering(n,e,i._volumetricLightScatteringPass,xo.a.TriangleFillMode,s,c,(function(e,t){return l.setMatrix(\"world\",t)}))}}}}},c=new s.b(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=e.clearColor,e.clearColor=c})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){e.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(t,i,n,r){var o,s=e.getEngine();if(r.length){for(s.setColorWrite(!1),o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),s.setAlphaMode(g.a.ALPHA_COMBINE),o=0;o1||e.getCaps().drawBuffersExtension)},enumerable:!1,configurable:!0}),t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,\"ridge\",void 0),Object(h.c)([Object(w.c)()],t.prototype,\"valley\",void 0),t}(li);c.a.RegisteredTypes[\"BABYLON.ScreenSpaceCurvaturePostProcess\"]=sp;i(166),i(167);Object.defineProperty(Q.a.prototype,\"forceShowBoundingBoxes\",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(e){this._forceShowBoundingBoxes=e,e&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),Q.a.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new cp(this)),this._boundingBoxRenderer},Object.defineProperty(Ge.a.prototype,\"showBoundingBox\",{get:function(){return this._showBoundingBox||!1},set:function(e){this._showBoundingBox=e,e&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var cp=function(){function e(e){this.name=Me.a.NAME_BOUNDINGBOXRENDERER,this.frontColor=new s.a(1,1,1),this.backColor=new s.a(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new o.c,this.onAfterBoxRenderingObservable=new o.c,this.onResourcesReadyObservable=new o.c,this.enabled=!0,this.renderList=new oi.a(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this.scene=e,e._addComponent(this)}return e.prototype.register=function(){this.scene._beforeEvaluateActiveMeshStage.registerStep(Me.a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(Me.a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(Me.a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(Me.a.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)},e.prototype._evaluateSubMesh=function(e,t){if(e.showSubMeshesBoundingBox){var i=t.getBoundingInfo();null!=i&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}},e.prototype._preActiveMesh=function(e){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){var t=e.getBoundingInfo();t.boundingBox._tag=e.renderingGroupId,this.renderList.push(t.boundingBox)}},e.prototype._prepareResources=function(){if(!this._colorShader){this._colorShader=new Lc.a(\"colorShader\",this.scene,\"color\",{attributes:[Qi.b.PositionKind],uniforms:[\"world\",\"viewProjection\",\"color\"]}),this._colorShader.reservedDataStore={hidden:!0};var e=this.scene.getEngine(),t=Ki.a.CreateBox({size:1});this._vertexBuffers[Qi.b.PositionKind]=new Qi.b(e,t.positions,Qi.b.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=t.indices,this.onResourcesReadyObservable.notifyObservers(this)}},e.prototype._createIndexBuffer=function(){var e=this.scene.getEngine();this._indexBuffer=e.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])},e.prototype.rebuild=function(){var e=this._vertexBuffers[Qi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.reset=function(){this.renderList.reset()},e.prototype.render=function(e){if(0!==this.renderList.length&&this.enabled&&(this._prepareResources(),this._colorShader.isReady())){var t=this.scene.getEngine();t.setDepthWrite(!1),this._colorShader._preBind();for(var i=0;i\\n\\nattribute vec3 position;\\nattribute vec4 normal;\\n\\nuniform mat4 viewProjection;\\nuniform float width;\\nuniform float aspectRatio;\\nvoid main(void) {\\n#include\\nmat4 worldViewProjection=viewProjection*finalWorld;\\nvec4 viewPosition=worldViewProjection*vec4(position,1.0);\\nvec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);\\nvec2 currentScreen=viewPosition.xy/viewPosition.w;\\nvec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;\\ncurrentScreen.x*=aspectRatio;\\nnextScreen.x*=aspectRatio;\\nvec2 dir=normalize(nextScreen-currentScreen);\\nvec2 normalDir=vec2(-dir.y,dir.x);\\nnormalDir*=width/2.0;\\nnormalDir.x/=aspectRatio;\\nvec4 offset=vec4(normalDir*normal.w,0.0,0.0);\\ngl_Position=viewPosition+offset;\\n}\";ai.a.ShadersStore.lineVertexShader=up;Ge.a.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},Ge.a.prototype.enableEdgesRendering=function(e,t,i){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new dp(this,e,t,!0,i),this},Object.defineProperty(Ge.a.prototype,\"edgesRenderer\",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),Ch.b.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new fp(this,e,t),this},Ch.a.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),Ch.b.prototype.enableEdgesRendering.apply(this,arguments),this};var hp=function(){this.edges=new Array,this.edgesConnectedCount=0},dp=function(){function e(e,t,i,n,r){var o,a=this;void 0===t&&(t=.95),void 0===i&&(i=!1),void 0===n&&(n=!0),this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._buffersForInstances={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this.customInstances=new oi.a(32),this._source=e,this._checkVerticesInsteadOfIndices=i,this._options=null!=r?r:null,this._epsilon=t,this._prepareRessources(),n&&(null===(o=null==r?void 0:r.useAlternateEdgeFinder)||void 0===o||o?this._generateEdgesLinesAlternate():this._generateEdgesLines()),this._meshRebuildObserver=this._source.onRebuildObservable.add((function(){a._rebuild()})),this._meshDisposeObserver=this._source.onDisposeObservable.add((function(){a.dispose()}))}return Object.defineProperty(e.prototype,\"linesPositions\",{get:function(){return this._linesPositions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"linesNormals\",{get:function(){return this._linesNormals},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"linesIndices\",{get:function(){return this._linesIndices},enumerable:!1,configurable:!0}),e.GetShader=function(e){if(!e._edgeRenderLineShader){var t=new Lc.a(\"lineShader\",e,\"line\",{attributes:[\"position\",\"normal\"],uniforms:[\"world\",\"viewProjection\",\"color\",\"width\",\"aspectRatio\"]});t.disableDepthWrite=!0,t.backFaceCulling=!1,e._edgeRenderLineShader=t}return e._edgeRenderLineShader},e.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=e.GetShader(this._source.getScene()))},e.prototype._rebuild=function(){var e=this._buffers[Qi.b.PositionKind];e&&e._rebuild(),(e=this._buffers[Qi.b.NormalKind])&&e._rebuild();var t=this._source.getScene().getEngine();this._ib=t.createIndexBuffer(this._linesIndices)},e.prototype.dispose=function(){this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);var e=this._buffers[Qi.b.PositionKind];e&&(e.dispose(),this._buffers[Qi.b.PositionKind]=null),(e=this._buffers[Qi.b.NormalKind])&&(e.dispose(),this._buffers[Qi.b.NormalKind]=null),this._ib&&this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},e.prototype._processEdgeForAdjacencies=function(e,t,i,n,r){return e===i&&t===n||e===n&&t===i?0:e===n&&t===r||e===r&&t===n?1:e===r&&t===i||e===i&&t===r?2:-1},e.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,n,r){var o=1e-10;return e.equalsWithEpsilon(i,o)&&t.equalsWithEpsilon(n,o)||e.equalsWithEpsilon(n,o)&&t.equalsWithEpsilon(i,o)?0:e.equalsWithEpsilon(n,o)&&t.equalsWithEpsilon(r,o)||e.equalsWithEpsilon(r,o)&&t.equalsWithEpsilon(n,o)?1:e.equalsWithEpsilon(r,o)&&t.equalsWithEpsilon(i,o)||e.equalsWithEpsilon(i,o)&&t.equalsWithEpsilon(r,o)?2:-1},e.prototype._checkEdge=function(e,t,i,n,r){var o;void 0===t?o=!0:o=a.e.Dot(i[e],i[t])=0&&t.push(i);for(var n=0;n=e[0].length&&e[1].length>=e[2].length?o=1:e[2].length>=e[0].length&&e[2].length>=e[1].length&&(o=2);for(var a=0;a<3;++a)a===o?e[a].sort((function(e,t){return e[1]t[1]?1:0})):e[a].sort((function(e,t){return e[1]>t[1]?-1:e[1]=o+1;--u)r(e[u%3],c,u!==o+2?n[i[t+(u+1)%3]]:-1);var h=c.length;i.push(n[i[t+o]],s[0],c[0]),i.push(n[i[t+(o+1)%3]],c[h-1],s[l-1]);for(var d=l<=h,f=d?l:h,p=d?h:l,_=d?l-1:h-1,m=d?0:1,g=l+h-2,v=0,b=0,y=d?s:c,T=d?c:s,E=0;g-- >0;){m?i.push(y[v],T[b]):i.push(T[b],y[v]);var S=void 0;(E+=f)>=p&&v<_?(S=y[++v],E-=p):S=T[++b],i.push(S)}i[t+0]=i[i.length-3],i[t+1]=i[i.length-2],i[t+2]=i[i.length-1],i.length=i.length-3},e.prototype._generateEdgesLinesAlternate=function(){var e,t,i,n,r,o,s,c,l,u=this._source.getVerticesData(Qi.b.PositionKind),h=this._source.getIndices();if(h&&u){Array.isArray(h)||(h=Ce.b.SliceToArray(h));var d=null===(t=null===(e=this._options)||void 0===e?void 0:e.useFastVertexMerger)||void 0===t||t,f=d?Math.round(-Math.log(null!==(n=null===(i=this._options)||void 0===i?void 0:i.epsilonVertexMerge)&&void 0!==n?n:1e-6)/Math.log(10)):null!==(o=null===(r=this._options)||void 0===r?void 0:r.epsilonVertexMerge)&&void 0!==o?o:1e-6,p=[],_=[];if(d)for(var m={},g=0;gN){var $=D;D=N,N=$}if(te=Z[ee=D+\"_\"+N]){if(!te.done)a.e.Dot(J,te.normal)0||this._source.hasThinInstances)},e.prototype.render=function(){var e=this._source.getScene();if(this.isReady()&&e.activeCamera){var t=e.getEngine();this._lineShader._preBind(),1!==this._source.edgesColor.a?t.setAlphaMode(g.a.ALPHA_COMBINE):t.setAlphaMode(g.a.ALPHA_DISABLE);var i=this._source.hasInstances&&this.customInstances.length>0,n=i||this._source.hasThinInstances,r=0;if(n)if(this._buffersForInstances.world0=this._source.getVertexBuffer(\"world0\"),this._buffersForInstances.world1=this._source.getVertexBuffer(\"world1\"),this._buffersForInstances.world2=this._source.getVertexBuffer(\"world2\"),this._buffersForInstances.world3=this._source.getVertexBuffer(\"world3\"),i){var o=this._source._instanceDataStorage;if(r=this.customInstances.length,!o.isFrozen){for(var a=0,s=0;s0&&(t.push(!0),i.push(!1));this._multiRenderAttachments=this._engine.buildTextureLayout(e),this._clearAttachments=this._engine.buildTextureLayout(t),this._defaultAttachments=this._engine.buildTextureLayout(i)},e.prototype._createCompositionEffect=function(){this.prePassRT=new Hc(\"sceneprePassRT\",{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()},this.mrtCount,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:g.a.TEXTURETYPE_UNSIGNED_INT,types:this._mrtFormats}),this.prePassRT.samples=1,this._initializeAttachments(),this._useGeometryBufferFallback&&!this._geometryBuffer&&(this.useGeometryBufferFallback=!0),this.imageProcessingPostProcess=new Yi(\"sceneCompositionPass\",1,null,void 0,this._engine),this.imageProcessingPostProcess.autoClear=!1},Object.defineProperty(e.prototype,\"isSupported\",{get:function(){return this._engine.webGLVersion>1||this._scene.getEngine().getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),e.prototype.bindAttachmentsForEffect=function(e,t){if(this.enabled)if(e._multiTarget)this._engine.bindAttachments(this._multiRenderAttachments);else if(this._engine.bindAttachments(this._defaultAttachments),this._geometryBuffer){var i=t.getMaterial();i&&-1===this.excludedMaterials.indexOf(i)&&this._geometryBuffer.renderList.push(t.getRenderingMesh())}},e.prototype.restoreAttachments=function(){this.enabled&&this._defaultAttachments&&this._engine.bindAttachments(this._defaultAttachments)},e.prototype._beforeCameraDraw=function(){this._isDirty&&this._update(),this._geometryBuffer&&(this._geometryBuffer.renderList.length=0),this._bindFrameBuffer()},e.prototype._afterCameraDraw=function(){if(this._enabled){var e=this._scene.activeCamera&&this._scene.activeCamera._getFirstPostProcess();e&&this._postProcesses.length&&this._scene.postProcessManager._prepareFrame(),this._scene.postProcessManager.directRender(this._postProcesses,e?e.inputTexture:null)}},e.prototype._checkRTSize=function(){var e=this._engine.getRenderWidth(!0),t=this._engine.getRenderHeight(!0),i=this.prePassRT.getRenderWidth(),n=this.prePassRT.getRenderHeight();i===e&&n===t||(this.prePassRT.resize({width:e,height:t}),this._updateGeometryBufferLayout(),this._bindPostProcessChain())},e.prototype._bindFrameBuffer=function(){if(this._enabled){this._checkRTSize();var e=this.prePassRT.getInternalTexture();e&&this._engine.bindFramebuffer(e)}},e.prototype.clear=function(){this._enabled&&(this._bindFrameBuffer(),this._engine.clear(this._scene.clearColor,this._scene.autoClear||this._scene.forceWireframe||this._scene.forcePointsCloud,this._scene.autoClearDepthAndStencil,this._scene.autoClearDepthAndStencil),this._engine.bindAttachments(this._clearAttachments),this._engine.clear(this._clearColor,!0,!1,!1),this._engine.bindAttachments(this._defaultAttachments))},e.prototype._setState=function(e){this._enabled=e,this._scene.prePass=e,this.imageProcessingPostProcess&&(this.imageProcessingPostProcess.imageProcessingConfiguration.applyByPostProcess=e)},e.prototype._updateGeometryBufferLayout=function(){if(this._geometryBuffer){this._geometryBuffer._resetLayout();for(var e=[],t=0;t\\n#include\\n#include\\n#include\\nvarying vec2 vUV;\\nuniform vec2 texelSize;\\nuniform sampler2D textureSampler;\\nuniform sampler2D irradianceSampler;\\nuniform sampler2D depthSampler;\\nuniform sampler2D albedoSampler;\\nuniform vec2 viewportSize;\\nuniform float metersPerUnit;\\nconst float LOG2_E=1.4426950408889634;\\nconst float SSS_PIXELS_PER_SAMPLE=4.;\\nconst int _SssSampleBudget=40;\\n#define rcp(x) 1./x\\n#define Sq(x) x*x\\n#define SSS_BILATERAL_FILTER true\\n\\n\\nvec3 EvalBurleyDiffusionProfile(float r,vec3 S)\\n{\\nvec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S);\\nvec3 expSum=exp_13*(1.+exp_13*exp_13);\\nreturn (S*rcp(8.*PI))*expSum;\\n}\\n\\n\\n\\n\\n\\n\\nvec2 SampleBurleyDiffusionProfile(float u,float rcpS)\\n{\\nu=1.-u;\\nfloat g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));\\nfloat n=exp2(log2(g)*(-1.0/3.0));\\nfloat p=(g*n)*n;\\nfloat c=1.+p+n;\\nfloat d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u);\\nfloat x=(3./LOG2_E)*log2(c)-d;\\n\\n\\n\\n\\n\\n\\nfloat rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));\\nfloat r=x*rcpS;\\nfloat rcpPdf=(8.*PI*rcpS)*rcpExp;\\nreturn vec2(r,rcpPdf);\\n}\\n\\n\\nvec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)\\n{\\n#ifndef SSS_BILATERAL_FILTER\\nz=0.;\\n#endif\\n\\n\\n\\nfloat r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));\\nfloat area=rcpPdf;\\n#if SSS_CLAMP_ARTIFACT\\nreturn clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);\\n#else\\nreturn EvalBurleyDiffusionProfile(r,S)*area;\\n#endif\\n}\\nvoid EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,\\nfloat phase,inout vec3 totalIrradiance,inout vec3 totalWeight)\\n{\\n\\nfloat scale=rcp(float(n));\\nfloat offset=rcp(float(n))*0.5;\\n\\nfloat sinPhase,cosPhase;\\nsinPhase=sin(phase);\\ncosPhase=cos(phase);\\nvec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);\\nfloat r=bdp.x;\\nfloat rcpPdf=bdp.y;\\nfloat phi=SampleDiskGolden(i,n).y;\\nfloat sinPhi,cosPhi;\\nsinPhi=sin(phi);\\ncosPhi=cos(phi);\\nfloat sinPsi=cosPhase*sinPhi+sinPhase*cosPhi;\\nfloat cosPsi=cosPhase*cosPhi-sinPhase*sinPhi;\\nvec2 vec=r*vec2(cosPsi,sinPsi);\\n\\nvec2 position;\\nfloat xy2;\\nposition=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;\\nxy2=r*r;\\nvec4 textureSample=texture2D(irradianceSampler,position);\\nfloat viewZ=texture2D(depthSampler,position).r;\\nvec3 irradiance=textureSample.rgb;\\nif (testLightingForSSS(textureSample.a))\\n{\\n\\nfloat relZ=viewZ-centerPosVS.z;\\nvec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);\\ntotalIrradiance+=weight*irradiance;\\ntotalWeight+=weight;\\n}\\nelse\\n{\\n\\n\\n\\n\\n\\n\\n}\\n}\\nvoid main(void)\\n{\\nvec4 irradianceAndDiffusionProfile=texture2D(irradianceSampler,vUV);\\nvec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;\\nint diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));\\nfloat centerDepth=0.;\\nvec4 inputColor=texture2D(textureSampler,vUV);\\nbool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);\\nif (passedStencilTest)\\n{\\ncenterDepth=texture2D(depthSampler,vUV).r;\\n}\\nif (!passedStencilTest) {\\ngl_FragColor=inputColor;\\nreturn;\\n}\\nfloat distScale=1.;\\nvec3 S=diffusionS[diffusionProfileIndex];\\nfloat d=diffusionD[diffusionProfileIndex];\\nfloat filterRadius=filterRadii[diffusionProfileIndex];\\n\\nvec2 centerPosNDC=vUV;\\nvec2 cornerPosNDC=vUV+0.5*texelSize;\\nvec3 centerPosVS=vec3(centerPosNDC*viewportSize,1.0)*centerDepth;\\nvec3 cornerPosVS=vec3(cornerPosNDC*viewportSize,1.0)*centerDepth;\\n\\nfloat mmPerUnit=1000.*(metersPerUnit*rcp(distScale));\\nfloat unitsPerMm=rcp(mmPerUnit);\\n\\n\\nfloat unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);\\nfloat pixelsPerMm=rcp(unitsPerPixel)*unitsPerMm;\\n\\nfloat filterArea=PI*Sq(filterRadius*pixelsPerMm);\\nint sampleCount=int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));\\nint sampleBudget=_SssSampleBudget;\\nint texturingMode=0;\\nvec3 albedo=texture2D(albedoSampler,vUV).rgb;\\nif (distScale == 0. || sampleCount<1)\\n{\\n#ifdef DEBUG_SSS_SAMPLES\\nvec3 green=vec3(0.,1.,0.);\\ngl_FragColor=vec4(green,1.0);\\nreturn;\\n#endif\\ngl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);\\nreturn;\\n}\\n#ifdef DEBUG_SSS_SAMPLES\\nvec3 red=vec3(1.,0.,0.);\\nvec3 blue=vec3(0.,0.,1.);\\ngl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);\\nreturn;\\n#endif\\n\\nfloat phase=0.;\\nint n=min(sampleCount,sampleBudget);\\n\\nvec3 centerWeight=vec3(0.);\\nvec3 totalIrradiance=vec3(0.);\\nvec3 totalWeight=vec3(0.);\\nfor (int i=0; i=5)return m.a.Error(\"You already reached the maximum number of diffusion profiles.\"),0;for(var t=0;t\\nvoid main(void) {\\n#ifdef ALPHATEST\\nif (texture2D(diffuseSampler,vUV).a<0.4)\\ndiscard;\\n#endif\\n#include\\ngl_FragColor=color;\\n}\";ai.a.ShadersStore.outlinePixelShader=Ep;var Sp=\"\\nattribute vec3 position;\\nattribute vec3 normal;\\n#include\\n#include\\n#include[0..maxSimultaneousMorphTargets]\\n\\nuniform float offset;\\n#include\\nuniform mat4 viewProjection;\\n#ifdef ALPHATEST\\nvarying vec2 vUV;\\nuniform mat4 diffuseMatrix;\\n#ifdef UV1\\nattribute vec2 uv;\\n#endif\\n#ifdef UV2\\nattribute vec2 uv2;\\n#endif\\n#endif\\n#include\\nvoid main(void)\\n{\\nvec3 positionUpdated=position;\\nvec3 normalUpdated=normal;\\n#ifdef UV1\\nvec2 uvUpdated=uv;\\n#endif\\n#include[0..maxSimultaneousMorphTargets]\\nvec3 offsetPosition=positionUpdated+(normalUpdated*offset);\\n#include\\n#include\\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\\n#ifdef ALPHATEST\\n#ifdef UV1\\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\\n#endif\\n#ifdef UV2\\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\\n#endif\\n#endif\\n#include\\n}\\n\";ai.a.ShadersStore.outlineVertexShader=Sp;Q.a.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new Ap(this)),this._outlineRenderer},Object.defineProperty(be.a.prototype,\"renderOutline\",{get:function(){return this._renderOutline},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(be.a.prototype,\"renderOverlay\",{get:function(){return this._renderOverlay},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOverlay=e},enumerable:!0,configurable:!0});var Ap=function(){function e(e){this.name=Me.a.NAME_OUTLINERENDERER,this.zOffset=1,this.scene=e,this._engine=e.getEngine(),this.scene._addComponent(this)}return e.prototype.register=function(){this.scene._beforeRenderingMeshStage.registerStep(Me.a.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(Me.a.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype.render=function(e,t,i){var n=this;void 0===i&&(i=!1);var r=this.scene,o=r.getEngine(),a=o.getCaps().instancedArrays&&(null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id]||e.getRenderingMesh().hasThinInstances);if(this.isReady(e,a)){var s=e.getMesh(),c=s._internalAbstractMeshDataInfo._actAsRegularMesh?s:null,l=e.getRenderingMesh(),u=c||l,h=e.getMaterial();if(h&&r.activeCamera){if(o.enableEffect(this._effect),h.useLogarithmicDepth&&this._effect.setFloat(\"logarithmicDepthConstant\",2/(Math.log(r.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat(\"offset\",i?0:l.outlineWidth),this._effect.setColor4(\"color\",i?l.overlayColor:l.outlineColor,i?l.overlayAlpha:h.alpha),this._effect.setMatrix(\"viewProjection\",r.getTransformMatrix()),this._effect.setMatrix(\"world\",u.getWorldMatrix()),l.useBones&&l.computeBonesUsingShaders&&l.skeleton&&this._effect.setMatrices(\"mBones\",l.skeleton.getTransformMatrices(l)),ro.a.BindMorphTargetParameters(l,this._effect),l._bind(e,this._effect,h.fillMode),h&&h.needAlphaTesting()){var d=h.getAlphaTestTexture();d&&(this._effect.setTexture(\"diffuseSampler\",d),this._effect.setMatrix(\"diffuseMatrix\",d.getTextureMatrix()))}o.setZOffset(-this.zOffset),l._processRendering(u,e,this._effect,h.fillMode,t,a,(function(e,t){n._effect.setMatrix(\"world\",t)})),o.setZOffset(0)}}},e.prototype.isReady=function(e,t){var i=[],n=[Qi.b.PositionKind,Qi.b.NormalKind],r=e.getMesh(),o=e.getMaterial();o&&(o.needAlphaTesting()&&(i.push(\"#define ALPHATEST\"),r.isVerticesDataPresent(Qi.b.UVKind)&&(n.push(Qi.b.UVKind),i.push(\"#define UV1\")),r.isVerticesDataPresent(Qi.b.UV2Kind)&&(n.push(Qi.b.UV2Kind),i.push(\"#define UV2\"))),o.useLogarithmicDepth&&i.push(\"#define LOGARITHMICDEPTH\")),r.useBones&&r.computeBonesUsingShaders?(n.push(Qi.b.MatricesIndicesKind),n.push(Qi.b.MatricesWeightsKind),r.numBoneInfluencers>4&&(n.push(Qi.b.MatricesIndicesExtraKind),n.push(Qi.b.MatricesWeightsExtraKind)),i.push(\"#define NUM_BONE_INFLUENCERS \"+r.numBoneInfluencers),i.push(\"#define BonesPerMesh \"+(r.skeleton?r.skeleton.bones.length+1:0))):i.push(\"#define NUM_BONE_INFLUENCERS 0\");var a=r.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,i.push(\"#define MORPHTARGETS\"),i.push(\"#define NUM_MORPH_INFLUENCERS \"+s),ro.a.PrepareAttributesForMorphTargetsInfluencers(n,r,s)),t&&(i.push(\"#define INSTANCES\"),ro.a.PushAttributesForInstances(n),e.getRenderingMesh().hasThinInstances&&i.push(\"#define THIN_INSTANCES\"));var c=i.join(\"\\n\");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this.scene.getEngine().createEffect(\"outline\",n,[\"world\",\"mBones\",\"viewProjection\",\"diffuseMatrix\",\"offset\",\"color\",\"logarithmicDepthConstant\",\"morphTargetInfluences\"],[\"diffuseSampler\"],c,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype._beforeRenderingMesh=function(t,i,n){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var r=i.getMaterial();r&&r.needAlphaBlendingForMesh(t)&&(this._engine.cacheStencilState(),this._engine.setDepthWrite(!1),this._engine.setColorWrite(!1),this._engine.setStencilBuffer(!0),this._engine.setStencilOperationPass(g.a.REPLACE),this._engine.setStencilFunction(g.a.ALWAYS),this._engine.setStencilMask(e._StencilReference),this._engine.setStencilFunctionReference(e._StencilReference),this.render(i,n,!0),this._engine.setColorWrite(!0),this._engine.setStencilFunction(g.a.NOTEQUAL)),this._engine.setDepthWrite(!1),this.render(i,n),this._engine.setDepthWrite(this._savedDepthWrite),r&&r.needAlphaBlendingForMesh(t)&&this._engine.restoreStencilState()}},e.prototype._afterRenderingMesh=function(e,t,i){if(e.renderOverlay){var n=this._engine.getAlphaMode(),r=this._engine.alphaState.alphaBlend;this._engine.setAlphaMode(g.a.ALPHA_COMBINE),this.render(t,i,!0),this._engine.setAlphaMode(n),this._engine.setDepthWrite(this._savedDepthWrite),this._engine.alphaState.alphaBlend=r}e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,i),this._engine.setColorWrite(!0))},e._StencilReference=4,e}(),Pp=i(148),Cp=function(e){function t(t,i){var n=e.call(this)||this;return n.name=t,n.animations=new Array,n.isPickable=!1,n.useAlphaForPicking=!1,n.onDisposeObservable=new o.c,n._onAnimationEnd=null,n._endAnimation=function(){n._onAnimationEnd&&n._onAnimationEnd(),n.disposeWhenFinishedAnimating&&n.dispose()},n.color=new s.b(1,1,1,1),n.position=a.e.Zero(),n._manager=i,n._manager.sprites.push(n),n.uniqueId=n._manager.scene.getUniqueId(),n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,\"size\",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"manager\",{get:function(){return this._manager},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"Sprite\"},Object.defineProperty(t.prototype,\"fromIndex\",{get:function(){return this._fromIndex},set:function(e){this.playAnimation(e,this._toIndex,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"toIndex\",{get:function(){return this._toIndex},set:function(e){this.playAnimation(this._fromIndex,e,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"loopAnimation\",{get:function(){return this._loopAnimation},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,e,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"delay\",{get:function(){return Math.max(this._delay,1)},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,this._loopAnimation,e,this._onAnimationEnd)},enumerable:!1,configurable:!0}),t.prototype.playAnimation=function(t,i,n,r,o){void 0===o&&(o=null),this._onAnimationEnd=o,e.prototype.playAnimation.call(this,t,i,n,r,this._endAnimation)},t.prototype.dispose=function(){for(var e=0;ethis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onBaseAnimationEnd&&this._onBaseAnimationEnd()))))},e}());Q.a.prototype._internalPickSprites=function(e,t,i,n){if(!gn.a)return null;var r=null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers.length>0)for(var o=0;o=r.distance))&&(r=s,i))break}}return r||new gn.a},Q.a.prototype._internalMultiPickSprites=function(e,t,i){if(!gn.a)return null;var n=new Array;if(!i){if(!this.activeCamera)return null;i=this.activeCamera}if(this.spriteManagers.length>0)for(var r=0;r0&&(i=r.pickSprite(e,t,this._spritePredicate,!1,r.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite&&i.pickedSprite.actionManager){switch(r._pickedDownSprite=i.pickedSprite,n.button){case 0:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnLeftPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n));break;case 1:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnCenterPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n));break;case 2:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnRightPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n))}i.pickedSprite.actionManager&&i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickDownTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n))}return i},e.prototype._pointerUp=function(e,t,i,n){var r=this.scene;if(r.spriteManagers.length>0){var o=r.pickSprite(e,t,this._spritePredicate,!1,r.cameraToUseForPointers||void 0);o&&(o.hit&&o.pickedSprite&&o.pickedSprite.actionManager&&(o.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickUpTrigger,u.a.CreateNewFromSprite(o.pickedSprite,r,n)),o.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickTrigger,u.a.CreateNewFromSprite(o.pickedSprite,r,n)))),r._pickedDownSprite&&r._pickedDownSprite.actionManager&&r._pickedDownSprite!==o.pickedSprite&&r._pickedDownSprite.actionManager.processTrigger(g.a.ACTION_OnPickOutTrigger,u.a.CreateNewFromSprite(r._pickedDownSprite,r,n)))}return i},e}();ai.a.IncludesShadersStore.imageProcessingCompatibility=\"#ifdef IMAGEPROCESSINGPOSTPROCESS\\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\\n#endif\";var xp=\"uniform bool alphaTest;\\nvarying vec4 vColor;\\n\\nvarying vec2 vUV;\\nuniform sampler2D diffuseSampler;\\n\\n#include\\nvoid main(void) {\\nvec4 color=texture2D(diffuseSampler,vUV);\\nif (alphaTest)\\n{\\nif (color.a<0.95)\\ndiscard;\\n}\\ncolor*=vColor;\\n#include\\ngl_FragColor=color;\\n#include\\n}\";ai.a.ShadersStore.spritesPixelShader=xp;var Op=\"\\nattribute vec4 position;\\nattribute vec2 options;\\nattribute vec2 offsets;\\nattribute vec2 inverts;\\nattribute vec4 cellInfo;\\nattribute vec4 color;\\n\\nuniform mat4 view;\\nuniform mat4 projection;\\n\\nvarying vec2 vUV;\\nvarying vec4 vColor;\\n#include\\nvoid main(void) {\\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;\\nvec2 cornerPos;\\nfloat angle=position.w;\\nvec2 size=vec2(options.x,options.y);\\nvec2 offset=offsets.xy;\\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\\n\\nvec3 rotatedCorner;\\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\\nrotatedCorner.z=0.;\\n\\nviewPos+=rotatedCorner;\\ngl_Position=projection*vec4(viewPos,1.0);\\n\\nvColor=color;\\n\\nvec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));\\nvec2 uvPlace=cellInfo.xy;\\nvec2 uvSize=cellInfo.zw;\\nvUV.x=uvPlace.x+uvSize.x*uvOffset.x;\\nvUV.y=uvPlace.y+uvSize.y*uvOffset.y;\\n\\n#ifdef FOG\\nvFogDistance=viewPos;\\n#endif\\n}\";ai.a.ShadersStore.spritesVertexShader=Op;var Mp=function(){function e(e,t,i,n){if(void 0===i&&(i=.01),void 0===n&&(n=null),this.blendMode=g.a.ALPHA_COMBINE,this.autoResetAlpha=!0,this.disableDepthWrite=!1,this.fogEnabled=!0,this._useVAO=!1,this._useInstancing=!1,this._vertexBuffers={},this._capacity=t,this._epsilon=i,this._engine=e,this._useInstancing=e.getCaps().instancedArrays,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects,this._scene=n,!this._useInstancing){for(var r=[],o=0,a=0;a>0;t._xOffset=(t.cellIndex-l*c)*this.cellWidth/r.width,t._yOffset=l*this.cellHeight/r.height,t._xSize=this.cellWidth,t._ySize=this.cellHeight}this._vertexData[s]=t.position.x,this._vertexData[s+1]=t.position.y,this._vertexData[s+2]=t.position.z,this._vertexData[s+3]=t.angle,this._vertexData[s+4]=t.width,this._vertexData[s+5]=t.height,this._useInstancing?s-=2:(this._vertexData[s+6]=i,this._vertexData[s+7]=n),this._vertexData[s+8]=o?t.invertU?0:1:t.invertU?1:0,this._vertexData[s+9]=t.invertV?1:0,this._vertexData[s+10]=t._xOffset,this._vertexData[s+11]=t._yOffset,this._vertexData[s+12]=t._xSize/r.width,this._vertexData[s+13]=t._ySize/r.height,this._vertexData[s+14]=t.color.r,this._vertexData[s+15]=t.color.g,this._vertexData[s+16]=t.color.b,this._vertexData[s+17]=t.color.a},e.prototype.dispose=function(){this._buffer&&(this._buffer.dispose(),this._buffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),this.texture&&(this.texture.dispose(),this.texture=null)},e}(),Ip=function(){function e(e,t,i,n,r,a,s,c,l){var u=this;void 0===a&&(a=.01),void 0===s&&(s=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=!1),void 0===l&&(l=null),this.name=e,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.isPickable=!1,this.onDisposeObservable=new o.c,this.disableDepthWrite=!1,this._packedAndReady=!1,this._customUpdate=function(e,t){e.cellRef||(e.cellIndex=0);var i=e.cellIndex;\"number\"==typeof i&&isFinite(i)&&Math.floor(i)===i&&(e.cellRef=u._spriteMap[e.cellIndex]),e._xOffset=u._cellData[e.cellRef].frame.x/t.width,e._yOffset=u._cellData[e.cellRef].frame.y/t.height,e._xSize=u._cellData[e.cellRef].frame.w,e._ySize=u._cellData[e.cellRef].frame.h},r||(r=Se.a.LastCreatedScene),r._getComponent(Me.a.NAME_SPRITE)||r._addComponent(new Rp(r)),this._fromPacked=c,this._scene=r;var h=this._scene.getEngine();if(this._spriteRenderer=new Mp(h,i,a,r),n.width&&n.height)this.cellWidth=n.width,this.cellHeight=n.height;else{if(void 0===n)return void(this._spriteRenderer=null);this.cellWidth=n,this.cellHeight=n}this._scene.spriteManagers.push(this),this.uniqueId=this.scene.getUniqueId(),t&&(this.texture=new Ke.a(t,r,!0,!1,s)),this._fromPacked&&this._makePacked(t,l)}return Object.defineProperty(e.prototype,\"onDispose\",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"children\",{get:function(){return this.sprites},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"scene\",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"capacity\",{get:function(){return this._spriteRenderer.capacity},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"texture\",{get:function(){return this._spriteRenderer.texture},set:function(e){e.wrapU=Ke.a.CLAMP_ADDRESSMODE,e.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._spriteRenderer.texture=e,this._textureContent=null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"cellWidth\",{get:function(){return this._spriteRenderer.cellWidth},set:function(e){this._spriteRenderer.cellWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"cellHeight\",{get:function(){return this._spriteRenderer.cellHeight},set:function(e){this._spriteRenderer.cellHeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"fogEnabled\",{get:function(){return this._spriteRenderer.fogEnabled},set:function(e){this._spriteRenderer.fogEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"blendMode\",{get:function(){return this._spriteRenderer.blendMode},set:function(e){this._spriteRenderer.blendMode=e},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return\"SpriteManager\"},e.prototype._makePacked=function(e,t){var i=this;if(null!==t)try{var n=void 0;if((n=\"string\"==typeof t?JSON.parse(t):t).frames.length){for(var r={},o=0;o0);var u=e.substring(0,l-1)+\".json\",h=new XMLHttpRequest;h.open(\"GET\",u,!0),h.onerror=function(){m.a.Error(\"JSON ERROR: Unable to load JSON file.\"),i._fromPacked=!1,i._packedAndReady=!1},h.onload=function(){try{var e=JSON.parse(h.response),t=Reflect.ownKeys(e.frames);i._spriteMap=t,i._packedAndReady=!0,i._cellData=e.frames}catch(e){throw i._fromPacked=!1,i._packedAndReady=!1,new Error(\"Invalid JSON format. Please check documentation for format specifications.\")}},h.send()}},e.prototype._checkTextureAlpha=function(e,t,i,n,r){if(!e.useAlphaForPicking||!this.texture)return!0;var o=this.texture.getSize();this._textureContent||(this._textureContent=new Uint8Array(o.width*o.height*4),this.texture.readPixels(0,0,this._textureContent));var s=a.c.Vector3[0];s.copyFrom(t.direction),s.normalize(),s.scaleInPlace(i),s.addInPlace(t.origin);var c=(s.x-n.x)/(r.x-n.x)-.5,l=1-(s.y-n.y)/(r.y-n.y)-.5,u=e.angle,h=c*Math.cos(u)-l*Math.sin(u)+.5,d=c*Math.sin(u)+l*Math.cos(u)+.5,f=e._xOffset*o.width+h*e._xSize|0,p=e._yOffset*o.height+d*e._ySize|0;return this._textureContent[4*(f+p*o.width)+3]>.5},e.prototype.intersects=function(e,t,i,n){for(var r=Math.min(this.capacity,this.sprites.length),o=a.e.Zero(),s=a.e.Zero(),c=Number.MAX_VALUE,l=null,u=a.c.Vector3[0],h=a.c.Vector3[1],d=t.getViewMatrix(),f=0;f_){if(!this._checkTextureAlpha(p,e,_,o,s))continue;if(c=_,l=p,n)break}}}}if(l){var m=new gn.a;d.invertToRef(a.c.Matrix[0]),m.hit=!0,m.pickedSprite=l,m.distance=c;var g=a.c.Vector3[2];return g.copyFrom(e.direction),g.normalize(),g.scaleInPlace(c),e.origin.addToRef(g,u),m.pickedPoint=a.e.TransformCoordinates(u,a.c.Matrix[0]),m}return null},e.prototype.multiIntersects=function(e,t,i){for(var n,r=Math.min(this.capacity,this.sprites.length),o=a.e.Zero(),s=a.e.Zero(),c=[],l=a.c.Vector3[0].copyFromFloats(0,0,0),u=a.c.Vector3[1].copyFromFloats(0,0,0),h=t.getViewMatrix(),d=0;d0.) {\\nmt=mod(time*animationData.z,1.0);\\nfor(float f=0.; fmt){\\nframeID=animationData.x;\\nbreak;\\n}\\nanimationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);\\n}\\n}\\n\\nmat4 frameData=getFrameData(frameID+0.5);\\nvec2 frameSize=(frameData[0].wz)/spriteMapSize;\\nvec2 offset=frameData[0].xy*sheetUnits;\\nvec2 ratio=frameData[2].xy/frameData[0].wz;\\n\\nif (frameData[2].z == 1.){\\ntileUV.xy=tileUV.yx;\\n}\\nif (i == 0){\\ncolor=texture2D(spriteSheet,tileUV*frameSize+offset);\\n} else {\\nvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);\\nfloat alpha=min(color.a+nc.a,1.0);\\nvec3 mixed=mix(color.xyz,nc.xyz,nc.a);\\ncolor=vec4(mixed,alpha);\\n}\\n}\\ncolor.xyz*=colorMul;\\ngl_FragColor=color;\\n}\";ai.a.ShadersStore.spriteMapPixelShader=Dp;var Np=\"precision highp float;\\n\\nattribute vec3 position;\\nattribute vec3 normal;\\nattribute vec2 uv;\\n\\nvarying vec3 vPosition;\\nvarying vec2 vUV;\\nvarying vec2 tUV;\\nvarying vec2 stageUnits;\\nvarying vec2 levelUnits;\\nvarying vec2 tileID;\\n\\nuniform float time;\\nuniform mat4 worldViewProjection;\\nuniform vec2 outputSize;\\nuniform vec2 stageSize;\\nuniform vec2 spriteMapSize;\\nuniform float stageScale;\\nvoid main() {\\nvec4 p=vec4( position,1. );\\nvPosition=p.xyz;\\nvUV=uv;\\ntUV=uv*stageSize;\\ngl_Position=worldViewProjection*p;\\n}\";ai.a.ShadersStore.spriteMapVertexShader=Np;var Lp,wp=function(){function e(e,t,i,n,r){var o=this;this.name=e,this.sprites=[],this.atlasJSON=t,this.sprites=this.atlasJSON.frames,this.spriteSheet=i,this.options=n,n.stageSize=n.stageSize||new a.d(1,1),n.outputSize=n.outputSize||n.stageSize,n.outputPosition=n.outputPosition||a.e.Zero(),n.outputRotation=n.outputRotation||a.e.Zero(),n.layerCount=n.layerCount||1,n.maxAnimationFrames=n.maxAnimationFrames||0,n.baseTile=n.baseTile||0,n.flipU=n.flipU||!1,n.colorMultiply=n.colorMultiply||new a.e(1,1,1),this._scene=r,this._frameMap=this._createFrameBuffer(),this._tileMaps=new Array;for(var s=0;s0&&(e+=\"\\n\\r\"),e+=this._tileMaps[t]._texture._bufferView.toString();var i=document.createElement(\"a\");i.href=\"data:octet/stream;charset=utf-8,\"+encodeURI(e),i.target=\"_blank\",i.download=this.name+\".tilemaps\",i.click(),i.remove()},e.prototype.loadTileMaps=function(e){var t=this,i=new XMLHttpRequest;i.open(\"GET\",e);var n=this.options.layerCount||0;i.onload=function(){for(var e=i.response.split(\"\\n\\r\"),r=0;r-1&&this._tasks.splice(t,1)},e.prototype._decreaseWaitingTasksCount=function(e){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,e),this.onProgressObservable.notifyObservers(new jp(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){m.a.Error(\"Error running progress callbacks.\"),console.log(e)}if(0===this._waitingTasksCount){try{var t=this._tasks.slice();this.onFinish&&this.onFinish(t);for(var i=0,n=t;i-1&&this._tasks.splice(r,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){m.a.Error(\"Error running tasks-done callbacks.\"),console.log(e)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}},e.prototype._runTask=function(e){var t=this,i=function(i,n){e._setErrorObject(i,n),t.onTaskError&&t.onTaskError(e),t.onTaskErrorObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)};e.run(this._scene,(function(){try{t.onTaskSuccess&&t.onTaskSuccess(e),t.onTaskSuccessObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)}catch(e){i(\"Error executing task success callbacks\",e)}}),i)},e.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},e.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,0===this._waitingTasksCount)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e=0&&this._meshes.splice(i,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var n=0;n0&&this._textureLoadingCallback(e)}this._currentScene.render()}},e.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},e.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},e.prototype._traverseFolder=function(e,t,i,n){var r=this,o=e.createReader(),a=e.fullPath.replace(/^\\//,\"\").replace(/(.+?)\\/?$/,\"$1/\");o.readEntries((function(e){i.count+=e.length;for(var o=0,s=e;o0)){for(var i=new Array,n=[],r=e.dataTransfer?e.dataTransfer.items:null,o=0;o0&&m.a.ClearLogCache(),this._engine.stopRenderLoop()),pr.ShowLoadingScreen=!1,this._engine.displayLoadingUI(),pr.LoadAsync(\"file:\",this._sceneFileToLoad,this._engine,(function(t){e._progressCallback&&e._progressCallback(t)})).then((function(t){e._currentScene&&e._currentScene.dispose(),e._currentScene=t,e._sceneLoadedCallback&&e._sceneLoadedCallback(e._sceneFileToLoad,e._currentScene),e._currentScene.executeWhenReady((function(){e._engine.hideLoadingUI(),e._engine.runRenderLoop((function(){e.renderFunction()}))}))})).catch((function(t){e._engine.hideLoadingUI(),e._errorCallback&&e._errorCallback(e._sceneFileToLoad,e._currentScene,t.message)}))):m.a.Error(\"Please provide a valid .babylon file.\")},e}(),n_=i(146),r_=i(145),o_=function(){function e(e){void 0===e&&(e=0),this.priority=e}return e.prototype.getDescription=function(){return\"\"},e.prototype.apply=function(e,t){return!0},e}(),a_=function(e){function t(t,i,n){void 0===t&&(t=0),void 0===i&&(i=1024),void 0===n&&(n=.5);var r=e.call(this,t)||this;return r.priority=t,r.maximumSize=i,r.step=n,r}return Object(h.d)(t,e),t.prototype.getDescription=function(){return\"Reducing render target texture size to \"+this.maximumSize},t.prototype.apply=function(e,t){for(var i=!0,n=0;nthis.maximumSize&&(r.scale(this.step),i=!1)}}return i},t}(o_),s_=function(e){function t(t,i,n){void 0===t&&(t=0),void 0===i&&(i=2),void 0===n&&(n=.25);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r.step=n,r._currentScale=-1,r._directionOffset=1,r}return Object(h.d)(t,e),t.prototype.getDescription=function(){return\"Setting hardware scaling level to \"+this._currentScale},t.prototype.apply=function(e,t){return-1===this._currentScale&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),1===this._directionOffset?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(o_),c_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.getDescription=function(){return\"Turning shadows on/off\"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t}(o_),l_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.getDescription=function(){return\"Turning post-processes on/off\"},t.prototype.apply=function(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0},t}(o_),u_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.getDescription=function(){return\"Turning lens flares on/off\"},t.prototype.apply=function(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0},t}(o_),h_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():\"Running user defined callback\"},t.prototype.apply=function(e,t){return!this.onApply||this.onApply(e,t)},t}(o_),d_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.getDescription=function(){return\"Turning particles on/off\"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t}(o_),f_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.getDescription=function(){return\"Turning render targets off\"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t}(o_),p_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof be.a))return!1;var t=e;return!t.isDisposed()&&(!(!t.isVisible||!t.isEnabled())&&(!(t.instances.length>0)&&(!t.skeleton&&!t.hasLODLevels)))},t}return Object(h.d)(t,e),Object.defineProperty(t,\"UpdateSelectionTree\",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return\"Merging similar meshes together\"},t.prototype.apply=function(e,i,n){for(var r=e.meshes.slice(0),o=r.length,a=0;a=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var n=!0,r=!0,o=0;o0){o.animationGroups=[];for(var h=0;h0)for(o.reflectionProbes=[],i=0;i0&&setTimeout((function(){i.stopRecording()}),1e3*t),this._fileName=e,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise((function(e,t){i._resolve=e,i._reject=t}))},e.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},e.prototype._handleDataAvailable=function(e){e.data.size>0&&this._recordedChunks.push(e.data)},e.prototype._handleError=function(e){if(this.stopRecording(),!this._reject)throw new e.error;this._reject(e.error)},e.prototype._handleStop=function(){this.stopRecording();var e=new Blob(this._recordedChunks);this._resolve&&this._resolve(e),window.URL.createObjectURL(e),this._fileName&&Ce.b.Download(e,this._fileName)},e._defaultOptions={mimeType:\"video/webm\",fps:25,recordChunckSize:3e3},e}(),A_=function(){function e(){}return e.CreateScreenshot=function(t,i,n,r,o){void 0===o&&(o=\"image/png\");var a=e._getScreenshotSize(t,i,n),s=a.height,c=a.width;if(s&&c){Ce.b._ScreenshotCanvas||(Ce.b._ScreenshotCanvas=document.createElement(\"canvas\")),Ce.b._ScreenshotCanvas.width=c,Ce.b._ScreenshotCanvas.height=s;var l=Ce.b._ScreenshotCanvas.getContext(\"2d\"),u=t.getRenderWidth()/t.getRenderHeight(),h=c,d=h/u;d>s&&(h=(d=s)*u);var f=Math.max(0,c-h)/2,p=Math.max(0,s-d)/2,_=t.getRenderingCanvas();l&&_&&l.drawImage(_,f,p,h,d),Ce.b.EncodeScreenshotCanvasData(r,o)}else m.a.Error(\"Invalid 'size' parameter !\")},e.CreateScreenshotAsync=function(t,i,n,r){return void 0===r&&(r=\"image/png\"),new Promise((function(o,a){e.CreateScreenshot(t,i,n,(function(e){void 0!==e?o(e):a(new Error(\"Data is undefined\"))}),r)}))},e.CreateScreenshotUsingRenderTarget=function(t,i,n,r,o,a,s,c,l,u){void 0===o&&(o=\"image/png\"),void 0===a&&(a=1),void 0===s&&(s=!1),void 0===l&&(l=!1),void 0===u&&(u=!1);var h=e._getScreenshotSize(t,i,n),d=h.height,f=h.width,p={width:f,height:d};if(d&&f){var _=t.getRenderingCanvas();if(_){var v={width:_.width,height:_.height};t.setSize(f,d);var b=i.getScene(),y=null,T=b.activeCameras;(b.activeCamera!==i||b.activeCameras&&b.activeCameras.length)&&(y=b.activeCamera,b.activeCamera=i),b.render();var E=new Ni(\"screenShot\",p,b,!1,!1,g.a.TEXTURETYPE_UNSIGNED_INT,!1,Ke.a.NEAREST_SAMPLINGMODE,void 0,u);E.renderList=null,E.samples=a,E.renderSprites=l,E.onAfterRenderObservable.add((function(){Ce.b.DumpFramebuffer(f,d,t,r,o,c)}));var S=function(){b.incrementRenderId(),b.resetCachedMaterial(),E.render(!0),E.dispose(),y&&(b.activeCamera=y),b.activeCameras=T,t.setSize(v.width,v.height),i.getProjectionMatrix(!0)};if(s){var A=new mf(\"antialiasing\",1,b.activeCamera);E.addPostProcess(A),A.getEffect().isReady()?S():A.getEffect().onCompiled=function(){S()}}else S()}else m.a.Error(\"No rendering canvas found !\")}else m.a.Error(\"Invalid 'size' parameter !\")},e.CreateScreenshotUsingRenderTargetAsync=function(t,i,n,r,o,a,s,c){return void 0===r&&(r=\"image/png\"),void 0===o&&(o=1),void 0===a&&(a=!1),void 0===c&&(c=!1),new Promise((function(l,u){e.CreateScreenshotUsingRenderTarget(t,i,n,(function(e){void 0!==e?l(e):u(new Error(\"Data is undefined\"))}),r,o,a,s,c)}))},e._getScreenshotSize=function(e,t,i){var n=0,r=0;if(\"object\"==typeof i){var o=i.precision?Math.abs(i.precision):1;i.width&&i.height?(n=i.height*o,r=i.width*o):i.width&&!i.height?(r=i.width*o,n=Math.round(r/e.getAspectRatio(t))):i.height&&!i.width?(n=i.height*o,r=Math.round(n*e.getAspectRatio(t))):(r=Math.round(e.getRenderWidth()*o),n=Math.round(r/e.getAspectRatio(t)))}else isNaN(i)||(n=i,r=i);return r&&(r=Math.floor(r)),n&&(n=Math.floor(n)),{height:0|n,width:0|r}},e}();Ce.b.CreateScreenshot=A_.CreateScreenshot,Ce.b.CreateScreenshotAsync=A_.CreateScreenshotAsync,Ce.b.CreateScreenshotUsingRenderTarget=A_.CreateScreenshotUsingRenderTarget,Ce.b.CreateScreenshotUsingRenderTargetAsync=A_.CreateScreenshotUsingRenderTargetAsync,function(e){e[e.Checkbox=0]=\"Checkbox\",e[e.Slider=1]=\"Slider\",e[e.Vector3=2]=\"Vector3\",e[e.Quaternion=3]=\"Quaternion\",e[e.Color3=4]=\"Color3\",e[e.String=5]=\"String\"}(zp||(zp={}));var P_,C_=i(140),R_=function(){function e(e){this.byteOffset=0,this.buffer=e}return e.prototype.loadAsync=function(e){var t=this;return this.buffer.readAsync(this.byteOffset,e).then((function(e){t._dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),t._dataByteOffset=0}))},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,e},e.prototype.readUint8Array=function(e){var t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,e);return this._dataByteOffset+=e,this.byteOffset+=e,t},e.prototype.readString=function(e){return io.a.Decode(this.readUint8Array(e))},e.prototype.skipBytes=function(e){this._dataByteOffset+=e,this.byteOffset+=e},e}(),x_=function(){function e(){}return e._GetStorage=function(){try{return localStorage.setItem(\"test\",\"\"),localStorage.removeItem(\"test\"),localStorage}catch(t){var e={};return{getItem:function(t){var i=e[t];return void 0===i?null:i},setItem:function(t,i){e[t]=i}}}},e.ReadString=function(e,t){var i=this._Storage.getItem(e);return null!==i?i:t},e.WriteString=function(e,t){this._Storage.setItem(e,t)},e.ReadBoolean=function(e,t){var i=this._Storage.getItem(e);return null!==i?\"true\"===i:t},e.WriteBoolean=function(e,t){this._Storage.setItem(e,t?\"true\":\"false\")},e.ReadNumber=function(e,t){var i=this._Storage.getItem(e);return null!==i?parseFloat(i):t},e.WriteNumber=function(e,t){this._Storage.setItem(e,t.toString())},e._Storage=e._GetStorage(),e}(),O_=function(){function e(){this._trackedScene=null}return e.prototype.track=function(e){this._trackedScene=e,this._savedJSON=y_.Serialize(e)},e.prototype.getDelta=function(){if(!this._trackedScene)return null;var e=y_.Serialize(this._trackedScene),t={};for(var i in e)this._compareCollections(i,this._savedJSON[i],e[i],t);return t},e.prototype._compareArray=function(e,t,i,n){if(0===t.length&&0===i.length)return!0;if(t.length&&!isNaN(t[0])||i.length&&!isNaN(i[0])){if(t.length!==i.length)return!1;if(0===t.length)return!0;for(var r=0;re.MAX_SEQUENCE_LENGTH)throw new Error(\"Sequences longer than \"+e.MAX_SEQUENCE_LENGTH+\" not supported.\");this._alphabet=i,this._characters=t.map((function(e){return n._alphabet.getCharacterIdx(e)}))}return e.prototype.serialize=function(){return JSON.stringify(this._characters)},e.Deserialize=function(t,i){var n=new e([],i);return n._characters=JSON.parse(t),n},e.prototype.distance=function(t){return e._distance(this,t)},e._distance=function(t,i){var n=t._alphabet;if(n!==i._alphabet)throw new Error(\"Cannot Levenshtein compare Sequences built from different alphabets.\");var r=t._characters,o=i._characters,a=r.length,s=o.length,c=e._costMatrix;c[0][0]=0;for(var l=0;l.98)&&(a.e.CrossToRef(e._forwardDir,e._inverseFromVec,e._upDir),e._upDir.normalize(),a.a.LookAtLHToRef(t,i,e._upDir,e._lookMatrix),n.subtractToRef(i,e._fromToVec),e._fromToVec.normalize(),a.e.TransformNormalToRef(e._fromToVec,e._lookMatrix,r),!0)},e._tokenizeSegment=function(t,i){e._bestMatch=0,e._score=a.e.Dot(t,i[0]),e._bestScore=e._score;for(var n=1;ne._bestScore&&(e._bestMatch=n,e._bestScore=e._score);return e._bestMatch},e._forwardDir=new a.e,e._inverseFromVec=new a.e,e._upDir=new a.e,e._fromToVec=new a.e,e._lookMatrix=new a.a,e}(),I_=function(){function e(e){this.chars=new Array(e)}return e.Generate=function(t,i,n,r,o){void 0===t&&(t=64),void 0===i&&(i=256),void 0===n&&(n=.1),void 0===r&&(r=.001),void 0===o&&(o=[]);for(var s,c,l=new e(t),u=0;u1e-6&&f.scaleAndAddToRef(1/(f.lengthSquared()*c),d)})),d.scaleInPlace(s),l.chars[e].addInPlace(d),l.chars[e].normalize()};for(u=o.length;u4;o=Math.floor(o/2))r.push(t.resampleAtTargetResolution(o).tokenize(i.chars));return r},e.prototype.distance=function(e){for(var t=0,i=0;i0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,e.MIN_AVERAGE_DISTANCE))},e.MIN_AVERAGE_DISTANCE=1,e}(),L_=function(){function e(){this._maximumAllowableMatchCost=4,this._nameToDescribedTrajectory=new Map}return e.prototype.serialize=function(){var e={};return e.maximumAllowableMatchCost=this._maximumAllowableMatchCost,e.vector3Alphabet=this._vector3Alphabet.serialize(),e.levenshteinAlphabet=this._levenshteinAlphabet.serialize(),e.nameToDescribedTrajectory=[],this._nameToDescribedTrajectory.forEach((function(t,i){e.nameToDescribedTrajectory.push(i),e.nameToDescribedTrajectory.push(t.serialize())})),JSON.stringify(e)},e.Deserialize=function(t){var i=JSON.parse(t),n=new e;n._maximumAllowableMatchCost=i.maximumAllowableMatchCost,n._vector3Alphabet=I_.Deserialize(i.vector3Alphabet),n._levenshteinAlphabet=P_.Alphabet.Deserialize(i.levenshteinAlphabet);for(var r=0;r0&&this.onFeaturePointsAddedObservable.notifyObservers(r),n.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(n)}}},t.prototype._init=function(){this._xrSessionManager.session.trySetFeaturePointCloudEnabled&&this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)&&(this._enabled=!0)},t.Name=Ia.FEATURE_POINTS,t.Version=1,t}(ja);Da.AddWebXRFeature(H_.Name,(function(e){return function(){return new H_(e)}}),H_.Version);var X_=function(){function e(e,t,i,n,r){this.xrController=e,this.trackedMeshes=t,this._handMesh=i,this._rigMapping=n,this._defaultHandMesh=!1,this._transformNodeMapping=[],this.handPartsDefinition=this.generateHandPartsDefinition(e.inputSource.hand),this._scene=t[0].getScene(),this._handMesh&&this._rigMapping?this._defaultHandMesh=!1:r||this._generateDefaultHandMesh(),this.xrController.motionController&&(this.xrController.motionController.rootMesh?this.xrController.motionController.rootMesh.setEnabled(!1):this.xrController.motionController.onModelLoadedObservable.add((function(e){e.rootMesh&&e.rootMesh.setEnabled(!1)}))),this.xrController.onMotionControllerInitObservable.add((function(e){e.onModelLoadedObservable.add((function(e){e.rootMesh&&e.rootMesh.setEnabled(!1)})),e.rootMesh&&e.rootMesh.setEnabled(!1)}))}return e.prototype.generateHandPartsDefinition=function(e){var t;return(t={}).wrist=[e.WRIST],t.thumb=[e.THUMB_METACARPAL,e.THUMB_PHALANX_PROXIMAL,e.THUMB_PHALANX_DISTAL,e.THUMB_PHALANX_TIP],t.index=[e.INDEX_METACARPAL,e.INDEX_PHALANX_PROXIMAL,e.INDEX_PHALANX_INTERMEDIATE,e.INDEX_PHALANX_DISTAL,e.INDEX_PHALANX_TIP],t.middle=[e.MIDDLE_METACARPAL,e.MIDDLE_PHALANX_PROXIMAL,e.MIDDLE_PHALANX_INTERMEDIATE,e.MIDDLE_PHALANX_DISTAL,e.MIDDLE_PHALANX_TIP],t.ring=[e.RING_METACARPAL,e.RING_PHALANX_PROXIMAL,e.RING_PHALANX_INTERMEDIATE,e.RING_PHALANX_DISTAL,e.RING_PHALANX_TIP],t.little=[e.LITTLE_METACARPAL,e.LITTLE_PHALANX_PROXIMAL,e.LITTLE_PHALANX_INTERMEDIATE,e.LITTLE_PHALANX_DISTAL,e.LITTLE_PHALANX_TIP],t},e.prototype.updateFromXRFrame=function(e,t,i){var n=this;void 0===i&&(i=2);var r=this.xrController.inputSource.hand;r&&this.trackedMeshes.forEach((function(o,a){var s=r[a];if(s){var c=e.getJointPose(s,t);if(!c||!c.transform)return;var l=c.transform.position,u=c.transform.orientation;o.position.set(l.x,l.y,l.z),o.rotationQuaternion.set(u.x,u.y,u.z,u.w);var h=(c.radius||.008)*i;o.scaling.set(h,h,h),n._handMesh&&n._rigMapping&&n._rigMapping[a]&&(n._transformNodeMapping[a]=n._transformNodeMapping[a]||n._scene.getTransformNodeByName(n._rigMapping[a]),n._transformNodeMapping[a]&&(n._transformNodeMapping[a].position.copyFrom(o.position),n._transformNodeMapping[a].rotationQuaternion.copyFrom(o.rotationQuaternion),o.isVisible=!1)),o.getScene().useRightHandedSystem||(o.position.z*=-1,o.rotationQuaternion.z*=-1,o.rotationQuaternion.w*=-1)}}))},e.prototype.getHandPartMeshes=function(e){var t=this;return this.handPartsDefinition[e].map((function(e){return t.trackedMeshes[e]}))},e.prototype.dispose=function(){this.trackedMeshes.forEach((function(e){return e.dispose()})),this._defaultHandMesh&&this._handMesh&&this._handMesh.dispose()},e.prototype._generateDefaultHandMesh=function(){return Object(h.b)(this,void 0,void 0,(function(){var e,t,i,n,r,o,a,c;return Object(h.e)(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),e=\"right\"===this.xrController.inputSource.handedness?\"right\":\"left\",t=(\"right\"===e?\"r\":\"l\")+\"_hand_\"+(this._scene.useRightHandedSystem?\"r\":\"l\")+\"hs.glb\",[4,pr.ImportMeshAsync(\"\",\"https://assets.babylonjs.com/meshes/HandMeshes/\",t,this._scene)];case 1:return i=l.sent(),n={base:s.a.FromInts(116,63,203),fresnel:s.a.FromInts(149,102,229),fingerColor:s.a.FromInts(177,130,255),tipFresnel:s.a.FromInts(220,200,255)},[4,(r=new ql(\"leftHandShader\",this._scene,{emitComments:!1})).loadAsync(\"https://patrickryanms.github.io/BabylonJStextures/Demos/xrHandMesh/handsShader.json\")];case 2:if(l.sent(),r.build(!1),r.needDepthPrePass=!0,r.transparencyMode=xo.a.MATERIAL_ALPHABLEND,r.alphaMode=Se.a.ALPHA_COMBINE,(o={base:r.getBlockByName(\"baseColor\"),fresnel:r.getBlockByName(\"fresnelColor\"),fingerColor:r.getBlockByName(\"fingerColor\"),tipFresnel:r.getBlockByName(\"tipFresnelColor\")}).base.value=n.base,o.fresnel.value=n.fresnel,o.fingerColor.value=n.fingerColor,o.tipFresnel.value=n.tipFresnel,i.meshes[1].material=r,this._defaultHandMesh=!0,this._handMesh=i.meshes[0],this._rigMapping=[\"wrist_\",\"thumb_metacarpal_\",\"thumb_proxPhalanx_\",\"thumb_distPhalanx_\",\"thumb_tip_\",\"index_metacarpal_\",\"index_proxPhalanx_\",\"index_intPhalanx_\",\"index_distPhalanx_\",\"index_tip_\",\"middle_metacarpal_\",\"middle_proxPhalanx_\",\"middle_intPhalanx_\",\"middle_distPhalanx_\",\"middle_tip_\",\"ring_metacarpal_\",\"ring_proxPhalanx_\",\"ring_intPhalanx_\",\"ring_distPhalanx_\",\"ring_tip_\",\"little_metacarpal_\",\"little_proxPhalanx_\",\"little_intPhalanx_\",\"little_distPhalanx_\",\"little_tip_\"].map((function(t){return t+(\"right\"===e?\"R\":\"L\")})),!(a=this._scene.getTransformNodeByName(this._rigMapping[0])))throw new Error(\"could not find the wrist node\");return a.parent&&a.parent.rotate(J.a.Y,Math.PI),[3,4];case 3:return c=l.sent(),Ce.b.Error(\"error loading hand mesh\"),console.log(c),[3,4];case 4:return[2]}}))}))},e}(),Y_=function(e){function t(i,n){var r=e.call(this,i)||this;return r.options=n,r.onHandAddedObservable=new o.c,r.onHandRemovedObservable=new o.c,r._hands={},r._attachHand=function(e){var i,n,o,s,c,l,u,d,f,p;if(e.inputSource.hand&&!r._hands[e.uniqueId]){var _=e.inputSource.hand,m=[],g=(null===(i=r.options.jointMeshes)||void 0===i?void 0:i.sourceMesh)||xr.a.CreateSphere(\"jointParent\",{diameter:1});g.isVisible=!!(null===(n=r.options.jointMeshes)||void 0===n?void 0:n.keepOriginalVisible);for(var v=0;v<_.length;++v){var b=g.createInstance(e.uniqueId+\"-handJoint-\"+v);if(null===(o=r.options.jointMeshes)||void 0===o?void 0:o.onHandJointMeshGenerated){var y=r.options.jointMeshes.onHandJointMeshGenerated(b,v,e.uniqueId);y&&y!==b&&(b.dispose(),b=y)}if(b.isPickable=!1,null===(s=r.options.jointMeshes)||void 0===s?void 0:s.enablePhysics){var T=r.options.jointMeshes.physicsProps||{},E=void 0!==T.impostorType?T.impostorType:dc.a.SphereImpostor;b.physicsImpostor=new dc.a(b,E,Object(h.a)({mass:0},T))}b.rotationQuaternion=new a.b,(null===(c=r.options.jointMeshes)||void 0===c?void 0:c.invisible)&&(b.isVisible=!1),m.push(b)}var S=\"right\"===e.inputSource.handedness?\"right\":\"left\",A=(null===(l=r.options.jointMeshes)||void 0===l?void 0:l.handMeshes)&&(null===(u=r.options.jointMeshes)||void 0===u?void 0:u.handMeshes[S]),P=(null===(d=r.options.jointMeshes)||void 0===d?void 0:d.rigMapping)&&(null===(f=r.options.jointMeshes)||void 0===f?void 0:f.rigMapping[S]),C=new X_(e,m,A,P,null===(p=r.options.jointMeshes)||void 0===p?void 0:p.disableDefaultHandMesh);r._hands[e.uniqueId]={handObject:C,id:t._idCounter++},r.onHandAddedObservable.notifyObservers(C)}},r.xrNativeFeatureName=\"hand-tracking\",r}return Object(h.d)(t,e),t.prototype.isCompatible=function(){return\"undefined\"!=typeof XRHand},t.prototype.attach=function(){var t=this;return!!e.prototype.attach.call(this)&&(this.options.xrInput.controllers.forEach(this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable,this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable,(function(e){t._detachHand(e.uniqueId)})),!0)},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._hands).forEach((function(e){t._detachHand(e)})),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onHandAddedObservable.clear()},t.prototype.getHandByControllerId=function(e){var t;return(null===(t=this._hands[e])||void 0===t?void 0:t.handObject)||null},t.prototype.getHandByHandedness=function(e){var t=this,i=Object.keys(this._hands).map((function(e){return t._hands[e].handObject.xrController.inputSource.handedness})).indexOf(e);return-1!==i?this._hands[i].handObject:null},t.prototype._onXRFrame=function(e){var t=this;Object.keys(this._hands).forEach((function(i){var n;t._hands[i].handObject.updateFromXRFrame(e,t._xrSessionManager.referenceSpace,null===(n=t.options.jointMeshes)||void 0===n?void 0:n.scaleFactor)}))},t.prototype._detachHand=function(e){this._hands[e]&&(this.onHandRemovedObservable.notifyObservers(this._hands[e].handObject),this._hands[e].handObject.dispose())},t._idCounter=0,t.Name=Ia.HAND_TRACKING,t.Version=1,t}(ja);Da.AddWebXRFeature(Y_.Name,(function(e,t){return function(){return new Y_(e,t)}}),Y_.Version,!1);var K_=function(e){function t(t,i,n){var r=e.call(this,t,Q_[\"left-right\"],i,n)||this;return r._mapping={defaultButton:{valueNodeName:\"VALUE\",unpressedNodeName:\"UNPRESSED\",pressedNodeName:\"PRESSED\"},defaultAxis:{valueNodeName:\"VALUE\",minNodeName:\"MIN\",maxNodeName:\"MAX\"},buttons:{\"xr-standard-trigger\":{rootNodeName:\"SELECT\",componentProperty:\"button\",states:[\"default\",\"touched\",\"pressed\"]},\"xr-standard-squeeze\":{rootNodeName:\"GRASP\",componentProperty:\"state\",states:[\"pressed\"]},\"xr-standard-touchpad\":{rootNodeName:\"TOUCHPAD_PRESS\",labelAnchorNodeName:\"squeeze-label\",touchPointNodeName:\"TOUCH\"},\"xr-standard-thumbstick\":{rootNodeName:\"THUMBSTICK_PRESS\",componentProperty:\"state\",states:[\"pressed\"]}},axes:{\"xr-standard-touchpad\":{\"x-axis\":{rootNodeName:\"TOUCHPAD_TOUCH_X\"},\"y-axis\":{rootNodeName:\"TOUCHPAD_TOUCH_Y\"}},\"xr-standard-thumbstick\":{\"x-axis\":{rootNodeName:\"THUMBSTICK_X\"},\"y-axis\":{rootNodeName:\"THUMBSTICK_Y\"}}}},r.profileId=\"microsoft-mixed-reality\",r}return Object(h.d)(t,e),t.prototype._getFilenameAndPath=function(){return{filename:\"left\"===this.handedness?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,path:t.MODEL_BASE_URL+\"default/\"}},t.prototype._getModelLoadingConstraints=function(){var e=pr.IsPluginForExtensionAvailable(\".glb\");return e||m.a.Warn(\"glTF / glb loaded was not registered, using generic controller instead\"),e},t.prototype._processLoadedModel=function(e){var t=this;this.rootMesh&&(this.getComponentIds().forEach((function(e,i){if(!t.disableAnimation&&e&&t.rootMesh){var n=t._mapping.buttons[e],r=n.rootNodeName;if(!r)return void m.a.Log(\"Skipping unknown button at index: \"+i+\" with mapped name: \"+e);var o=t._getChildByName(t.rootMesh,r);if(!o)return void m.a.Warn(\"Missing button mesh with name: \"+r);if(n.valueMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.valueNodeName),n.pressedMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.pressedNodeName),n.unpressedMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.unpressedNodeName),n.valueMesh&&n.pressedMesh&&n.unpressedMesh){var a=t.getComponent(e);a&&a.onButtonStateChangedObservable.add((function(e){t._lerpTransform(n,e.value)}),void 0,!0)}else m.a.Warn(\"Missing button submesh under mesh with name: \"+r)}})),this.getComponentIds().forEach((function(e,i){var n=t.getComponent(e);n.isAxes()&&[\"x-axis\",\"y-axis\"].forEach((function(i){if(t.rootMesh){var r=t._mapping.axes[e][i],o=t._getChildByName(t.rootMesh,r.rootNodeName);o?(r.valueMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.valueNodeName),r.minMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.minNodeName),r.maxMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.maxNodeName),r.valueMesh&&r.minMesh&&r.maxMesh?n&&n.onAxisValueChangedObservable.add((function(e){var n=\"x-axis\"===i?e.x:e.y;t._lerpTransform(r,n,!0)}),void 0,!0):m.a.Warn(\"Missing axis submesh under mesh with name: \"+r.rootNodeName)):m.a.Warn(\"Missing axis mesh with name: \"+r.rootNodeName)}}))})))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new be.a(this.profileId+\" \"+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;i1){for(r();-1!==n&&e._OperatorPriority[a()]>=e._OperatorPriority[h];)i.push(s());o(h),c++}else l+=u;c++}for(r();-1!==n;)\"(\"===a()?s():i.push(s());return i},e._OperatorPriority={\")\":0,\"(\":1,\"||\":2,\"&&\":3},e._Stack=[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"],e}(),u=function(e){function t(t,i){void 0===i&&(i=!1);var n=e.call(this)||this;return n.define=t,n.not=i,n}return Object(a.d)(t,e),t.prototype.isTrue=function(e){var t=void 0!==e[this.define];return this.not&&(t=!t),t},t}(l),h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(a.d)(t,e),t.prototype.isTrue=function(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)},t}(l),d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(a.d)(t,e),t.prototype.isTrue=function(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)},t}(l),f=function(e){function t(t,i,n){var r=e.call(this)||this;return r.define=t,r.operand=i,r.testValue=n,r}return Object(a.d)(t,e),t.prototype.isTrue=function(e){var t=e[this.define];void 0===t&&(t=this.define);var i=!1,n=parseInt(t),r=parseInt(this.testValue);switch(this.operand){case\">\":i=n>r;break;case\"<\":i=n=\":i=n>=r;break;case\"==\":i=n===r}return i},t}(l),p=i(21),_=/defined\\s*?\\((.+?)\\)/g,m=/defined\\s*?\\[(.+?)\\]/g,g=function(){function e(){}return e.Process=function(e,t,i,n){var r=this;this._ProcessIncludes(e,t,(function(e){var o=r._ProcessShaderConversion(e,t,n);i(o)}))},e._ProcessPrecision=function(e,t){var i=t.shouldUseHighPrecisionShader;return-1===e.indexOf(\"precision highp float\")?e=i?\"precision highp float;\\n\"+e:\"precision mediump float;\\n\"+e:i||(e=e.replace(\"precision highp float\",\"precision mediump float\")),e},e._ExtractOperation=function(e){var t=/defined\\((.+)\\)/.exec(e);if(t&&t.length)return new u(t[1].trim(),\"!\"===e[0]);for(var i=\"\",n=0,r=0,o=[\"==\",\">=\",\"<=\",\"<\",\">\"];r-1));r++);if(-1===n)return new u(e);var a=e.substring(0,n).trim(),s=e.substring(n+i.length).trim();return new f(a,i,s)},e._BuildSubExpression=function(e){e=e.replace(_,\"defined[$1]\");for(var t=[],i=0,n=l.infixToPostfix(e);i=2){var o=t[t.length-1],a=t[t.length-2];t.length-=2;var s=\"&&\"==r?new d:new h;\"string\"==typeof o&&(o=o.replace(m,\"defined($1)\")),\"string\"==typeof a&&(a=a.replace(m,\"defined($1)\")),s.leftOperand=\"string\"==typeof a?this._ExtractOperation(a):a,s.rightOperand=\"string\"==typeof o?this._ExtractOperation(o):o,t.push(s)}}var c=t[t.length-1];return\"string\"==typeof c&&(c=c.replace(m,\"defined($1)\")),\"string\"==typeof c?this._ExtractOperation(c):c},e._BuildExpression=function(e,t){var i=new c,n=e.substring(0,t),r=e.substring(t);return r=r.substring(0,(r.indexOf(\"//\")+1||r.length+1)-1).trim(),i.testExpression=\"#ifdef\"===n?new u(r):\"#ifndef\"===n?new u(r,!0):this._BuildSubExpression(r),i},e._MoveCursorWithinIf=function(e,t,i){for(var n=e.currentLine;this._MoveCursor(e,i);){var o=(n=e.currentLine).substring(0,5).toLowerCase();if(\"#else\"===o){var a=new r;return t.children.push(a),void this._MoveCursor(e,a)}if(\"#elif\"===o){var s=this._BuildExpression(n,5);t.children.push(s),i=s}}},e._MoveCursor=function(e,t){for(;e.canRead;){e.lineIndex++;var i=e.currentLine,n=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(i);if(n&&n.length){switch(n[0]){case\"#ifdef\":var o=new s;t.children.push(o);var a=this._BuildExpression(i,6);o.children.push(a),this._MoveCursorWithinIf(e,o,a);break;case\"#else\":case\"#elif\":return!0;case\"#endif\":return!1;case\"#ifndef\":o=new s;t.children.push(o);a=this._BuildExpression(i,7);o.children.push(a),this._MoveCursorWithinIf(e,o,a);break;case\"#if\":o=new s,a=this._BuildExpression(i,3);t.children.push(o),o.children.push(a),this._MoveCursorWithinIf(e,o,a)}}else{var c=new r;if(c.line=i,t.children.push(c),\"#\"===i[0]&&\"d\"===i[1]){var l=i.replace(\";\",\"\").split(\" \");c.additionalDefineKey=l[1],3===l.length&&(c.additionalDefineValue=l[2])}}}return!1},e._EvaluatePreProcessors=function(e,t,i){var n=new r,a=new o;return a.lineIndex=-1,a.lines=e.split(\"\\n\"),this._MoveCursor(a,n),n.process(t,i)},e._PreparePreProcessors=function(e){for(var t={},i=0,n=e.defines;i1?r[1]:\"\"}return t.GL_ES=\"true\",t.__VERSION__=e.version,t[e.platformName]=\"true\",t},e._ProcessShaderConversion=function(e,t,i){var n=this._ProcessPrecision(e,t);if(!t.processor)return n;if(-1!==n.indexOf(\"#version 3\"))return n.replace(\"#version 300 es\",\"\");var r=t.defines,o=this._PreparePreProcessors(t);return t.processor.preProcessor&&(n=t.processor.preProcessor(n,r,t.isFragment)),n=this._EvaluatePreProcessors(n,o,t),t.processor.postProcessor&&(n=t.processor.postProcessor(n,r,t.isFragment,i)),n},e._ProcessIncludes=function(t,i,n){for(var r=this,o=/#include<(.+)>(\\((.*)\\))*(\\[(.*)\\])*/g,a=o.exec(t),s=new String(t),c=!1;null!=a;){var l=a[1];if(-1!==l.indexOf(\"__decl__\")&&(l=l.replace(/__decl__/,\"\"),i.supportsUniformBuffers&&(l=(l=l.replace(/Vertex/,\"Ubo\")).replace(/Fragment/,\"Ubo\")),l+=\"Declaration\"),!i.includesShadersStore[l]){var u=i.shadersRepository+\"ShadersInclude/\"+l+\".fx\";return void e._FileToolsLoadFile(u,(function(e){i.includesShadersStore[l]=e,r._ProcessIncludes(s,i,n)}))}var h=i.includesShadersStore[l];if(a[2])for(var d=a[3].split(\",\"),f=0;f=0,a=o.exec(t)}c?this._ProcessIncludes(s.toString(),i,n):n(s)},e._FileToolsLoadFile=function(e,t,i,n,r,o){throw p.a.WarnImport(\"FileTools\")},e}()},function(e,t,i){\"use strict\";i(26).a.prototype._readTexturePixels=function(e,t,i,n,r,o){void 0===n&&(n=-1),void 0===r&&(r=0),void 0===o&&(o=null);var a=this._gl;if(!a)throw new Error(\"Engine does not have gl rendering context.\");if(!this._dummyFramebuffer){var s=a.createFramebuffer();if(!s)throw new Error(\"Unable to create dummy framebuffer\");this._dummyFramebuffer=s}a.bindFramebuffer(a.FRAMEBUFFER,this._dummyFramebuffer),n>-1?a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+n,e._webGLTexture,r):a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,e._webGLTexture,r);var c=void 0!==e.type?this._getWebGLTextureType(e.type):a.UNSIGNED_BYTE;switch(c){case a.UNSIGNED_BYTE:o||(o=new Uint8Array(4*t*i)),c=a.UNSIGNED_BYTE;break;default:o||(o=new Float32Array(4*t*i)),c=a.FLOAT}return a.readPixels(0,0,t,i,a.RGBA,c,o),a.bindFramebuffer(a.FRAMEBUFFER,this._currentFramebuffer),o}},function(e,t,i){\"use strict\";var n=\"shadowsFragmentFunctions\",r=\"#ifdef SHADOWS\\n#ifndef SHADOWFLOAT\\n\\nfloat unpack(vec4 color)\\n{\\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\\nreturn dot(color,bit_shift);\\n}\\n#endif\\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\\n{\\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\\nreturn mix(value,1.0,mask);\\n}\\n#define inline\\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\\n{\\nvec3 directionToLight=vPositionW-lightPosition;\\nfloat depth=length(directionToLight);\\ndepth=(depth+depthValues.x)/(depthValues.y);\\ndepth=clamp(depth,0.,1.0);\\ndirectionToLight=normalize(directionToLight);\\ndirectionToLight.y=-directionToLight.y;\\n#ifndef SHADOWFLOAT\\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\\n#else\\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\\n#endif\\nreturn depth>shadow ? darkness : 1.0;\\n}\\n#define inline\\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\\n{\\nvec3 directionToLight=vPositionW-lightPosition;\\nfloat depth=length(directionToLight);\\ndepth=(depth+depthValues.x)/(depthValues.y);\\ndepth=clamp(depth,0.,1.0);\\ndirectionToLight=normalize(directionToLight);\\ndirectionToLight.y=-directionToLight.y;\\nfloat visibility=1.;\\nvec3 poissonDisk[4];\\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\\n\\n#ifndef SHADOWFLOAT\\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\\n}\\n#endif\\n#define inline\\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\\n{\\nreturn 1.0;\\n}\\nelse\\n{\\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\\n#ifndef SHADOWFLOAT\\nfloat shadow=unpack(texture2D(shadowSampler,uv));\\n#else\\nfloat shadow=texture2D(shadowSampler,uv).x;\\n#endif\\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\\n}\\n}\\n#define inline\\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\\n{\\nreturn 1.0;\\n}\\nelse\\n{\\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\\nfloat visibility=1.;\\nvec2 poissonDisk[4];\\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\\npoissonDisk[3]=vec2(0.34495938,0.29387760);\\n\\n#ifndef SHADOWFLOAT\\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\\n{\\nreturn 1.0;\\n}\\nelse\\n{\\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\\n#ifndef SHADOWFLOAT\\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\\n#else\\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\\n#endif\\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\\n}\\n}\\n#define inline\\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\\n{\\nreturn 1.0;\\n}\\nelse\\n{\\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\\n#ifndef SHADOWFLOAT\\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\\n#else\\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\\n#endif\\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\\n}\\n}\\n#ifdef WEBGL2\\n#define GREATEST_LESS_THAN_ONE 0.99999994\\n\\n#define inline\\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\\nfloat shadow=texture(shadowSampler,uvDepthLayer);\\nshadow=mix(darkness,1.,shadow);\\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\\n}\\n\\n\\n\\n#define inline\\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\\nuv+=0.5;\\nvec2 st=fract(uv);\\nvec2 base_uv=floor(uv)-0.5;\\nbase_uv*=shadowMapSizeAndInverse.y;\\n\\n\\n\\n\\nvec2 uvw0=3.-2.*st;\\nvec2 uvw1=1.+2.*st;\\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\\nfloat shadow=0.;\\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\\nshadow=shadow/16.;\\nshadow=mix(darkness,1.,shadow);\\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\\n}\\n\\n\\n\\n#define inline\\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\\nuv+=0.5;\\nvec2 st=fract(uv);\\nvec2 base_uv=floor(uv)-0.5;\\nbase_uv*=shadowMapSizeAndInverse.y;\\n\\n\\nvec2 uvw0=4.-3.*st;\\nvec2 uvw1=vec2(7.);\\nvec2 uvw2=1.+3.*st;\\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\\nfloat shadow=0.;\\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\\nshadow=shadow/144.;\\nshadow=mix(darkness,1.,shadow);\\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\\n}\\n\\n#define inline\\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\\n{\\nif (depthMetric>1.0 || depthMetric<0.0) {\\nreturn 1.0;\\n}\\nelse\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\\nfloat shadow=texture2D(shadowSampler,uvDepth);\\nshadow=mix(darkness,1.,shadow);\\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\\n}\\n}\\n\\n\\n\\n#define inline\\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\\n{\\nif (depthMetric>1.0 || depthMetric<0.0) {\\nreturn 1.0;\\n}\\nelse\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\\nuv+=0.5;\\nvec2 st=fract(uv);\\nvec2 base_uv=floor(uv)-0.5;\\nbase_uv*=shadowMapSizeAndInverse.y;\\n\\n\\n\\n\\nvec2 uvw0=3.-2.*st;\\nvec2 uvw1=1.+2.*st;\\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\\nfloat shadow=0.;\\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\\nshadow=shadow/16.;\\nshadow=mix(darkness,1.,shadow);\\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\\n}\\n}\\n\\n\\n\\n#define inline\\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\\n{\\nif (depthMetric>1.0 || depthMetric<0.0) {\\nreturn 1.0;\\n}\\nelse\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\\nuv+=0.5;\\nvec2 st=fract(uv);\\nvec2 base_uv=floor(uv)-0.5;\\nbase_uv*=shadowMapSizeAndInverse.y;\\n\\n\\nvec2 uvw0=4.-3.*st;\\nvec2 uvw1=vec2(7.);\\nvec2 uvw2=1.+3.*st;\\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\\nfloat shadow=0.;\\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\\nshadow=shadow/144.;\\nshadow=mix(darkness,1.,shadow);\\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\\n}\\n}\\nconst vec3 PoissonSamplers32[64]=vec3[64](\\nvec3(0.06407013,0.05409927,0.),\\nvec3(0.7366577,0.5789394,0.),\\nvec3(-0.6270542,-0.5320278,0.),\\nvec3(-0.4096107,0.8411095,0.),\\nvec3(0.6849564,-0.4990818,0.),\\nvec3(-0.874181,-0.04579735,0.),\\nvec3(0.9989998,0.0009880066,0.),\\nvec3(-0.004920578,-0.9151649,0.),\\nvec3(0.1805763,0.9747483,0.),\\nvec3(-0.2138451,0.2635818,0.),\\nvec3(0.109845,0.3884785,0.),\\nvec3(0.06876755,-0.3581074,0.),\\nvec3(0.374073,-0.7661266,0.),\\nvec3(0.3079132,-0.1216763,0.),\\nvec3(-0.3794335,-0.8271583,0.),\\nvec3(-0.203878,-0.07715034,0.),\\nvec3(0.5912697,0.1469799,0.),\\nvec3(-0.88069,0.3031784,0.),\\nvec3(0.5040108,0.8283722,0.),\\nvec3(-0.5844124,0.5494877,0.),\\nvec3(0.6017799,-0.1726654,0.),\\nvec3(-0.5554981,0.1559997,0.),\\nvec3(-0.3016369,-0.3900928,0.),\\nvec3(-0.5550632,-0.1723762,0.),\\nvec3(0.925029,0.2995041,0.),\\nvec3(-0.2473137,0.5538505,0.),\\nvec3(0.9183037,-0.2862392,0.),\\nvec3(0.2469421,0.6718712,0.),\\nvec3(0.3916397,-0.4328209,0.),\\nvec3(-0.03576927,-0.6220032,0.),\\nvec3(-0.04661255,0.7995201,0.),\\nvec3(0.4402924,0.3640312,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.),\\nvec3(0.,0.,0.)\\n);\\nconst vec3 PoissonSamplers64[64]=vec3[64](\\nvec3(-0.613392,0.617481,0.),\\nvec3(0.170019,-0.040254,0.),\\nvec3(-0.299417,0.791925,0.),\\nvec3(0.645680,0.493210,0.),\\nvec3(-0.651784,0.717887,0.),\\nvec3(0.421003,0.027070,0.),\\nvec3(-0.817194,-0.271096,0.),\\nvec3(-0.705374,-0.668203,0.),\\nvec3(0.977050,-0.108615,0.),\\nvec3(0.063326,0.142369,0.),\\nvec3(0.203528,0.214331,0.),\\nvec3(-0.667531,0.326090,0.),\\nvec3(-0.098422,-0.295755,0.),\\nvec3(-0.885922,0.215369,0.),\\nvec3(0.566637,0.605213,0.),\\nvec3(0.039766,-0.396100,0.),\\nvec3(0.751946,0.453352,0.),\\nvec3(0.078707,-0.715323,0.),\\nvec3(-0.075838,-0.529344,0.),\\nvec3(0.724479,-0.580798,0.),\\nvec3(0.222999,-0.215125,0.),\\nvec3(-0.467574,-0.405438,0.),\\nvec3(-0.248268,-0.814753,0.),\\nvec3(0.354411,-0.887570,0.),\\nvec3(0.175817,0.382366,0.),\\nvec3(0.487472,-0.063082,0.),\\nvec3(-0.084078,0.898312,0.),\\nvec3(0.488876,-0.783441,0.),\\nvec3(0.470016,0.217933,0.),\\nvec3(-0.696890,-0.549791,0.),\\nvec3(-0.149693,0.605762,0.),\\nvec3(0.034211,0.979980,0.),\\nvec3(0.503098,-0.308878,0.),\\nvec3(-0.016205,-0.872921,0.),\\nvec3(0.385784,-0.393902,0.),\\nvec3(-0.146886,-0.859249,0.),\\nvec3(0.643361,0.164098,0.),\\nvec3(0.634388,-0.049471,0.),\\nvec3(-0.688894,0.007843,0.),\\nvec3(0.464034,-0.188818,0.),\\nvec3(-0.440840,0.137486,0.),\\nvec3(0.364483,0.511704,0.),\\nvec3(0.034028,0.325968,0.),\\nvec3(0.099094,-0.308023,0.),\\nvec3(0.693960,-0.366253,0.),\\nvec3(0.678884,-0.204688,0.),\\nvec3(0.001801,0.780328,0.),\\nvec3(0.145177,-0.898984,0.),\\nvec3(0.062655,-0.611866,0.),\\nvec3(0.315226,-0.604297,0.),\\nvec3(-0.780145,0.486251,0.),\\nvec3(-0.371868,0.882138,0.),\\nvec3(0.200476,0.494430,0.),\\nvec3(-0.494552,-0.711051,0.),\\nvec3(0.612476,0.705252,0.),\\nvec3(-0.578845,-0.768792,0.),\\nvec3(-0.772454,-0.090976,0.),\\nvec3(0.504440,0.372295,0.),\\nvec3(0.155736,0.065157,0.),\\nvec3(0.391522,0.849605,0.),\\nvec3(-0.620106,-0.328104,0.),\\nvec3(0.789239,-0.419965,0.),\\nvec3(-0.545396,0.538133,0.),\\nvec3(-0.178564,-0.596057,0.)\\n);\\n\\n\\n\\n\\n\\n#define inline\\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\\nfloat blockerDepth=0.0;\\nfloat sumBlockerDepth=0.0;\\nfloat numBlocker=0.0;\\nfor (int i=0; i1.0 || depthMetric<0.0) {\\nreturn 1.0;\\n}\\nelse\\n{\\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\\nfloat blockerDepth=0.0;\\nfloat sumBlockerDepth=0.0;\\nfloat numBlocker=0.0;\\nfor (int i=0; icurrRayHeight)\\n{\\nfloat delta1=currSampledHeight-currRayHeight;\\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\\nfloat ratio=delta1/(delta1+delta2);\\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\\n\\nbreak;\\n}\\nelse\\n{\\ncurrRayHeight-=stepSize;\\nvLastOffset=vCurrOffset;\\nvCurrOffset+=stepSize*vMaxOffset;\\nlastSampledHeight=currSampledHeight;\\n}\\n}\\nreturn vCurrOffset;\\n}\\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\\n{\\n\\nfloat height=texture2D(bumpSampler,vBumpUV).w;\\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\\nreturn -texCoordOffset;\\n}\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"vec2 uvOffset=vec2(0.0,0.0);\\n#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)\\n#ifdef NORMALXYSCALE\\nfloat normalScale=1.0;\\n#elif defined(BUMP)\\nfloat normalScale=vBumpInfos.y;\\n#else\\nfloat normalScale=1.0;\\n#endif\\n#if defined(TANGENT) && defined(NORMAL)\\nmat3 TBN=vTBN;\\n#elif defined(BUMP)\\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\\n#else\\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vDetailUV,vec2(1.,1.));\\n#endif\\n#elif defined(ANISOTROPIC)\\n#if defined(TANGENT) && defined(NORMAL)\\nmat3 TBN=vTBN;\\n#else\\nmat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,vec2(1.,1.));\\n#endif\\n#endif\\n#ifdef PARALLAX\\nmat3 invTBN=transposeMat3(TBN);\\n#ifdef PARALLAXOCCLUSION\\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\\n#else\\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\\n#endif\\n#endif\\n#ifdef DETAIL\\nvec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);\\nvec2 detailNormalRG=detailColor.wy*2.0-1.0;\\nfloat detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));\\nvec3 detailNormal=vec3(detailNormalRG,detailNormalB);\\n#endif\\n#ifdef BUMP\\n#ifdef OBJECTSPACE_NORMALMAP\\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\\nnormalW=normalize(mat3(normalMatrix)*normalW);\\n#elif !defined(DETAIL)\\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\\n#else\\nvec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;\\n\\n#if DETAIL_NORMALBLENDMETHOD == 0\\ndetailNormal.xy*=vDetailInfos.z;\\nvec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));\\n#elif DETAIL_NORMALBLENDMETHOD == 1\\ndetailNormal.xy*=vDetailInfos.z;\\nbumpNormal+=vec3(0.0,0.0,1.0);\\ndetailNormal*=vec3(-1.0,-1.0,1.0);\\nvec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;\\n#endif\\nnormalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);\\n#endif\\n#elif defined(DETAIL)\\ndetailNormal.xy*=vDetailInfos.z;\\nnormalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);\\n#endif\";i(5).a.IncludesShadersStore.bumpFragment=n},function(e,t,i){\"use strict\";var n=\"lightFragment\",r=\"#ifdef LIGHT{X}\\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\\n\\n#else\\n#ifdef PBR\\n\\n#ifdef SPOTLIGHT{X}\\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\\n#elif defined(POINTLIGHT{X})\\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\\n#elif defined(HEMILIGHT{X})\\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\\n#elif defined(DIRLIGHT{X})\\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\\n#endif\\npreInfo.NdotV=NdotV;\\n\\n#ifdef SPOTLIGHT{X}\\n#ifdef LIGHT_FALLOFF_GLTF{X}\\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\\n#else\\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\\n#endif\\n#elif defined(POINTLIGHT{X})\\n#ifdef LIGHT_FALLOFF_GLTF{X}\\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\\n#else\\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\\n#endif\\n#else\\npreInfo.attenuation=1.0;\\n#endif\\n\\n\\n#ifdef HEMILIGHT{X}\\npreInfo.roughness=roughness;\\n#else\\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\\n#endif\\n\\n#ifdef HEMILIGHT{X}\\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\\n#elif defined(SS_TRANSLUCENCY)\\ninfo.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);\\n#else\\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\\n#endif\\n\\n#ifdef SPECULARTERM\\n#ifdef ANISOTROPIC\\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\\n#else\\ninfo.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\\n#endif\\n#endif\\n\\n#ifdef SHEEN\\n#ifdef SHEEN_LINKWITHALBEDO\\n\\npreInfo.roughness=sheenOut.sheenIntensity;\\n#else\\n#ifdef HEMILIGHT{X}\\npreInfo.roughness=sheenOut.sheenRoughness;\\n#else\\npreInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\\n#endif\\n#endif\\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\\n#endif\\n\\n#ifdef CLEARCOAT\\n\\n#ifdef HEMILIGHT{X}\\npreInfo.roughness=clearcoatOut.clearCoatRoughness;\\n#else\\npreInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\\n#endif\\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);\\n#ifdef CLEARCOAT_TINT\\n\\nabsorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);\\ninfo.diffuse*=absorption;\\n#ifdef SPECULARTERM\\ninfo.specular*=absorption;\\n#endif\\n#endif\\n\\ninfo.diffuse*=info.clearCoat.w;\\n#ifdef SPECULARTERM\\ninfo.specular*=info.clearCoat.w;\\n#endif\\n#ifdef SHEEN\\ninfo.sheen*=info.clearCoat.w;\\n#endif\\n#endif\\n#else\\n#ifdef SPOTLIGHT{X}\\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\\n#elif defined(HEMILIGHT{X})\\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);\\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\\n#endif\\n#endif\\n#ifdef PROJECTEDLIGHTTEXTURE{X}\\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\\n#endif\\n#endif\\n#ifdef SHADOW{X}\\n#ifdef SHADOWCSM{X}\\nfor (int i=0; i=0.) {\\nindex{X}=i;\\nbreak;\\n}\\n}\\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\\nif (index{X}>=0)\\n#endif\\n{\\n#if defined(SHADOWPCF{X})\\n#if defined(SHADOWLOWQUALITY{X})\\nshadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#elif defined(SHADOWMEDIUMQUALITY{X})\\nshadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#else\\nshadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#endif\\n#elif defined(SHADOWPCSS{X})\\n#if defined(SHADOWLOWQUALITY{X})\\nshadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\\n#elif defined(SHADOWMEDIUMQUALITY{X})\\nshadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\\n#else\\nshadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\\n#endif\\n#else\\nshadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#endif\\n#ifdef SHADOWCSMDEBUG{X}\\nshadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];\\n#endif\\n#ifndef SHADOWCSMNOBLEND{X}\\nfloat frustumLength=frustumLengths{X}[index{X}];\\nfloat diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};\\nif (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)\\n{\\nindex{X}+=1;\\nfloat nextShadow=0.;\\n#if defined(SHADOWPCF{X})\\n#if defined(SHADOWLOWQUALITY{X})\\nnextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#elif defined(SHADOWMEDIUMQUALITY{X})\\nnextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#else\\nnextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#endif\\n#elif defined(SHADOWPCSS{X})\\n#if defined(SHADOWLOWQUALITY{X})\\nnextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\\n#elif defined(SHADOWMEDIUMQUALITY{X})\\nnextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\\n#else\\nnextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\\n#endif\\n#else\\nnextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#endif\\nshadow=mix(nextShadow,shadow,diffRatio);\\n#ifdef SHADOWCSMDEBUG{X}\\nshadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);\\n#endif\\n}\\n#endif\\n}\\n#elif defined(SHADOWCLOSEESM{X})\\n#if defined(SHADOWCUBE{X})\\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\\n#else\\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\\n#endif\\n#elif defined(SHADOWESM{X})\\n#if defined(SHADOWCUBE{X})\\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\\n#else\\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\\n#endif\\n#elif defined(SHADOWPOISSON{X})\\n#if defined(SHADOWCUBE{X})\\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\\n#else\\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#endif\\n#elif defined(SHADOWPCF{X})\\n#if defined(SHADOWLOWQUALITY{X})\\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#elif defined(SHADOWMEDIUMQUALITY{X})\\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#else\\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#endif\\n#elif defined(SHADOWPCSS{X})\\n#if defined(SHADOWLOWQUALITY{X})\\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#elif defined(SHADOWMEDIUMQUALITY{X})\\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#else\\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#endif\\n#else\\n#if defined(SHADOWCUBE{X})\\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\\n#else\\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\\n#endif\\n#endif\\n#ifdef SHADOWONLY\\n#ifndef SHADOWINUSE\\n#define SHADOWINUSE\\n#endif\\nglobalShadow+=shadow;\\nshadowLightCount+=1.0;\\n#endif\\n#else\\nshadow=1.;\\n#endif\\n#ifndef SHADOWONLY\\n#ifdef CUSTOMUSERLIGHTING\\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\\n#ifdef SPECULARTERM\\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\\n#endif\\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\\ndiffuseBase+=lightmapColor.rgb*shadow;\\n#ifdef SPECULARTERM\\n#ifndef LIGHTMAPNOSPECULAR{X}\\nspecularBase+=info.specular*shadow*lightmapColor.rgb;\\n#endif\\n#endif\\n#ifdef CLEARCOAT\\n#ifndef LIGHTMAPNOSPECULAR{X}\\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;\\n#endif\\n#endif\\n#ifdef SHEEN\\n#ifndef LIGHTMAPNOSPECULAR{X}\\nsheenBase+=info.sheen.rgb*shadow;\\n#endif\\n#endif\\n#else\\n#ifdef SHADOWCSMDEBUG{X}\\ndiffuseBase+=info.diffuse*shadowDebug{X};\\n#else\\ndiffuseBase+=info.diffuse*shadow;\\n#endif\\n#ifdef SPECULARTERM\\nspecularBase+=info.specular*shadow;\\n#endif\\n#ifdef CLEARCOAT\\nclearCoatBase+=info.clearCoat.rgb*shadow;\\n#endif\\n#ifdef SHEEN\\nsheenBase+=info.sheen.rgb*shadow;\\n#endif\\n#endif\\n#endif\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"#ifdef FOG\\nfloat fog=CalcFogFactor();\\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\\n#endif\";i(5).a.IncludesShadersStore.fogFragment=n},function(e,t,i){\"use strict\";var n=\"fogVertexDeclaration\",r=\"#ifdef FOG\\nvarying vec3 vFogDistance;\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"shadowsVertex\",r=\"#ifdef SHADOWS\\n#if defined(SHADOWCSM{X})\\nvPositionFromCamera{X}=view*worldPos;\\nfor (int i=0; i1)for(var c=0;c=e||-1!==i.indexOf(\"file:\")?-1:Math.pow(2,r)*t}},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,this.reset()}return Object.defineProperty(e.prototype,\"isDirty\",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"zOffset\",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"cullFace\",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"cull\",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"depthFunc\",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"depthMask\",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"depthTest\",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"frontFace\",{get:function(){return this._frontFace},set:function(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,0)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r}));var n=i(2),r=function(){function e(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(e.prototype,\"isDirty\",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stencilFunc\",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stencilFuncRef\",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stencilFuncMask\",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stencilOpStencilFail\",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stencilOpDepthFail\",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stencilOpStencilDepthPass\",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stencilMask\",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stencilTest\",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.KEEP,this._stencilOpDepthFail=e.KEEP,this._stencilOpStencilDepthPass=e.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},e.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},e.ALWAYS=n.a.ALWAYS,e.KEEP=n.a.KEEP,e.REPLACE=n.a.REPLACE,e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this.reset()}return Object.defineProperty(e.prototype,\"isDirty\",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"alphaBlend\",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.setAlphaBlendConstants=function(e,t,i,n){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===n||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=n,this._isBlendConstantsDirty=!0)},e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,n){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===n||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=n,this._isBlendFunctionParametersDirty=!0)},e.prototype.setAlphaEquationParameters=function(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return n}));var n=function(){function e(){this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null}return Object.defineProperty(e.prototype,\"isAsync\",{get:function(){return this.isParallelCompiled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isReady\",{get:function(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))},enumerable:!1,configurable:!0}),e.prototype._handlesSpectorRebuildCallback=function(e){e&&this.program&&e(this.program)},e.prototype._getVertexShaderCode=function(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null},e.prototype._getFragmentShaderCode=function(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null},e}()},function(e,t,i){\"use strict\";var n;i.d(t,\"a\",(function(){return a})),function(e){e[e.Pending=0]=\"Pending\",e[e.Fulfilled=1]=\"Fulfilled\",e[e.Rejected=2]=\"Rejected\"}(n||(n={}));var r=function(){this.count=0,this.target=0,this.results=[]},o=function(){function e(e){var t=this;if(this._state=n.Pending,this._children=new Array,this._rejectWasConsumed=!1,e)try{e((function(e){t._resolve(e)}),(function(e){t._reject(e)}))}catch(e){this._reject(e)}}return Object.defineProperty(e.prototype,\"_result\",{get:function(){return this._resultValue},set:function(e){this._resultValue=e,this._parent&&void 0===this._parent._result&&(this._parent._result=e)},enumerable:!1,configurable:!0}),e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.then=function(t,i){var r=this,o=new e;return o._onFulfilled=t,o._onRejected=i,this._children.push(o),o._parent=this,this._state!==n.Pending&&setTimeout((function(){if(r._state===n.Fulfilled||r._rejectWasConsumed){var e=o._resolve(r._result);if(null!=e)if(void 0!==e._state){var t=e;o._children.push(t),t._parent=o,o=t}else o._result=e}else o._reject(r._reason)})),o},e.prototype._moveChildren=function(e){var t,i=this;if((t=this._children).push.apply(t,e.splice(0,e.length)),this._children.forEach((function(e){e._parent=i})),this._state===n.Fulfilled)for(var r=0,o=this._children;r=this._sampleCount||e>=this._samples.length)return 0;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return r}));var n=i(0),r=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new n.e(0,0,0),this._diffPositionForCollisions=new n.e(0,0,0),this._collisionResponse=!0}},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return a}));var n=i(33),r=i(0),o=i(2),a=function(){function e(e,t,i,r,o){void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=null),this.index=e,this._opaqueSubMeshes=new n.a(256),this._transparentSubMeshes=new n.a(256),this._alphaTestSubMeshes=new n.a(256),this._depthOnlySubMeshes=new n.a(256),this._particleSystems=new n.a(256),this._spriteManagers=new n.a(256),this._edgesRenderers=new n.b(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=o}return Object.defineProperty(e.prototype,\"opaqueSortCompareFn\",{set:function(t){this._opaqueSortCompareFn=t,this._renderOpaque=t?this.renderOpaqueSorted:e.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"alphaTestSortCompareFn\",{set:function(t){this._alphaTestSortCompareFn=t,this._renderAlphaTest=t?this.renderAlphaTestSorted:e.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"transparentSortCompareFn\",{set:function(t){this._transparentSortCompareFn=t||e.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!1,configurable:!0}),e.prototype.render=function(e,t,i,n){if(e)e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var r=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(r.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),r.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);var a=r.getStencilBuffer();if(r.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(n),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(r.setStencilBuffer(a),this._renderTransparent(this._transparentSubMeshes),r.setAlphaMode(o.a.ALPHA_DISABLE)),r.setStencilBuffer(!1),this._edgesRenderers.length){for(var s=0;si._alphaIndex?1:t._alphaIndext._distanceToCamera?-1:0},e.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},e.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},e.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},e.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh()),void 0===i&&(i=e.getMaterial()),null!=i&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTesting()?(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer))},e.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},e.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},e.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var i=0;i=0;){var u=r[c];u<0?u=0:u>1&&(u=1),l[c]=255*u}r=l}var h=document.createElement(\"canvas\");h.width=a,h.height=s;var d=h.getContext(\"2d\");if(!d)return null;var f=d.createImageData(a,s);if(f.data.set(r),d.putImageData(f,0,0),n.invertY){var p=document.createElement(\"canvas\");p.width=a,p.height=s;var _=p.getContext(\"2d\");return _?(_.translate(0,s),_.scale(1,-1),_.drawImage(h,0,0),p.toDataURL(\"image/png\")):null}return h.toDataURL(\"image/png\")},e}()},function(e,t,i){\"use strict\";i.d(t,\"a\",(function(){return f}));var n=i(1),r=i(0),o=i(8),a=i(31),s=i(7),c=i(41),l=i(46),u=i(4),h=i(43),d=i(12);s.a._instancedMeshFactory=function(e,t){var i=new f(e,t);if(t.instancedBuffers)for(var n in i.instancedBuffers={},t.instancedBuffers)i.instancedBuffers[n]=t.instancedBuffers[n];return i};var f=function(e){function t(t,i){var n=e.call(this,t,i.getScene())||this;n._indexInSourceMeshInstanceArray=-1,i.addInstance(n),n._sourceMesh=i,n._unIndexed=i._unIndexed,n.position.copyFrom(i.position),n.rotation.copyFrom(i.rotation),n.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(n.rotationQuaternion=i.rotationQuaternion.clone()),n.animations=d.b.Slice(i.animations);for(var r=0,o=i.getAnimationRanges();r0!=this._getWorldMatrixDeterminant()>0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1},t.prototype._postActivate=function(){this._sourceMesh.edgesShareWithInstances&&this._sourceMesh._edgesRenderer&&this._sourceMesh._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup?(this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())):this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)},t.prototype.getWorldMatrix=function(){if(this._currentLOD&&this._currentLOD.billboardMode!==l.a.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){var t=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,r.c.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),r.c.Matrix[0].copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(r.c.Vector3[7]),this._currentLOD._masterMesh=t,r.c.Matrix[0]}return e.prototype.getWorldMatrix.call(this)},Object.defineProperty(t.prototype,\"isAnInstance\",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.getLOD=function(e){if(!e)return this;var t=this.getBoundingInfo();return this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere),this._currentLOD===this.sourceMesh?this.sourceMesh:this._currentLOD},t.prototype._preActivateForIntermediateRendering=function(e){return this.sourceMesh._preActivateForIntermediateRendering(e)},t.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e=lightDirection.w)\\n{\\ncosAngle=max(0.,pow(cosAngle,lightData.w));\\nattenuation*=cosAngle;\\n\\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\\n#ifdef NDOTL\\nresult.ndl=ndl;\\n#endif\\nresult.diffuse=ndl*diffuseColor*attenuation;\\n#ifdef SPECULARTERM\\n\\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\\nfloat specComp=max(0.,dot(vNormal,angleW));\\nspecComp=pow(specComp,max(1.,glossiness));\\nresult.specular=specComp*specularColor*attenuation;\\n#endif\\nreturn result;\\n}\\nresult.diffuse=vec3(0.);\\n#ifdef SPECULARTERM\\nresult.specular=vec3(0.);\\n#endif\\n#ifdef NDOTL\\nresult.ndl=0.;\\n#endif\\nreturn result;\\n}\\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\\nlightingInfo result;\\n\\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\\n#ifdef NDOTL\\nresult.ndl=ndl;\\n#endif\\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\\n#ifdef SPECULARTERM\\n\\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\\nfloat specComp=max(0.,dot(vNormal,angleW));\\nspecComp=pow(specComp,max(1.,glossiness));\\nresult.specular=specComp*specularColor;\\n#endif\\nreturn result;\\n}\\n#define inline\\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\\nstrq/=strq.w;\\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\\nreturn textureColor;\\n}\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"logDepthFragment\",r=\"#ifdef LOGARITHMICDEPTH\\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\\n#if defined(TANGENT) && defined(NORMAL)\\nvec3 tbnNormal=normalize(normalUpdated);\\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\\n#endif\\n#endif\";i(5).a.IncludesShadersStore.bumpVertex=n},function(e,t,i){\"use strict\";var n=\"#ifdef FOG\\nvFogDistance=(view*worldPos).xyz;\\n#endif\";i(5).a.IncludesShadersStore.fogVertex=n},function(e,t,i){\"use strict\";var n=\"logDepthVertex\",r=\"#ifdef LOGARITHMICDEPTH\\nvFragmentDepth=1.0+gl_Position.w;\\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t){var i;i=function(){return this}();try{i=i||new Function(\"return this\")()}catch(e){\"object\"==typeof window&&(i=window)}e.exports=i},function(e,t,i){\"use strict\";var n=\"prePassDeclaration\",r=\"#ifdef PREPASS\\n#extension GL_EXT_draw_buffers : require\\n#ifdef WEBGL2\\nlayout(location=0) out highp vec4 glFragData[{X}];\\nhighp vec4 gl_FragColor;\\n#endif\\n#ifdef PREPASS_DEPTHNORMAL\\nvarying highp vec3 vViewPos;\\n#endif\\n#ifdef PREPASS_VELOCITY\\nvarying highp vec4 vCurrentPosition;\\nvarying highp vec4 vPreviousPosition;\\n#endif\\n#endif\\n\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"fresnelFunction\",r=\"#ifdef FRESNEL\\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\\n{\\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\\nreturn clamp(fresnelTerm,0.,1.);\\n}\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"#ifdef DEPTHPREPASS\\ngl_FragColor=vec4(0.,0.,0.,1.0);\\nreturn;\\n#endif\";i(5).a.IncludesShadersStore.depthPrePass=n},function(e,t,i){\"use strict\";var n=\"prePassVertexDeclaration\",r=\"#ifdef PREPASS\\n#ifdef PREPASS_DEPTHNORMAL\\nvarying vec3 vViewPos;\\n#endif\\n#ifdef PREPASS_VELOCITY\\nuniform mat4 previousWorld;\\nuniform mat4 previousViewProjection;\\nvarying vec4 vCurrentPosition;\\nvarying vec4 vPreviousPosition;\\n#endif\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"bumpVertexDeclaration\",r=\"#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\\n#if defined(TANGENT) && defined(NORMAL)\\nvarying mat3 vTBN;\\n#endif\\n#endif\\n\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=\"prePassVertex\",r=\"#ifdef PREPASS_DEPTHNORMAL\\nvViewPos=(view*worldPos).rgb;\\n#endif\\n#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)\\nvCurrentPosition=viewProjection*worldPos;\\n#if NUM_BONE_INFLUENCERS>0\\nmat4 previousInfluence;\\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\\n#if NUM_BONE_INFLUENCERS>1\\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\\n#endif\\n#if NUM_BONE_INFLUENCERS>2\\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\\n#endif\\n#if NUM_BONE_INFLUENCERS>3\\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\\n#endif\\n#if NUM_BONE_INFLUENCERS>4\\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\\n#endif\\n#if NUM_BONE_INFLUENCERS>5\\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\\n#endif\\n#if NUM_BONE_INFLUENCERS>6\\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\\n#endif\\n#if NUM_BONE_INFLUENCERS>7\\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\\n#endif\\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);\\n#else\\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\\n#endif\\n#endif\";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){\"use strict\";var n=i(5),r=(i(115),i(110),\"colorPixelShader\"),o=\"#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#else\\nuniform vec4 color;\\n#endif\\n#include\\nvoid main(void) {\\n#include\\n#ifdef VERTEXCOLOR\\ngl_FragColor=vColor;\\n#else\\ngl_FragColor=color;\\n#endif\\n}\";n.a.ShadersStore[r]=o},function(e,t,i){\"use strict\";var n=i(5),r=(i(78),i(117),i(79),i(80),i(81),i(111),\"colorVertexShader\"),o=\"\\nattribute vec3 position;\\n#ifdef VERTEXCOLOR\\nattribute vec4 color;\\n#endif\\n#include\\n#include\\n\\n#include\\nuniform mat4 viewProjection;\\n#ifdef MULTIVIEW\\nuniform mat4 viewProjectionR;\\n#endif\\n\\n#ifdef VERTEXCOLOR\\nvarying vec4 vColor;\\n#endif\\nvoid main(void) {\\n#include\\n#include\\nvec4 worldPos=finalWorld*vec4(position,1.0);\\n#ifdef MULTIVIEW\\nif (gl_ViewID_OVR == 0u) {\\ngl_Position=viewProjection*worldPos;\\n} else {\\ngl_Position=viewProjectionR*worldPos;\\n}\\n#else\\ngl_Position=viewProjection*worldPos;\\n#endif\\n#include\\n#ifdef VERTEXCOLOR\\n\\nvColor=color;\\n#endif\\n}\";n.a.ShadersStore[r]=o},function(e,t,i){\"use strict\";(function(e){i.d(t,\"b\",(function(){return h})),i.d(t,\"a\",(function(){return d}));var n=i(1),r=i(8),o=i(13),a=i(102),s=i(27),c=i(2),l=i(89),u=i(74),h=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4},d=function(t){function i(i){void 0===i&&(i=new h);var n=t.call(this,null)||this;o.a.Instances.push(n),void 0===i.deterministicLockstep&&(i.deterministicLockstep=!1),void 0===i.lockstepMaxSteps&&(i.lockstepMaxSteps=4),n._options=i,u.a.SetMatrixPrecision(!!i.useHighPrecisionMatrix),n._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:512,maxCubemapTextureSize:512,maxRenderTextureSize:512,maxVertexAttribs:16,maxVaryingVectors:16,maxFragmentUniformVectors:16,maxVertexUniformVectors:16,standardDerivatives:!1,astc:null,pvrtc:null,etc1:null,etc2:null,bptc:null,maxAnisotropy:0,uintIndices:!1,fragmentDepthSupported:!1,highPrecisionShaderSupported:!0,colorBufferFloat:!1,textureFloat:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloat:!1,textureHalfFloatLinearFiltering:!1,textureHalfFloatRender:!1,textureLOD:!1,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!1,instancedArrays:!1,canUseTimestampForTimerQuery:!1,maxMSAASamples:1,blendMinMax:!1},r.a.Log(\"Babylon.js v\"+o.a.Version+\" - Null engine\");var a=\"undefined\"!=typeof self?self:void 0!==e?e:window;return\"undefined\"==typeof URL&&(a.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),\"undefined\"==typeof Blob&&(a.Blob=function(){}),n}return Object(n.d)(i,t),i.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},i.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},i.prototype.getHardwareScalingLevel=function(){return 1},i.prototype.createVertexBuffer=function(e){var t=new l.a;return t.references=1,t},i.prototype.createIndexBuffer=function(e){var t=new l.a;return t.references=1,t},i.prototype.clear=function(e,t,i,n){void 0===n&&(n=!1)},i.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},i.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},i.prototype.setViewport=function(e,t,i){this._cachedViewport=e},i.prototype.createShaderProgram=function(e,t,i,n,r){return{__SPECTOR_rebuildProgram:null}},i.prototype.getUniforms=function(e,t){return[]},i.prototype.getAttributes=function(e,t){return[]},i.prototype.bindSamplers=function(e){this._currentEffect=null},i.prototype.enableEffect=function(e){this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e)},i.prototype.setState=function(e,t,i,n){void 0===t&&(t=0),void 0===n&&(n=!1)},i.prototype.setIntArray=function(e,t){return!0},i.prototype.setIntArray2=function(e,t){return!0},i.prototype.setIntArray3=function(e,t){return!0},i.prototype.setIntArray4=function(e,t){return!0},i.prototype.setFloatArray=function(e,t){return!0},i.prototype.setFloatArray2=function(e,t){return!0},i.prototype.setFloatArray3=function(e,t){return!0},i.prototype.setFloatArray4=function(e,t){return!0},i.prototype.setArray=function(e,t){return!0},i.prototype.setArray2=function(e,t){return!0},i.prototype.setArray3=function(e,t){return!0},i.prototype.setArray4=function(e,t){return!0},i.prototype.setMatrices=function(e,t){return!0},i.prototype.setMatrix3x3=function(e,t){return!0},i.prototype.setMatrix2x2=function(e,t){return!0},i.prototype.setFloat=function(e,t){return!0},i.prototype.setFloat2=function(e,t,i){return!0},i.prototype.setFloat3=function(e,t,i,n){return!0},i.prototype.setBool=function(e,t){return!0},i.prototype.setFloat4=function(e,t,i,n,r){return!0},i.prototype.setAlphaMode=function(e,t){void 0===t&&(t=!1),this._alphaMode!==e&&(this.alphaState.alphaBlend=e!==c.a.ALPHA_DISABLE,t||this.setDepthWrite(e===c.a.ALPHA_DISABLE),this._alphaMode=e)},i.prototype.bindBuffers=function(e,t,i){},i.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this.stencilState.reset(),this.depthCullingState.reset(),this.alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},i.prototype.draw=function(e,t,i,n){},i.prototype.drawElementsType=function(e,t,i,n){},i.prototype.drawArraysType=function(e,t,i,n){},i.prototype._createTexture=function(){return{}},i.prototype._releaseTexture=function(e){},i.prototype.createTexture=function(e,t,i,n,r,o,a,l,u,h,d,f){void 0===r&&(r=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=null),void 0===d&&(d=null);var p=new s.a(this,s.b.Url),_=String(e);return p.url=_,p.generateMipMaps=!t,p.samplingMode=r,p.invertY=i,p.baseWidth=this._options.textureSize,p.baseHeight=this._options.textureSize,p.width=this._options.textureSize,p.height=this._options.textureSize,h&&(p.format=h),p.isReady=!0,o&&o(),this._internalTexturesCache.push(p),p},i.prototype.createRenderTargetTexture=function(e,t){var i=new a.a;void 0!==t&&\"object\"==typeof t?(i.generateMipMaps=t.generateMipMaps,i.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&t.generateStencilBuffer,i.type=void 0===t.type?c.a.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?c.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=c.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var n=new s.a(this,s.b.RenderTarget),r=e.width||e,o=e.height||e;return n._depthStencilBuffer={},n._framebuffer={},n.baseWidth=r,n.baseHeight=o,n.width=r,n.height=o,n.isReady=!0,n.samples=1,n.generateMipMaps=!!i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(n),n},i.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},i.prototype.bindFramebuffer=function(e,t,i,n,r){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer,this._cachedViewport&&!r&&this.setViewport(this._cachedViewport,i,n)},i.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null,i&&(e._MSAAFramebuffer&&(this._currentFramebuffer=e._framebuffer),i()),this._currentFramebuffer=null},i.prototype.createDynamicVertexBuffer=function(e){var t=new l.a;return t.references=1,t.capacity=1,t},i.prototype.updateDynamicTexture=function(e,t,i,n,r){void 0===n&&(n=!1)},i.prototype.areAllEffectsReady=function(){return!0},i.prototype.getError=function(){return 0},i.prototype._getUnpackAlignement=function(){return 1},i.prototype._unpackFlipY=function(e){},i.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0)},i.prototype.updateDynamicVertexBuffer=function(e,t,i,n){},i.prototype._bindTextureDirectly=function(e,t){return this._boundTexturesCache[this._activeChannel]!==t&&(this._boundTexturesCache[this._activeChannel]=t,!0)},i.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},i.prototype._deleteBuffer=function(e){},i.prototype.releaseEffects=function(){},i.prototype.displayLoadingUI=function(){},i.prototype.hideLoadingUI=function(){},i.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){void 0===o&&(o=0),void 0===a&&(a=0)},i.prototype._uploadDataToTextureDirectly=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i.prototype._uploadImageToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i}(o.a)}).call(this,i(159))},function(e,t,i){\"use strict\";i.r(t),function(e){i.d(t,\"Debug\",(function(){return l}));var n=i(127),r=i(99);i.d(t,\"AbstractScene\",(function(){return n.AbstractScene})),i.d(t,\"AbstractActionManager\",(function(){return n.AbstractActionManager})),i.d(t,\"Action\",(function(){return n.Action})),i.d(t,\"ActionEvent\",(function(){return n.ActionEvent})),i.d(t,\"ActionManager\",(function(){return n.ActionManager})),i.d(t,\"Condition\",(function(){return n.Condition})),i.d(t,\"ValueCondition\",(function(){return n.ValueCondition})),i.d(t,\"PredicateCondition\",(function(){return n.PredicateCondition})),i.d(t,\"StateCondition\",(function(){return n.StateCondition})),i.d(t,\"SwitchBooleanAction\",(function(){return n.SwitchBooleanAction})),i.d(t,\"SetStateAction\",(function(){return n.SetStateAction})),i.d(t,\"SetValueAction\",(function(){return n.SetValueAction})),i.d(t,\"IncrementValueAction\",(function(){return n.IncrementValueAction})),i.d(t,\"PlayAnimationAction\",(function(){return n.PlayAnimationAction})),i.d(t,\"StopAnimationAction\",(function(){return n.StopAnimationAction})),i.d(t,\"DoNothingAction\",(function(){return n.DoNothingAction})),i.d(t,\"CombineAction\",(function(){return n.CombineAction})),i.d(t,\"ExecuteCodeAction\",(function(){return n.ExecuteCodeAction})),i.d(t,\"SetParentAction\",(function(){return n.SetParentAction})),i.d(t,\"PlaySoundAction\",(function(){return n.PlaySoundAction})),i.d(t,\"StopSoundAction\",(function(){return n.StopSoundAction})),i.d(t,\"InterpolateValueAction\",(function(){return n.InterpolateValueAction})),i.d(t,\"Animatable\",(function(){return n.Animatable})),i.d(t,\"_IAnimationState\",(function(){return n._IAnimationState})),i.d(t,\"Animation\",(function(){return n.Animation})),i.d(t,\"TargetedAnimation\",(function(){return n.TargetedAnimation})),i.d(t,\"AnimationGroup\",(function(){return n.AnimationGroup})),i.d(t,\"AnimationPropertiesOverride\",(function(){return n.AnimationPropertiesOverride})),i.d(t,\"EasingFunction\",(function(){return n.EasingFunction})),i.d(t,\"CircleEase\",(function(){return n.CircleEase})),i.d(t,\"BackEase\",(function(){return n.BackEase})),i.d(t,\"BounceEase\",(function(){return n.BounceEase})),i.d(t,\"CubicEase\",(function(){return n.CubicEase})),i.d(t,\"ElasticEase\",(function(){return n.ElasticEase})),i.d(t,\"ExponentialEase\",(function(){return n.ExponentialEase})),i.d(t,\"PowerEase\",(function(){return n.PowerEase})),i.d(t,\"QuadraticEase\",(function(){return n.QuadraticEase})),i.d(t,\"QuarticEase\",(function(){return n.QuarticEase})),i.d(t,\"QuinticEase\",(function(){return n.QuinticEase})),i.d(t,\"SineEase\",(function(){return n.SineEase})),i.d(t,\"BezierCurveEase\",(function(){return n.BezierCurveEase})),i.d(t,\"RuntimeAnimation\",(function(){return n.RuntimeAnimation})),i.d(t,\"AnimationEvent\",(function(){return n.AnimationEvent})),i.d(t,\"AnimationKeyInterpolation\",(function(){return n.AnimationKeyInterpolation})),i.d(t,\"AnimationRange\",(function(){return n.AnimationRange})),i.d(t,\"KeepAssets\",(function(){return n.KeepAssets})),i.d(t,\"InstantiatedEntries\",(function(){return n.InstantiatedEntries})),i.d(t,\"AssetContainer\",(function(){return n.AssetContainer})),i.d(t,\"Analyser\",(function(){return n.Analyser})),i.d(t,\"AudioEngine\",(function(){return n.AudioEngine})),i.d(t,\"AudioSceneComponent\",(function(){return n.AudioSceneComponent})),i.d(t,\"Sound\",(function(){return n.Sound})),i.d(t,\"SoundTrack\",(function(){return n.SoundTrack})),i.d(t,\"WeightedSound\",(function(){return n.WeightedSound})),i.d(t,\"AutoRotationBehavior\",(function(){return n.AutoRotationBehavior})),i.d(t,\"BouncingBehavior\",(function(){return n.BouncingBehavior})),i.d(t,\"FramingBehavior\",(function(){return n.FramingBehavior})),i.d(t,\"AttachToBoxBehavior\",(function(){return n.AttachToBoxBehavior})),i.d(t,\"FadeInOutBehavior\",(function(){return n.FadeInOutBehavior})),i.d(t,\"MultiPointerScaleBehavior\",(function(){return n.MultiPointerScaleBehavior})),i.d(t,\"PointerDragBehavior\",(function(){return n.PointerDragBehavior})),i.d(t,\"SixDofDragBehavior\",(function(){return n.SixDofDragBehavior})),i.d(t,\"Bone\",(function(){return n.Bone})),i.d(t,\"BoneIKController\",(function(){return n.BoneIKController})),i.d(t,\"BoneLookController\",(function(){return n.BoneLookController})),i.d(t,\"Skeleton\",(function(){return n.Skeleton})),i.d(t,\"ArcRotateCameraGamepadInput\",(function(){return n.ArcRotateCameraGamepadInput})),i.d(t,\"ArcRotateCameraKeyboardMoveInput\",(function(){return n.ArcRotateCameraKeyboardMoveInput})),i.d(t,\"ArcRotateCameraMouseWheelInput\",(function(){return n.ArcRotateCameraMouseWheelInput})),i.d(t,\"ArcRotateCameraPointersInput\",(function(){return n.ArcRotateCameraPointersInput})),i.d(t,\"ArcRotateCameraVRDeviceOrientationInput\",(function(){return n.ArcRotateCameraVRDeviceOrientationInput})),i.d(t,\"FlyCameraKeyboardInput\",(function(){return n.FlyCameraKeyboardInput})),i.d(t,\"FlyCameraMouseInput\",(function(){return n.FlyCameraMouseInput})),i.d(t,\"FollowCameraKeyboardMoveInput\",(function(){return n.FollowCameraKeyboardMoveInput})),i.d(t,\"FollowCameraMouseWheelInput\",(function(){return n.FollowCameraMouseWheelInput})),i.d(t,\"FollowCameraPointersInput\",(function(){return n.FollowCameraPointersInput})),i.d(t,\"FreeCameraDeviceOrientationInput\",(function(){return n.FreeCameraDeviceOrientationInput})),i.d(t,\"FreeCameraGamepadInput\",(function(){return n.FreeCameraGamepadInput})),i.d(t,\"FreeCameraKeyboardMoveInput\",(function(){return n.FreeCameraKeyboardMoveInput})),i.d(t,\"FreeCameraMouseInput\",(function(){return n.FreeCameraMouseInput})),i.d(t,\"FreeCameraMouseWheelInput\",(function(){return n.FreeCameraMouseWheelInput})),i.d(t,\"FreeCameraTouchInput\",(function(){return n.FreeCameraTouchInput})),i.d(t,\"FreeCameraVirtualJoystickInput\",(function(){return n.FreeCameraVirtualJoystickInput})),i.d(t,\"CameraInputTypes\",(function(){return n.CameraInputTypes})),i.d(t,\"CameraInputsManager\",(function(){return n.CameraInputsManager})),i.d(t,\"Camera\",(function(){return n.Camera})),i.d(t,\"TargetCamera\",(function(){return n.TargetCamera})),i.d(t,\"FreeCamera\",(function(){return n.FreeCamera})),i.d(t,\"FreeCameraInputsManager\",(function(){return n.FreeCameraInputsManager})),i.d(t,\"TouchCamera\",(function(){return n.TouchCamera})),i.d(t,\"ArcRotateCamera\",(function(){return n.ArcRotateCamera})),i.d(t,\"ArcRotateCameraInputsManager\",(function(){return n.ArcRotateCameraInputsManager})),i.d(t,\"DeviceOrientationCamera\",(function(){return n.DeviceOrientationCamera})),i.d(t,\"FlyCamera\",(function(){return n.FlyCamera})),i.d(t,\"FlyCameraInputsManager\",(function(){return n.FlyCameraInputsManager})),i.d(t,\"FollowCamera\",(function(){return n.FollowCamera})),i.d(t,\"ArcFollowCamera\",(function(){return n.ArcFollowCamera})),i.d(t,\"FollowCameraInputsManager\",(function(){return n.FollowCameraInputsManager})),i.d(t,\"GamepadCamera\",(function(){return n.GamepadCamera})),i.d(t,\"AnaglyphArcRotateCamera\",(function(){return n.AnaglyphArcRotateCamera})),i.d(t,\"AnaglyphFreeCamera\",(function(){return n.AnaglyphFreeCamera})),i.d(t,\"AnaglyphGamepadCamera\",(function(){return n.AnaglyphGamepadCamera})),i.d(t,\"AnaglyphUniversalCamera\",(function(){return n.AnaglyphUniversalCamera})),i.d(t,\"StereoscopicArcRotateCamera\",(function(){return n.StereoscopicArcRotateCamera})),i.d(t,\"StereoscopicFreeCamera\",(function(){return n.StereoscopicFreeCamera})),i.d(t,\"StereoscopicGamepadCamera\",(function(){return n.StereoscopicGamepadCamera})),i.d(t,\"StereoscopicUniversalCamera\",(function(){return n.StereoscopicUniversalCamera})),i.d(t,\"UniversalCamera\",(function(){return n.UniversalCamera})),i.d(t,\"VirtualJoysticksCamera\",(function(){return n.VirtualJoysticksCamera})),i.d(t,\"VRCameraMetrics\",(function(){return n.VRCameraMetrics})),i.d(t,\"VRDeviceOrientationArcRotateCamera\",(function(){return n.VRDeviceOrientationArcRotateCamera})),i.d(t,\"VRDeviceOrientationFreeCamera\",(function(){return n.VRDeviceOrientationFreeCamera})),i.d(t,\"VRDeviceOrientationGamepadCamera\",(function(){return n.VRDeviceOrientationGamepadCamera})),i.d(t,\"OnAfterEnteringVRObservableEvent\",(function(){return n.OnAfterEnteringVRObservableEvent})),i.d(t,\"VRExperienceHelper\",(function(){return n.VRExperienceHelper})),i.d(t,\"WebVRFreeCamera\",(function(){return n.WebVRFreeCamera})),i.d(t,\"Collider\",(function(){return n.Collider})),i.d(t,\"DefaultCollisionCoordinator\",(function(){return n.DefaultCollisionCoordinator})),i.d(t,\"PickingInfo\",(function(){return n.PickingInfo})),i.d(t,\"IntersectionInfo\",(function(){return n.IntersectionInfo})),i.d(t,\"_MeshCollisionData\",(function(){return n._MeshCollisionData})),i.d(t,\"BoundingBox\",(function(){return n.BoundingBox})),i.d(t,\"BoundingInfo\",(function(){return n.BoundingInfo})),i.d(t,\"BoundingSphere\",(function(){return n.BoundingSphere})),i.d(t,\"Octree\",(function(){return n.Octree})),i.d(t,\"OctreeBlock\",(function(){return n.OctreeBlock})),i.d(t,\"OctreeSceneComponent\",(function(){return n.OctreeSceneComponent})),i.d(t,\"Ray\",(function(){return n.Ray})),i.d(t,\"AxesViewer\",(function(){return n.AxesViewer})),i.d(t,\"BoneAxesViewer\",(function(){return n.BoneAxesViewer})),i.d(t,\"DebugLayerTab\",(function(){return n.DebugLayerTab})),i.d(t,\"DebugLayer\",(function(){return n.DebugLayer})),i.d(t,\"PhysicsViewer\",(function(){return n.PhysicsViewer})),i.d(t,\"RayHelper\",(function(){return n.RayHelper})),i.d(t,\"SkeletonViewer\",(function(){return n.SkeletonViewer})),i.d(t,\"DeviceInputSystem\",(function(){return n.DeviceInputSystem})),i.d(t,\"DeviceType\",(function(){return n.DeviceType})),i.d(t,\"PointerInput\",(function(){return n.PointerInput})),i.d(t,\"DualShockInput\",(function(){return n.DualShockInput})),i.d(t,\"XboxInput\",(function(){return n.XboxInput})),i.d(t,\"SwitchInput\",(function(){return n.SwitchInput})),i.d(t,\"DeviceSource\",(function(){return n.DeviceSource})),i.d(t,\"DeviceSourceManager\",(function(){return n.DeviceSourceManager})),i.d(t,\"Constants\",(function(){return n.Constants})),i.d(t,\"ThinEngine\",(function(){return n.ThinEngine})),i.d(t,\"Engine\",(function(){return n.Engine})),i.d(t,\"EngineStore\",(function(){return n.EngineStore})),i.d(t,\"NullEngineOptions\",(function(){return n.NullEngineOptions})),i.d(t,\"NullEngine\",(function(){return n.NullEngine})),i.d(t,\"_OcclusionDataStorage\",(function(){return n._OcclusionDataStorage})),i.d(t,\"_forceTransformFeedbackToBundle\",(function(){return n._forceTransformFeedbackToBundle})),i.d(t,\"EngineView\",(function(){return n.EngineView})),i.d(t,\"WebGLPipelineContext\",(function(){return n.WebGLPipelineContext})),i.d(t,\"WebGL2ShaderProcessor\",(function(){return n.WebGL2ShaderProcessor})),i.d(t,\"NativeEngine\",(function(){return n.NativeEngine})),i.d(t,\"ShaderCodeInliner\",(function(){return n.ShaderCodeInliner})),i.d(t,\"PerformanceConfigurator\",(function(){return n.PerformanceConfigurator})),i.d(t,\"KeyboardEventTypes\",(function(){return n.KeyboardEventTypes})),i.d(t,\"KeyboardInfo\",(function(){return n.KeyboardInfo})),i.d(t,\"KeyboardInfoPre\",(function(){return n.KeyboardInfoPre})),i.d(t,\"PointerEventTypes\",(function(){return n.PointerEventTypes})),i.d(t,\"PointerInfoBase\",(function(){return n.PointerInfoBase})),i.d(t,\"PointerInfoPre\",(function(){return n.PointerInfoPre})),i.d(t,\"PointerInfo\",(function(){return n.PointerInfo})),i.d(t,\"ClipboardEventTypes\",(function(){return n.ClipboardEventTypes})),i.d(t,\"ClipboardInfo\",(function(){return n.ClipboardInfo})),i.d(t,\"DaydreamController\",(function(){return n.DaydreamController})),i.d(t,\"GearVRController\",(function(){return n.GearVRController})),i.d(t,\"GenericController\",(function(){return n.GenericController})),i.d(t,\"OculusTouchController\",(function(){return n.OculusTouchController})),i.d(t,\"PoseEnabledControllerType\",(function(){return n.PoseEnabledControllerType})),i.d(t,\"PoseEnabledControllerHelper\",(function(){return n.PoseEnabledControllerHelper})),i.d(t,\"PoseEnabledController\",(function(){return n.PoseEnabledController})),i.d(t,\"ViveController\",(function(){return n.ViveController})),i.d(t,\"WebVRController\",(function(){return n.WebVRController})),i.d(t,\"WindowsMotionController\",(function(){return n.WindowsMotionController})),i.d(t,\"XRWindowsMotionController\",(function(){return n.XRWindowsMotionController})),i.d(t,\"StickValues\",(function(){return n.StickValues})),i.d(t,\"Gamepad\",(function(){return n.Gamepad})),i.d(t,\"GenericPad\",(function(){return n.GenericPad})),i.d(t,\"GamepadManager\",(function(){return n.GamepadManager})),i.d(t,\"GamepadSystemSceneComponent\",(function(){return n.GamepadSystemSceneComponent})),i.d(t,\"Xbox360Button\",(function(){return n.Xbox360Button})),i.d(t,\"Xbox360Dpad\",(function(){return n.Xbox360Dpad})),i.d(t,\"Xbox360Pad\",(function(){return n.Xbox360Pad})),i.d(t,\"DualShockButton\",(function(){return n.DualShockButton})),i.d(t,\"DualShockDpad\",(function(){return n.DualShockDpad})),i.d(t,\"DualShockPad\",(function(){return n.DualShockPad})),i.d(t,\"AxisDragGizmo\",(function(){return n.AxisDragGizmo})),i.d(t,\"AxisScaleGizmo\",(function(){return n.AxisScaleGizmo})),i.d(t,\"BoundingBoxGizmo\",(function(){return n.BoundingBoxGizmo})),i.d(t,\"Gizmo\",(function(){return n.Gizmo})),i.d(t,\"GizmoManager\",(function(){return n.GizmoManager})),i.d(t,\"PlaneRotationGizmo\",(function(){return n.PlaneRotationGizmo})),i.d(t,\"PositionGizmo\",(function(){return n.PositionGizmo})),i.d(t,\"RotationGizmo\",(function(){return n.RotationGizmo})),i.d(t,\"ScaleGizmo\",(function(){return n.ScaleGizmo})),i.d(t,\"LightGizmo\",(function(){return n.LightGizmo})),i.d(t,\"CameraGizmo\",(function(){return n.CameraGizmo})),i.d(t,\"PlaneDragGizmo\",(function(){return n.PlaneDragGizmo})),i.d(t,\"EnvironmentHelper\",(function(){return n.EnvironmentHelper})),i.d(t,\"PhotoDome\",(function(){return n.PhotoDome})),i.d(t,\"_forceSceneHelpersToBundle\",(function(){return n._forceSceneHelpersToBundle})),i.d(t,\"VideoDome\",(function(){return n.VideoDome})),i.d(t,\"EngineInstrumentation\",(function(){return n.EngineInstrumentation})),i.d(t,\"SceneInstrumentation\",(function(){return n.SceneInstrumentation})),i.d(t,\"_TimeToken\",(function(){return n._TimeToken})),i.d(t,\"EffectLayer\",(function(){return n.EffectLayer})),i.d(t,\"EffectLayerSceneComponent\",(function(){return n.EffectLayerSceneComponent})),i.d(t,\"GlowLayer\",(function(){return n.GlowLayer})),i.d(t,\"HighlightLayer\",(function(){return n.HighlightLayer})),i.d(t,\"Layer\",(function(){return n.Layer})),i.d(t,\"LayerSceneComponent\",(function(){return n.LayerSceneComponent})),i.d(t,\"LensFlare\",(function(){return n.LensFlare})),i.d(t,\"LensFlareSystem\",(function(){return n.LensFlareSystem})),i.d(t,\"LensFlareSystemSceneComponent\",(function(){return n.LensFlareSystemSceneComponent})),i.d(t,\"Light\",(function(){return n.Light})),i.d(t,\"ShadowLight\",(function(){return n.ShadowLight})),i.d(t,\"ShadowGenerator\",(function(){return n.ShadowGenerator})),i.d(t,\"CascadedShadowGenerator\",(function(){return n.CascadedShadowGenerator})),i.d(t,\"ShadowGeneratorSceneComponent\",(function(){return n.ShadowGeneratorSceneComponent})),i.d(t,\"DirectionalLight\",(function(){return n.DirectionalLight})),i.d(t,\"HemisphericLight\",(function(){return n.HemisphericLight})),i.d(t,\"PointLight\",(function(){return n.PointLight})),i.d(t,\"SpotLight\",(function(){return n.SpotLight})),i.d(t,\"DefaultLoadingScreen\",(function(){return n.DefaultLoadingScreen})),i.d(t,\"_BabylonLoaderRegistered\",(function(){return n._BabylonLoaderRegistered})),i.d(t,\"BabylonFileLoaderConfiguration\",(function(){return n.BabylonFileLoaderConfiguration})),i.d(t,\"SceneLoaderAnimationGroupLoadingMode\",(function(){return n.SceneLoaderAnimationGroupLoadingMode})),i.d(t,\"SceneLoader\",(function(){return n.SceneLoader})),i.d(t,\"SceneLoaderFlags\",(function(){return n.SceneLoaderFlags})),i.d(t,\"BackgroundMaterial\",(function(){return n.BackgroundMaterial})),i.d(t,\"ColorCurves\",(function(){return n.ColorCurves})),i.d(t,\"EffectFallbacks\",(function(){return n.EffectFallbacks})),i.d(t,\"Effect\",(function(){return n.Effect})),i.d(t,\"FresnelParameters\",(function(){return n.FresnelParameters})),i.d(t,\"ImageProcessingConfigurationDefines\",(function(){return n.ImageProcessingConfigurationDefines})),i.d(t,\"ImageProcessingConfiguration\",(function(){return n.ImageProcessingConfiguration})),i.d(t,\"Material\",(function(){return n.Material})),i.d(t,\"MaterialDefines\",(function(){return n.MaterialDefines})),i.d(t,\"ThinMaterialHelper\",(function(){return n.ThinMaterialHelper})),i.d(t,\"MaterialHelper\",(function(){return n.MaterialHelper})),i.d(t,\"MultiMaterial\",(function(){return n.MultiMaterial})),i.d(t,\"PBRMaterialDefines\",(function(){return n.PBRMaterialDefines})),i.d(t,\"PBRBaseMaterial\",(function(){return n.PBRBaseMaterial})),i.d(t,\"PBRBaseSimpleMaterial\",(function(){return n.PBRBaseSimpleMaterial})),i.d(t,\"PBRMaterial\",(function(){return n.PBRMaterial})),i.d(t,\"PBRMetallicRoughnessMaterial\",(function(){return n.PBRMetallicRoughnessMaterial})),i.d(t,\"PBRSpecularGlossinessMaterial\",(function(){return n.PBRSpecularGlossinessMaterial})),i.d(t,\"PushMaterial\",(function(){return n.PushMaterial})),i.d(t,\"ShaderMaterial\",(function(){return n.ShaderMaterial})),i.d(t,\"StandardMaterialDefines\",(function(){return n.StandardMaterialDefines})),i.d(t,\"StandardMaterial\",(function(){return n.StandardMaterial})),i.d(t,\"BaseTexture\",(function(){return n.BaseTexture})),i.d(t,\"ColorGradingTexture\",(function(){return n.ColorGradingTexture})),i.d(t,\"CubeTexture\",(function(){return n.CubeTexture})),i.d(t,\"DynamicTexture\",(function(){return n.DynamicTexture})),i.d(t,\"EquiRectangularCubeTexture\",(function(){return n.EquiRectangularCubeTexture})),i.d(t,\"HDRFiltering\",(function(){return n.HDRFiltering})),i.d(t,\"HDRCubeTexture\",(function(){return n.HDRCubeTexture})),i.d(t,\"HtmlElementTexture\",(function(){return n.HtmlElementTexture})),i.d(t,\"InternalTextureSource\",(function(){return n.InternalTextureSource})),i.d(t,\"InternalTexture\",(function(){return n.InternalTexture})),i.d(t,\"_DDSTextureLoader\",(function(){return n._DDSTextureLoader})),i.d(t,\"_ENVTextureLoader\",(function(){return n._ENVTextureLoader})),i.d(t,\"_KTXTextureLoader\",(function(){return n._KTXTextureLoader})),i.d(t,\"_TGATextureLoader\",(function(){return n._TGATextureLoader})),i.d(t,\"_BasisTextureLoader\",(function(){return n._BasisTextureLoader})),i.d(t,\"MirrorTexture\",(function(){return n.MirrorTexture})),i.d(t,\"MultiRenderTarget\",(function(){return n.MultiRenderTarget})),i.d(t,\"TexturePacker\",(function(){return n.TexturePacker})),i.d(t,\"TexturePackerFrame\",(function(){return n.TexturePackerFrame})),i.d(t,\"CustomProceduralTexture\",(function(){return n.CustomProceduralTexture})),i.d(t,\"NoiseProceduralTexture\",(function(){return n.NoiseProceduralTexture})),i.d(t,\"ProceduralTexture\",(function(){return n.ProceduralTexture})),i.d(t,\"ProceduralTextureSceneComponent\",(function(){return n.ProceduralTextureSceneComponent})),i.d(t,\"RawCubeTexture\",(function(){return n.RawCubeTexture})),i.d(t,\"RawTexture\",(function(){return n.RawTexture})),i.d(t,\"RawTexture2DArray\",(function(){return n.RawTexture2DArray})),i.d(t,\"RawTexture3D\",(function(){return n.RawTexture3D})),i.d(t,\"RefractionTexture\",(function(){return n.RefractionTexture})),i.d(t,\"RenderTargetTexture\",(function(){return n.RenderTargetTexture})),i.d(t,\"Texture\",(function(){return n.Texture})),i.d(t,\"VideoTexture\",(function(){return n.VideoTexture})),i.d(t,\"UniformBuffer\",(function(){return n.UniformBuffer})),i.d(t,\"MaterialFlags\",(function(){return n.MaterialFlags})),i.d(t,\"NodeMaterialBlockTargets\",(function(){return n.NodeMaterialBlockTargets})),i.d(t,\"NodeMaterialBlockConnectionPointTypes\",(function(){return n.NodeMaterialBlockConnectionPointTypes})),i.d(t,\"NodeMaterialBlockConnectionPointMode\",(function(){return n.NodeMaterialBlockConnectionPointMode})),i.d(t,\"NodeMaterialSystemValues\",(function(){return n.NodeMaterialSystemValues})),i.d(t,\"NodeMaterialModes\",(function(){return n.NodeMaterialModes})),i.d(t,\"NodeMaterialConnectionPointCompatibilityStates\",(function(){return n.NodeMaterialConnectionPointCompatibilityStates})),i.d(t,\"NodeMaterialConnectionPointDirection\",(function(){return n.NodeMaterialConnectionPointDirection})),i.d(t,\"NodeMaterialConnectionPoint\",(function(){return n.NodeMaterialConnectionPoint})),i.d(t,\"NodeMaterialBlock\",(function(){return n.NodeMaterialBlock})),i.d(t,\"NodeMaterialDefines\",(function(){return n.NodeMaterialDefines})),i.d(t,\"NodeMaterial\",(function(){return n.NodeMaterial})),i.d(t,\"VertexOutputBlock\",(function(){return n.VertexOutputBlock})),i.d(t,\"BonesBlock\",(function(){return n.BonesBlock})),i.d(t,\"InstancesBlock\",(function(){return n.InstancesBlock})),i.d(t,\"MorphTargetsBlock\",(function(){return n.MorphTargetsBlock})),i.d(t,\"LightInformationBlock\",(function(){return n.LightInformationBlock})),i.d(t,\"FragmentOutputBlock\",(function(){return n.FragmentOutputBlock})),i.d(t,\"ImageProcessingBlock\",(function(){return n.ImageProcessingBlock})),i.d(t,\"PerturbNormalBlock\",(function(){return n.PerturbNormalBlock})),i.d(t,\"DiscardBlock\",(function(){return n.DiscardBlock})),i.d(t,\"FrontFacingBlock\",(function(){return n.FrontFacingBlock})),i.d(t,\"DerivativeBlock\",(function(){return n.DerivativeBlock})),i.d(t,\"FragCoordBlock\",(function(){return n.FragCoordBlock})),i.d(t,\"ScreenSizeBlock\",(function(){return n.ScreenSizeBlock})),i.d(t,\"FogBlock\",(function(){return n.FogBlock})),i.d(t,\"LightBlock\",(function(){return n.LightBlock})),i.d(t,\"TextureBlock\",(function(){return n.TextureBlock})),i.d(t,\"ReflectionTextureBlock\",(function(){return n.ReflectionTextureBlock})),i.d(t,\"CurrentScreenBlock\",(function(){return n.CurrentScreenBlock})),i.d(t,\"InputBlock\",(function(){return n.InputBlock})),i.d(t,\"AnimatedInputBlockTypes\",(function(){return n.AnimatedInputBlockTypes})),i.d(t,\"MultiplyBlock\",(function(){return n.MultiplyBlock})),i.d(t,\"AddBlock\",(function(){return n.AddBlock})),i.d(t,\"ScaleBlock\",(function(){return n.ScaleBlock})),i.d(t,\"ClampBlock\",(function(){return n.ClampBlock})),i.d(t,\"CrossBlock\",(function(){return n.CrossBlock})),i.d(t,\"DotBlock\",(function(){return n.DotBlock})),i.d(t,\"TransformBlock\",(function(){return n.TransformBlock})),i.d(t,\"RemapBlock\",(function(){return n.RemapBlock})),i.d(t,\"NormalizeBlock\",(function(){return n.NormalizeBlock})),i.d(t,\"TrigonometryBlockOperations\",(function(){return n.TrigonometryBlockOperations})),i.d(t,\"TrigonometryBlock\",(function(){return n.TrigonometryBlock})),i.d(t,\"ColorMergerBlock\",(function(){return n.ColorMergerBlock})),i.d(t,\"VectorMergerBlock\",(function(){return n.VectorMergerBlock})),i.d(t,\"ColorSplitterBlock\",(function(){return n.ColorSplitterBlock})),i.d(t,\"VectorSplitterBlock\",(function(){return n.VectorSplitterBlock})),i.d(t,\"LerpBlock\",(function(){return n.LerpBlock})),i.d(t,\"DivideBlock\",(function(){return n.DivideBlock})),i.d(t,\"SubtractBlock\",(function(){return n.SubtractBlock})),i.d(t,\"StepBlock\",(function(){return n.StepBlock})),i.d(t,\"OneMinusBlock\",(function(){return n.OneMinusBlock})),i.d(t,\"ViewDirectionBlock\",(function(){return n.ViewDirectionBlock})),i.d(t,\"FresnelBlock\",(function(){return n.FresnelBlock})),i.d(t,\"MaxBlock\",(function(){return n.MaxBlock})),i.d(t,\"MinBlock\",(function(){return n.MinBlock})),i.d(t,\"DistanceBlock\",(function(){return n.DistanceBlock})),i.d(t,\"LengthBlock\",(function(){return n.LengthBlock})),i.d(t,\"NegateBlock\",(function(){return n.NegateBlock})),i.d(t,\"PowBlock\",(function(){return n.PowBlock})),i.d(t,\"RandomNumberBlock\",(function(){return n.RandomNumberBlock})),i.d(t,\"ArcTan2Block\",(function(){return n.ArcTan2Block})),i.d(t,\"SmoothStepBlock\",(function(){return n.SmoothStepBlock})),i.d(t,\"ReciprocalBlock\",(function(){return n.ReciprocalBlock})),i.d(t,\"ReplaceColorBlock\",(function(){return n.ReplaceColorBlock})),i.d(t,\"PosterizeBlock\",(function(){return n.PosterizeBlock})),i.d(t,\"WaveBlockKind\",(function(){return n.WaveBlockKind})),i.d(t,\"WaveBlock\",(function(){return n.WaveBlock})),i.d(t,\"GradientBlockColorStep\",(function(){return n.GradientBlockColorStep})),i.d(t,\"GradientBlock\",(function(){return n.GradientBlock})),i.d(t,\"NLerpBlock\",(function(){return n.NLerpBlock})),i.d(t,\"WorleyNoise3DBlock\",(function(){return n.WorleyNoise3DBlock})),i.d(t,\"SimplexPerlin3DBlock\",(function(){return n.SimplexPerlin3DBlock})),i.d(t,\"NormalBlendBlock\",(function(){return n.NormalBlendBlock})),i.d(t,\"Rotate2dBlock\",(function(){return n.Rotate2dBlock})),i.d(t,\"ReflectBlock\",(function(){return n.ReflectBlock})),i.d(t,\"RefractBlock\",(function(){return n.RefractBlock})),i.d(t,\"DesaturateBlock\",(function(){return n.DesaturateBlock})),i.d(t,\"PBRMetallicRoughnessBlock\",(function(){return n.PBRMetallicRoughnessBlock})),i.d(t,\"SheenBlock\",(function(){return n.SheenBlock})),i.d(t,\"AnisotropyBlock\",(function(){return n.AnisotropyBlock})),i.d(t,\"ReflectionBlock\",(function(){return n.ReflectionBlock})),i.d(t,\"ClearCoatBlock\",(function(){return n.ClearCoatBlock})),i.d(t,\"RefractionBlock\",(function(){return n.RefractionBlock})),i.d(t,\"SubSurfaceBlock\",(function(){return n.SubSurfaceBlock})),i.d(t,\"ParticleTextureBlock\",(function(){return n.ParticleTextureBlock})),i.d(t,\"ParticleRampGradientBlock\",(function(){return n.ParticleRampGradientBlock})),i.d(t,\"ParticleBlendMultiplyBlock\",(function(){return n.ParticleBlendMultiplyBlock})),i.d(t,\"ModBlock\",(function(){return n.ModBlock})),i.d(t,\"NodeMaterialOptimizer\",(function(){return n.NodeMaterialOptimizer})),i.d(t,\"PropertyTypeForEdition\",(function(){return n.PropertyTypeForEdition})),i.d(t,\"editableInPropertyPage\",(function(){return n.editableInPropertyPage})),i.d(t,\"EffectRenderer\",(function(){return n.EffectRenderer})),i.d(t,\"EffectWrapper\",(function(){return n.EffectWrapper})),i.d(t,\"ShadowDepthWrapper\",(function(){return n.ShadowDepthWrapper})),i.d(t,\"Scalar\",(function(){return n.Scalar})),i.d(t,\"extractMinAndMaxIndexed\",(function(){return n.extractMinAndMaxIndexed})),i.d(t,\"extractMinAndMax\",(function(){return n.extractMinAndMax})),i.d(t,\"Space\",(function(){return n.Space})),i.d(t,\"Axis\",(function(){return n.Axis})),i.d(t,\"Coordinate\",(function(){return n.Coordinate})),i.d(t,\"Color3\",(function(){return n.Color3})),i.d(t,\"Color4\",(function(){return n.Color4})),i.d(t,\"TmpColors\",(function(){return n.TmpColors})),i.d(t,\"ToGammaSpace\",(function(){return n.ToGammaSpace})),i.d(t,\"ToLinearSpace\",(function(){return n.ToLinearSpace})),i.d(t,\"Epsilon\",(function(){return n.Epsilon})),i.d(t,\"Frustum\",(function(){return n.Frustum})),i.d(t,\"Orientation\",(function(){return n.Orientation})),i.d(t,\"BezierCurve\",(function(){return n.BezierCurve})),i.d(t,\"Angle\",(function(){return n.Angle})),i.d(t,\"Arc2\",(function(){return n.Arc2})),i.d(t,\"Path2\",(function(){return n.Path2})),i.d(t,\"Path3D\",(function(){return n.Path3D})),i.d(t,\"Curve3\",(function(){return n.Curve3})),i.d(t,\"Plane\",(function(){return n.Plane})),i.d(t,\"Size\",(function(){return n.Size})),i.d(t,\"Vector2\",(function(){return n.Vector2})),i.d(t,\"Vector3\",(function(){return n.Vector3})),i.d(t,\"Vector4\",(function(){return n.Vector4})),i.d(t,\"Quaternion\",(function(){return n.Quaternion})),i.d(t,\"Matrix\",(function(){return n.Matrix})),i.d(t,\"TmpVectors\",(function(){return n.TmpVectors})),i.d(t,\"PositionNormalVertex\",(function(){return n.PositionNormalVertex})),i.d(t,\"PositionNormalTextureVertex\",(function(){return n.PositionNormalTextureVertex})),i.d(t,\"Viewport\",(function(){return n.Viewport})),i.d(t,\"SphericalHarmonics\",(function(){return n.SphericalHarmonics})),i.d(t,\"SphericalPolynomial\",(function(){return n.SphericalPolynomial})),i.d(t,\"AbstractMesh\",(function(){return n.AbstractMesh})),i.d(t,\"Buffer\",(function(){return n.Buffer})),i.d(t,\"VertexBuffer\",(function(){return n.VertexBuffer})),i.d(t,\"DracoCompression\",(function(){return n.DracoCompression})),i.d(t,\"CSG\",(function(){return n.CSG})),i.d(t,\"Geometry\",(function(){return n.Geometry})),i.d(t,\"GroundMesh\",(function(){return n.GroundMesh})),i.d(t,\"TrailMesh\",(function(){return n.TrailMesh})),i.d(t,\"InstancedMesh\",(function(){return n.InstancedMesh})),i.d(t,\"LinesMesh\",(function(){return n.LinesMesh})),i.d(t,\"InstancedLinesMesh\",(function(){return n.InstancedLinesMesh})),i.d(t,\"_CreationDataStorage\",(function(){return n._CreationDataStorage})),i.d(t,\"_InstancesBatch\",(function(){return n._InstancesBatch})),i.d(t,\"Mesh\",(function(){return n.Mesh})),i.d(t,\"VertexData\",(function(){return n.VertexData})),i.d(t,\"MeshBuilder\",(function(){return n.MeshBuilder})),i.d(t,\"SimplificationSettings\",(function(){return n.SimplificationSettings})),i.d(t,\"SimplificationQueue\",(function(){return n.SimplificationQueue})),i.d(t,\"SimplificationType\",(function(){return n.SimplificationType})),i.d(t,\"QuadraticErrorSimplification\",(function(){return n.QuadraticErrorSimplification})),i.d(t,\"SimplicationQueueSceneComponent\",(function(){return n.SimplicationQueueSceneComponent})),i.d(t,\"Polygon\",(function(){return n.Polygon})),i.d(t,\"PolygonMeshBuilder\",(function(){return n.PolygonMeshBuilder})),i.d(t,\"SubMesh\",(function(){return n.SubMesh})),i.d(t,\"MeshLODLevel\",(function(){return n.MeshLODLevel})),i.d(t,\"TransformNode\",(function(){return n.TransformNode})),i.d(t,\"BoxBuilder\",(function(){return n.BoxBuilder})),i.d(t,\"TiledBoxBuilder\",(function(){return n.TiledBoxBuilder})),i.d(t,\"DiscBuilder\",(function(){return n.DiscBuilder})),i.d(t,\"RibbonBuilder\",(function(){return n.RibbonBuilder})),i.d(t,\"SphereBuilder\",(function(){return n.SphereBuilder})),i.d(t,\"HemisphereBuilder\",(function(){return n.HemisphereBuilder})),i.d(t,\"CylinderBuilder\",(function(){return n.CylinderBuilder})),i.d(t,\"TorusBuilder\",(function(){return n.TorusBuilder})),i.d(t,\"TorusKnotBuilder\",(function(){return n.TorusKnotBuilder})),i.d(t,\"LinesBuilder\",(function(){return n.LinesBuilder})),i.d(t,\"PolygonBuilder\",(function(){return n.PolygonBuilder})),i.d(t,\"ShapeBuilder\",(function(){return n.ShapeBuilder})),i.d(t,\"LatheBuilder\",(function(){return n.LatheBuilder})),i.d(t,\"PlaneBuilder\",(function(){return n.PlaneBuilder})),i.d(t,\"TiledPlaneBuilder\",(function(){return n.TiledPlaneBuilder})),i.d(t,\"GroundBuilder\",(function(){return n.GroundBuilder})),i.d(t,\"TubeBuilder\",(function(){return n.TubeBuilder})),i.d(t,\"PolyhedronBuilder\",(function(){return n.PolyhedronBuilder})),i.d(t,\"IcoSphereBuilder\",(function(){return n.IcoSphereBuilder})),i.d(t,\"DecalBuilder\",(function(){return n.DecalBuilder})),i.d(t,\"CapsuleBuilder\",(function(){return n.CapsuleBuilder})),i.d(t,\"DataBuffer\",(function(){return n.DataBuffer})),i.d(t,\"WebGLDataBuffer\",(function(){return n.WebGLDataBuffer})),i.d(t,\"MorphTarget\",(function(){return n.MorphTarget})),i.d(t,\"MorphTargetManager\",(function(){return n.MorphTargetManager})),i.d(t,\"RecastJSPlugin\",(function(){return n.RecastJSPlugin})),i.d(t,\"RecastJSCrowd\",(function(){return n.RecastJSCrowd})),i.d(t,\"Node\",(function(){return n.Node})),i.d(t,\"Database\",(function(){return n.Database})),i.d(t,\"BaseParticleSystem\",(function(){return n.BaseParticleSystem})),i.d(t,\"BoxParticleEmitter\",(function(){return n.BoxParticleEmitter})),i.d(t,\"ConeParticleEmitter\",(function(){return n.ConeParticleEmitter})),i.d(t,\"CylinderParticleEmitter\",(function(){return n.CylinderParticleEmitter})),i.d(t,\"CylinderDirectedParticleEmitter\",(function(){return n.CylinderDirectedParticleEmitter})),i.d(t,\"HemisphericParticleEmitter\",(function(){return n.HemisphericParticleEmitter})),i.d(t,\"PointParticleEmitter\",(function(){return n.PointParticleEmitter})),i.d(t,\"SphereParticleEmitter\",(function(){return n.SphereParticleEmitter})),i.d(t,\"SphereDirectedParticleEmitter\",(function(){return n.SphereDirectedParticleEmitter})),i.d(t,\"CustomParticleEmitter\",(function(){return n.CustomParticleEmitter})),i.d(t,\"MeshParticleEmitter\",(function(){return n.MeshParticleEmitter})),i.d(t,\"GPUParticleSystem\",(function(){return n.GPUParticleSystem})),i.d(t,\"Particle\",(function(){return n.Particle})),i.d(t,\"ParticleHelper\",(function(){return n.ParticleHelper})),i.d(t,\"ParticleSystem\",(function(){return n.ParticleSystem})),i.d(t,\"ParticleSystemSet\",(function(){return n.ParticleSystemSet})),i.d(t,\"SolidParticle\",(function(){return n.SolidParticle})),i.d(t,\"ModelShape\",(function(){return n.ModelShape})),i.d(t,\"DepthSortedParticle\",(function(){return n.DepthSortedParticle})),i.d(t,\"SolidParticleVertex\",(function(){return n.SolidParticleVertex})),i.d(t,\"SolidParticleSystem\",(function(){return n.SolidParticleSystem})),i.d(t,\"CloudPoint\",(function(){return n.CloudPoint})),i.d(t,\"PointsGroup\",(function(){return n.PointsGroup})),i.d(t,\"PointColor\",(function(){return n.PointColor})),i.d(t,\"PointsCloudSystem\",(function(){return n.PointsCloudSystem})),i.d(t,\"SubEmitterType\",(function(){return n.SubEmitterType})),i.d(t,\"SubEmitter\",(function(){return n.SubEmitter})),i.d(t,\"PhysicsEngine\",(function(){return n.PhysicsEngine})),i.d(t,\"PhysicsEngineSceneComponent\",(function(){return n.PhysicsEngineSceneComponent})),i.d(t,\"PhysicsHelper\",(function(){return n.PhysicsHelper})),i.d(t,\"PhysicsRadialExplosionEventOptions\",(function(){return n.PhysicsRadialExplosionEventOptions})),i.d(t,\"PhysicsUpdraftEventOptions\",(function(){return n.PhysicsUpdraftEventOptions})),i.d(t,\"PhysicsVortexEventOptions\",(function(){return n.PhysicsVortexEventOptions})),i.d(t,\"PhysicsRadialImpulseFalloff\",(function(){return n.PhysicsRadialImpulseFalloff})),i.d(t,\"PhysicsUpdraftMode\",(function(){return n.PhysicsUpdraftMode})),i.d(t,\"PhysicsImpostor\",(function(){return n.PhysicsImpostor})),i.d(t,\"PhysicsJoint\",(function(){return n.PhysicsJoint})),i.d(t,\"DistanceJoint\",(function(){return n.DistanceJoint})),i.d(t,\"MotorEnabledJoint\",(function(){return n.MotorEnabledJoint})),i.d(t,\"HingeJoint\",(function(){return n.HingeJoint})),i.d(t,\"Hinge2Joint\",(function(){return n.Hinge2Joint})),i.d(t,\"CannonJSPlugin\",(function(){return n.CannonJSPlugin})),i.d(t,\"AmmoJSPlugin\",(function(){return n.AmmoJSPlugin})),i.d(t,\"OimoJSPlugin\",(function(){return n.OimoJSPlugin})),i.d(t,\"AnaglyphPostProcess\",(function(){return n.AnaglyphPostProcess})),i.d(t,\"BlackAndWhitePostProcess\",(function(){return n.BlackAndWhitePostProcess})),i.d(t,\"BloomEffect\",(function(){return n.BloomEffect})),i.d(t,\"BloomMergePostProcess\",(function(){return n.BloomMergePostProcess})),i.d(t,\"BlurPostProcess\",(function(){return n.BlurPostProcess})),i.d(t,\"ChromaticAberrationPostProcess\",(function(){return n.ChromaticAberrationPostProcess})),i.d(t,\"CircleOfConfusionPostProcess\",(function(){return n.CircleOfConfusionPostProcess})),i.d(t,\"ColorCorrectionPostProcess\",(function(){return n.ColorCorrectionPostProcess})),i.d(t,\"ConvolutionPostProcess\",(function(){return n.ConvolutionPostProcess})),i.d(t,\"DepthOfFieldBlurPostProcess\",(function(){return n.DepthOfFieldBlurPostProcess})),i.d(t,\"DepthOfFieldEffectBlurLevel\",(function(){return n.DepthOfFieldEffectBlurLevel})),i.d(t,\"DepthOfFieldEffect\",(function(){return n.DepthOfFieldEffect})),i.d(t,\"DepthOfFieldMergePostProcessOptions\",(function(){return n.DepthOfFieldMergePostProcessOptions})),i.d(t,\"DepthOfFieldMergePostProcess\",(function(){return n.DepthOfFieldMergePostProcess})),i.d(t,\"DisplayPassPostProcess\",(function(){return n.DisplayPassPostProcess})),i.d(t,\"ExtractHighlightsPostProcess\",(function(){return n.ExtractHighlightsPostProcess})),i.d(t,\"FilterPostProcess\",(function(){return n.FilterPostProcess})),i.d(t,\"FxaaPostProcess\",(function(){return n.FxaaPostProcess})),i.d(t,\"GrainPostProcess\",(function(){return n.GrainPostProcess})),i.d(t,\"HighlightsPostProcess\",(function(){return n.HighlightsPostProcess})),i.d(t,\"ImageProcessingPostProcess\",(function(){return n.ImageProcessingPostProcess})),i.d(t,\"MotionBlurPostProcess\",(function(){return n.MotionBlurPostProcess})),i.d(t,\"PassPostProcess\",(function(){return n.PassPostProcess})),i.d(t,\"PassCubePostProcess\",(function(){return n.PassCubePostProcess})),i.d(t,\"PostProcess\",(function(){return n.PostProcess})),i.d(t,\"PostProcessManager\",(function(){return n.PostProcessManager})),i.d(t,\"RefractionPostProcess\",(function(){return n.RefractionPostProcess})),i.d(t,\"DefaultRenderingPipeline\",(function(){return n.DefaultRenderingPipeline})),i.d(t,\"LensRenderingPipeline\",(function(){return n.LensRenderingPipeline})),i.d(t,\"SSAO2RenderingPipeline\",(function(){return n.SSAO2RenderingPipeline})),i.d(t,\"SSAORenderingPipeline\",(function(){return n.SSAORenderingPipeline})),i.d(t,\"StandardRenderingPipeline\",(function(){return n.StandardRenderingPipeline})),i.d(t,\"PostProcessRenderEffect\",(function(){return n.PostProcessRenderEffect})),i.d(t,\"PostProcessRenderPipeline\",(function(){return n.PostProcessRenderPipeline})),i.d(t,\"PostProcessRenderPipelineManager\",(function(){return n.PostProcessRenderPipelineManager})),i.d(t,\"PostProcessRenderPipelineManagerSceneComponent\",(function(){return n.PostProcessRenderPipelineManagerSceneComponent})),i.d(t,\"SharpenPostProcess\",(function(){return n.SharpenPostProcess})),i.d(t,\"StereoscopicInterlacePostProcessI\",(function(){return n.StereoscopicInterlacePostProcessI})),i.d(t,\"StereoscopicInterlacePostProcess\",(function(){return n.StereoscopicInterlacePostProcess})),i.d(t,\"TonemappingOperator\",(function(){return n.TonemappingOperator})),i.d(t,\"TonemapPostProcess\",(function(){return n.TonemapPostProcess})),i.d(t,\"VolumetricLightScatteringPostProcess\",(function(){return n.VolumetricLightScatteringPostProcess})),i.d(t,\"VRDistortionCorrectionPostProcess\",(function(){return n.VRDistortionCorrectionPostProcess})),i.d(t,\"VRMultiviewToSingleviewPostProcess\",(function(){return n.VRMultiviewToSingleviewPostProcess})),i.d(t,\"ScreenSpaceReflectionPostProcess\",(function(){return n.ScreenSpaceReflectionPostProcess})),i.d(t,\"ScreenSpaceCurvaturePostProcess\",(function(){return n.ScreenSpaceCurvaturePostProcess})),i.d(t,\"ReflectionProbe\",(function(){return n.ReflectionProbe})),i.d(t,\"BoundingBoxRenderer\",(function(){return n.BoundingBoxRenderer})),i.d(t,\"DepthRenderer\",(function(){return n.DepthRenderer})),i.d(t,\"DepthRendererSceneComponent\",(function(){return n.DepthRendererSceneComponent})),i.d(t,\"EdgesRenderer\",(function(){return n.EdgesRenderer})),i.d(t,\"LineEdgesRenderer\",(function(){return n.LineEdgesRenderer})),i.d(t,\"GeometryBufferRenderer\",(function(){return n.GeometryBufferRenderer})),i.d(t,\"GeometryBufferRendererSceneComponent\",(function(){return n.GeometryBufferRendererSceneComponent})),i.d(t,\"PrePassRenderer\",(function(){return n.PrePassRenderer})),i.d(t,\"PrePassRendererSceneComponent\",(function(){return n.PrePassRendererSceneComponent})),i.d(t,\"SubSurfaceSceneComponent\",(function(){return n.SubSurfaceSceneComponent})),i.d(t,\"OutlineRenderer\",(function(){return n.OutlineRenderer})),i.d(t,\"RenderingGroup\",(function(){return n.RenderingGroup})),i.d(t,\"RenderingGroupInfo\",(function(){return n.RenderingGroupInfo})),i.d(t,\"RenderingManager\",(function(){return n.RenderingManager})),i.d(t,\"UtilityLayerRenderer\",(function(){return n.UtilityLayerRenderer})),i.d(t,\"Scene\",(function(){return n.Scene})),i.d(t,\"SceneComponentConstants\",(function(){return n.SceneComponentConstants})),i.d(t,\"Stage\",(function(){return n.Stage})),i.d(t,\"Sprite\",(function(){return n.Sprite})),i.d(t,\"SpriteManager\",(function(){return n.SpriteManager})),i.d(t,\"SpriteMap\",(function(){return n.SpriteMap})),i.d(t,\"SpritePackedManager\",(function(){return n.SpritePackedManager})),i.d(t,\"SpriteSceneComponent\",(function(){return n.SpriteSceneComponent})),i.d(t,\"AlphaState\",(function(){return n.AlphaState})),i.d(t,\"DepthCullingState\",(function(){return n.DepthCullingState})),i.d(t,\"StencilState\",(function(){return n.StencilState})),i.d(t,\"AndOrNotEvaluator\",(function(){return n.AndOrNotEvaluator})),i.d(t,\"AssetTaskState\",(function(){return n.AssetTaskState})),i.d(t,\"AbstractAssetTask\",(function(){return n.AbstractAssetTask})),i.d(t,\"AssetsProgressEvent\",(function(){return n.AssetsProgressEvent})),i.d(t,\"ContainerAssetTask\",(function(){return n.ContainerAssetTask})),i.d(t,\"MeshAssetTask\",(function(){return n.MeshAssetTask})),i.d(t,\"TextFileAssetTask\",(function(){return n.TextFileAssetTask})),i.d(t,\"BinaryFileAssetTask\",(function(){return n.BinaryFileAssetTask})),i.d(t,\"ImageAssetTask\",(function(){return n.ImageAssetTask})),i.d(t,\"TextureAssetTask\",(function(){return n.TextureAssetTask})),i.d(t,\"CubeTextureAssetTask\",(function(){return n.CubeTextureAssetTask})),i.d(t,\"HDRCubeTextureAssetTask\",(function(){return n.HDRCubeTextureAssetTask})),i.d(t,\"EquiRectangularCubeTextureAssetTask\",(function(){return n.EquiRectangularCubeTextureAssetTask})),i.d(t,\"AssetsManager\",(function(){return n.AssetsManager})),i.d(t,\"BasisTranscodeConfiguration\",(function(){return n.BasisTranscodeConfiguration})),i.d(t,\"BasisTools\",(function(){return n.BasisTools})),i.d(t,\"DDSTools\",(function(){return n.DDSTools})),i.d(t,\"expandToProperty\",(function(){return n.expandToProperty})),i.d(t,\"serialize\",(function(){return n.serialize})),i.d(t,\"serializeAsTexture\",(function(){return n.serializeAsTexture})),i.d(t,\"serializeAsColor3\",(function(){return n.serializeAsColor3})),i.d(t,\"serializeAsFresnelParameters\",(function(){return n.serializeAsFresnelParameters})),i.d(t,\"serializeAsVector2\",(function(){return n.serializeAsVector2})),i.d(t,\"serializeAsVector3\",(function(){return n.serializeAsVector3})),i.d(t,\"serializeAsMeshReference\",(function(){return n.serializeAsMeshReference})),i.d(t,\"serializeAsColorCurves\",(function(){return n.serializeAsColorCurves})),i.d(t,\"serializeAsColor4\",(function(){return n.serializeAsColor4})),i.d(t,\"serializeAsImageProcessingConfiguration\",(function(){return n.serializeAsImageProcessingConfiguration})),i.d(t,\"serializeAsQuaternion\",(function(){return n.serializeAsQuaternion})),i.d(t,\"serializeAsMatrix\",(function(){return n.serializeAsMatrix})),i.d(t,\"serializeAsCameraReference\",(function(){return n.serializeAsCameraReference})),i.d(t,\"SerializationHelper\",(function(){return n.SerializationHelper})),i.d(t,\"Deferred\",(function(){return n.Deferred})),i.d(t,\"EnvironmentTextureTools\",(function(){return n.EnvironmentTextureTools})),i.d(t,\"MeshExploder\",(function(){return n.MeshExploder})),i.d(t,\"FilesInput\",(function(){return n.FilesInput})),i.d(t,\"CubeMapToSphericalPolynomialTools\",(function(){return n.CubeMapToSphericalPolynomialTools})),i.d(t,\"HDRTools\",(function(){return n.HDRTools})),i.d(t,\"PanoramaToCubeMapTools\",(function(){return n.PanoramaToCubeMapTools})),i.d(t,\"KhronosTextureContainer\",(function(){return n.KhronosTextureContainer})),i.d(t,\"EventState\",(function(){return n.EventState})),i.d(t,\"Observer\",(function(){return n.Observer})),i.d(t,\"MultiObserver\",(function(){return n.MultiObserver})),i.d(t,\"Observable\",(function(){return n.Observable})),i.d(t,\"PerformanceMonitor\",(function(){return n.PerformanceMonitor})),i.d(t,\"RollingAverage\",(function(){return n.RollingAverage})),i.d(t,\"PromisePolyfill\",(function(){return n.PromisePolyfill})),i.d(t,\"SceneOptimization\",(function(){return n.SceneOptimization})),i.d(t,\"TextureOptimization\",(function(){return n.TextureOptimization})),i.d(t,\"HardwareScalingOptimization\",(function(){return n.HardwareScalingOptimization})),i.d(t,\"ShadowsOptimization\",(function(){return n.ShadowsOptimization})),i.d(t,\"PostProcessesOptimization\",(function(){return n.PostProcessesOptimization})),i.d(t,\"LensFlaresOptimization\",(function(){return n.LensFlaresOptimization})),i.d(t,\"CustomOptimization\",(function(){return n.CustomOptimization})),i.d(t,\"ParticlesOptimization\",(function(){return n.ParticlesOptimization})),i.d(t,\"RenderTargetsOptimization\",(function(){return n.RenderTargetsOptimization})),i.d(t,\"MergeMeshesOptimization\",(function(){return n.MergeMeshesOptimization})),i.d(t,\"SceneOptimizerOptions\",(function(){return n.SceneOptimizerOptions})),i.d(t,\"SceneOptimizer\",(function(){return n.SceneOptimizer})),i.d(t,\"SceneSerializer\",(function(){return n.SceneSerializer})),i.d(t,\"SmartArray\",(function(){return n.SmartArray})),i.d(t,\"SmartArrayNoDuplicate\",(function(){return n.SmartArrayNoDuplicate})),i.d(t,\"StringDictionary\",(function(){return n.StringDictionary})),i.d(t,\"Tags\",(function(){return n.Tags})),i.d(t,\"TextureTools\",(function(){return n.TextureTools})),i.d(t,\"TGATools\",(function(){return n.TGATools})),i.d(t,\"Tools\",(function(){return n.Tools})),i.d(t,\"className\",(function(){return n.className})),i.d(t,\"AsyncLoop\",(function(){return n.AsyncLoop})),i.d(t,\"VideoRecorder\",(function(){return n.VideoRecorder})),i.d(t,\"JoystickAxis\",(function(){return n.JoystickAxis})),i.d(t,\"VirtualJoystick\",(function(){return n.VirtualJoystick})),i.d(t,\"WorkerPool\",(function(){return n.WorkerPool})),i.d(t,\"Logger\",(function(){return n.Logger})),i.d(t,\"_TypeStore\",(function(){return n._TypeStore})),i.d(t,\"FilesInputStore\",(function(){return n.FilesInputStore})),i.d(t,\"DeepCopier\",(function(){return n.DeepCopier})),i.d(t,\"PivotTools\",(function(){return n.PivotTools})),i.d(t,\"PrecisionDate\",(function(){return n.PrecisionDate})),i.d(t,\"ScreenshotTools\",(function(){return n.ScreenshotTools})),i.d(t,\"WebRequest\",(function(){return n.WebRequest})),i.d(t,\"InspectableType\",(function(){return n.InspectableType})),i.d(t,\"BRDFTextureTools\",(function(){return n.BRDFTextureTools})),i.d(t,\"RGBDTextureTools\",(function(){return n.RGBDTextureTools})),i.d(t,\"ColorGradient\",(function(){return n.ColorGradient})),i.d(t,\"Color3Gradient\",(function(){return n.Color3Gradient})),i.d(t,\"FactorGradient\",(function(){return n.FactorGradient})),i.d(t,\"GradientHelper\",(function(){return n.GradientHelper})),i.d(t,\"PerfCounter\",(function(){return n.PerfCounter})),i.d(t,\"RetryStrategy\",(function(){return n.RetryStrategy})),i.d(t,\"CanvasGenerator\",(function(){return n.CanvasGenerator})),i.d(t,\"LoadFileError\",(function(){return n.LoadFileError})),i.d(t,\"RequestFileError\",(function(){return n.RequestFileError})),i.d(t,\"ReadFileError\",(function(){return n.ReadFileError})),i.d(t,\"FileTools\",(function(){return n.FileTools})),i.d(t,\"StringTools\",(function(){return n.StringTools})),i.d(t,\"DataReader\",(function(){return n.DataReader})),i.d(t,\"MinMaxReducer\",(function(){return n.MinMaxReducer})),i.d(t,\"DepthReducer\",(function(){return n.DepthReducer})),i.d(t,\"DataStorage\",(function(){return n.DataStorage})),i.d(t,\"SceneRecorder\",(function(){return n.SceneRecorder})),i.d(t,\"KhronosTextureContainer2\",(function(){return n.KhronosTextureContainer2})),i.d(t,\"Trajectory\",(function(){return n.Trajectory})),i.d(t,\"TrajectoryClassifier\",(function(){return n.TrajectoryClassifier})),i.d(t,\"TimerState\",(function(){return n.TimerState})),i.d(t,\"setAndStartTimer\",(function(){return n.setAndStartTimer})),i.d(t,\"AdvancedTimer\",(function(){return n.AdvancedTimer})),i.d(t,\"CopyTools\",(function(){return n.CopyTools})),i.d(t,\"WebXRCamera\",(function(){return n.WebXRCamera})),i.d(t,\"WebXREnterExitUIButton\",(function(){return n.WebXREnterExitUIButton})),i.d(t,\"WebXREnterExitUIOptions\",(function(){return n.WebXREnterExitUIOptions})),i.d(t,\"WebXREnterExitUI\",(function(){return n.WebXREnterExitUI})),i.d(t,\"WebXRExperienceHelper\",(function(){return n.WebXRExperienceHelper})),i.d(t,\"WebXRInput\",(function(){return n.WebXRInput})),i.d(t,\"WebXRInputSource\",(function(){return n.WebXRInputSource})),i.d(t,\"WebXRManagedOutputCanvasOptions\",(function(){return n.WebXRManagedOutputCanvasOptions})),i.d(t,\"WebXRManagedOutputCanvas\",(function(){return n.WebXRManagedOutputCanvas})),i.d(t,\"WebXRState\",(function(){return n.WebXRState})),i.d(t,\"WebXRTrackingState\",(function(){return n.WebXRTrackingState})),i.d(t,\"WebXRSessionManager\",(function(){return n.WebXRSessionManager})),i.d(t,\"WebXRDefaultExperienceOptions\",(function(){return n.WebXRDefaultExperienceOptions})),i.d(t,\"WebXRDefaultExperience\",(function(){return n.WebXRDefaultExperience})),i.d(t,\"WebXRFeatureName\",(function(){return n.WebXRFeatureName})),i.d(t,\"WebXRFeaturesManager\",(function(){return n.WebXRFeaturesManager})),i.d(t,\"WebXRAbstractFeature\",(function(){return n.WebXRAbstractFeature})),i.d(t,\"WebXRHitTestLegacy\",(function(){return n.WebXRHitTestLegacy})),i.d(t,\"WebXRAnchorSystem\",(function(){return n.WebXRAnchorSystem})),i.d(t,\"WebXRPlaneDetector\",(function(){return n.WebXRPlaneDetector})),i.d(t,\"WebXRBackgroundRemover\",(function(){return n.WebXRBackgroundRemover})),i.d(t,\"WebXRMotionControllerTeleportation\",(function(){return n.WebXRMotionControllerTeleportation})),i.d(t,\"WebXRControllerPointerSelection\",(function(){return n.WebXRControllerPointerSelection})),i.d(t,\"IWebXRControllerPhysicsOptions\",(function(){return n.IWebXRControllerPhysicsOptions})),i.d(t,\"WebXRControllerPhysics\",(function(){return n.WebXRControllerPhysics})),i.d(t,\"WebXRHitTest\",(function(){return n.WebXRHitTest})),i.d(t,\"WebXRFeaturePointSystem\",(function(){return n.WebXRFeaturePointSystem})),i.d(t,\"WebXRHand\",(function(){return n.WebXRHand})),i.d(t,\"WebXRHandTracking\",(function(){return n.WebXRHandTracking})),i.d(t,\"WebXRAbstractMotionController\",(function(){return n.WebXRAbstractMotionController})),i.d(t,\"WebXRControllerComponent\",(function(){return n.WebXRControllerComponent})),i.d(t,\"WebXRGenericTriggerMotionController\",(function(){return n.WebXRGenericTriggerMotionController})),i.d(t,\"WebXRMicrosoftMixedRealityController\",(function(){return n.WebXRMicrosoftMixedRealityController})),i.d(t,\"WebXRMotionControllerManager\",(function(){return n.WebXRMotionControllerManager})),i.d(t,\"WebXROculusTouchMotionController\",(function(){return n.WebXROculusTouchMotionController})),i.d(t,\"WebXRHTCViveMotionController\",(function(){return n.WebXRHTCViveMotionController})),i.d(t,\"WebXRProfiledMotionController\",(function(){return n.WebXRProfiledMotionController}));var o=void 0!==e?e:\"undefined\"!=typeof window?window:void 0;if(void 0!==o){o.BABYLON=a,o.BABYLON=o.BABYLON||{};var a=o.BABYLON;a.Debug=a.Debug||{};var s=[];for(var c in r)a.Debug[c]=r[c],s.push(c);for(var c in n)a[c]=n[c]}var l={AxesViewer:r.AxesViewer,BoneAxesViewer:r.BoneAxesViewer,PhysicsViewer:r.PhysicsViewer,SkeletonViewer:r.SkeletonViewer}}.call(this,i(159))}])}));","/*\n * Copyright (c) 2015 cannon.js Authors\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use, copy,\n * modify, merge, publish, distribute, sublicense, and/or sell copies\n * of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n!function(e){if(\"object\"==typeof exports&&\"undefined\"!=typeof module)module.exports=e();else if(\"function\"==typeof define&&false)define([],e);else{var f;\"undefined\"!=typeof window?f=window:\"undefined\"!=typeof global?f=global:\"undefined\"!=typeof self&&(f=self),f.CANNON=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error(\"Cannot find module '\"+o+\"'\")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o (http://steffe.se)\",\n \"keywords\": [\n \"cannon.js\",\n \"cannon\",\n \"physics\",\n \"engine\",\n \"3d\"\n ],\n \"main\": \"./build/cannon.js\",\n \"engines\": {\n \"node\": \"*\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/schteppe/cannon.js.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/schteppe/cannon.js/issues\"\n },\n \"licenses\": [\n {\n \"type\": \"MIT\"\n }\n ],\n \"devDependencies\": {\n \"jshint\": \"latest\",\n \"uglify-js\": \"latest\",\n \"nodeunit\": \"^0.9.0\",\n \"grunt\": \"~0.4.0\",\n \"grunt-contrib-jshint\": \"~0.1.1\",\n \"grunt-contrib-nodeunit\": \"^0.4.1\",\n \"grunt-contrib-concat\": \"~0.1.3\",\n \"grunt-contrib-uglify\": \"^0.5.1\",\n \"grunt-browserify\": \"^2.1.4\",\n \"grunt-contrib-yuidoc\": \"^0.5.2\",\n \"browserify\": \"*\"\n },\n \"dependencies\": {}\n}\n\n},{}],2:[function(_dereq_,module,exports){\n// Export classes\nmodule.exports = {\n version : _dereq_('../package.json').version,\n\n AABB : _dereq_('./collision/AABB'),\n ArrayCollisionMatrix : _dereq_('./collision/ArrayCollisionMatrix'),\n Body : _dereq_('./objects/Body'),\n Box : _dereq_('./shapes/Box'),\n Broadphase : _dereq_('./collision/Broadphase'),\n Constraint : _dereq_('./constraints/Constraint'),\n ContactEquation : _dereq_('./equations/ContactEquation'),\n Narrowphase : _dereq_('./world/Narrowphase'),\n ConeTwistConstraint : _dereq_('./constraints/ConeTwistConstraint'),\n ContactMaterial : _dereq_('./material/ContactMaterial'),\n ConvexPolyhedron : _dereq_('./shapes/ConvexPolyhedron'),\n Cylinder : _dereq_('./shapes/Cylinder'),\n DistanceConstraint : _dereq_('./constraints/DistanceConstraint'),\n Equation : _dereq_('./equations/Equation'),\n EventTarget : _dereq_('./utils/EventTarget'),\n FrictionEquation : _dereq_('./equations/FrictionEquation'),\n GSSolver : _dereq_('./solver/GSSolver'),\n GridBroadphase : _dereq_('./collision/GridBroadphase'),\n Heightfield : _dereq_('./shapes/Heightfield'),\n HingeConstraint : _dereq_('./constraints/HingeConstraint'),\n LockConstraint : _dereq_('./constraints/LockConstraint'),\n Mat3 : _dereq_('./math/Mat3'),\n Material : _dereq_('./material/Material'),\n NaiveBroadphase : _dereq_('./collision/NaiveBroadphase'),\n ObjectCollisionMatrix : _dereq_('./collision/ObjectCollisionMatrix'),\n Pool : _dereq_('./utils/Pool'),\n Particle : _dereq_('./shapes/Particle'),\n Plane : _dereq_('./shapes/Plane'),\n PointToPointConstraint : _dereq_('./constraints/PointToPointConstraint'),\n Quaternion : _dereq_('./math/Quaternion'),\n Ray : _dereq_('./collision/Ray'),\n RaycastVehicle : _dereq_('./objects/RaycastVehicle'),\n RaycastResult : _dereq_('./collision/RaycastResult'),\n RigidVehicle : _dereq_('./objects/RigidVehicle'),\n RotationalEquation : _dereq_('./equations/RotationalEquation'),\n RotationalMotorEquation : _dereq_('./equations/RotationalMotorEquation'),\n SAPBroadphase : _dereq_('./collision/SAPBroadphase'),\n SPHSystem : _dereq_('./objects/SPHSystem'),\n Shape : _dereq_('./shapes/Shape'),\n Solver : _dereq_('./solver/Solver'),\n Sphere : _dereq_('./shapes/Sphere'),\n SplitSolver : _dereq_('./solver/SplitSolver'),\n Spring : _dereq_('./objects/Spring'),\n Trimesh : _dereq_('./shapes/Trimesh'),\n Vec3 : _dereq_('./math/Vec3'),\n Vec3Pool : _dereq_('./utils/Vec3Pool'),\n World : _dereq_('./world/World'),\n};\n\n},{\"../package.json\":1,\"./collision/AABB\":3,\"./collision/ArrayCollisionMatrix\":4,\"./collision/Broadphase\":5,\"./collision/GridBroadphase\":6,\"./collision/NaiveBroadphase\":7,\"./collision/ObjectCollisionMatrix\":8,\"./collision/Ray\":9,\"./collision/RaycastResult\":10,\"./collision/SAPBroadphase\":11,\"./constraints/ConeTwistConstraint\":12,\"./constraints/Constraint\":13,\"./constraints/DistanceConstraint\":14,\"./constraints/HingeConstraint\":15,\"./constraints/LockConstraint\":16,\"./constraints/PointToPointConstraint\":17,\"./equations/ContactEquation\":19,\"./equations/Equation\":20,\"./equations/FrictionEquation\":21,\"./equations/RotationalEquation\":22,\"./equations/RotationalMotorEquation\":23,\"./material/ContactMaterial\":24,\"./material/Material\":25,\"./math/Mat3\":27,\"./math/Quaternion\":28,\"./math/Vec3\":30,\"./objects/Body\":31,\"./objects/RaycastVehicle\":32,\"./objects/RigidVehicle\":33,\"./objects/SPHSystem\":34,\"./objects/Spring\":35,\"./shapes/Box\":37,\"./shapes/ConvexPolyhedron\":38,\"./shapes/Cylinder\":39,\"./shapes/Heightfield\":40,\"./shapes/Particle\":41,\"./shapes/Plane\":42,\"./shapes/Shape\":43,\"./shapes/Sphere\":44,\"./shapes/Trimesh\":45,\"./solver/GSSolver\":46,\"./solver/Solver\":47,\"./solver/SplitSolver\":48,\"./utils/EventTarget\":49,\"./utils/Pool\":51,\"./utils/Vec3Pool\":54,\"./world/Narrowphase\":55,\"./world/World\":56}],3:[function(_dereq_,module,exports){\nvar Vec3 = _dereq_('../math/Vec3');\nvar Utils = _dereq_('../utils/Utils');\n\nmodule.exports = AABB;\n\n/**\n * Axis aligned bounding box class.\n * @class AABB\n * @constructor\n * @param {Object} [options]\n * @param {Vec3} [options.upperBound]\n * @param {Vec3} [options.lowerBound]\n */\nfunction AABB(options){\n options = options || {};\n\n /**\n * The lower bound of the bounding box.\n * @property lowerBound\n * @type {Vec3}\n */\n this.lowerBound = new Vec3();\n if(options.lowerBound){\n this.lowerBound.copy(options.lowerBound);\n }\n\n /**\n * The upper bound of the bounding box.\n * @property upperBound\n * @type {Vec3}\n */\n this.upperBound = new Vec3();\n if(options.upperBound){\n this.upperBound.copy(options.upperBound);\n }\n}\n\nvar tmp = new Vec3();\n\n/**\n * Set the AABB bounds from a set of points.\n * @method setFromPoints\n * @param {Array} points An array of Vec3's.\n * @param {Vec3} position\n * @param {Quaternion} quaternion\n * @param {number} skinSize\n * @return {AABB} The self object\n */\nAABB.prototype.setFromPoints = function(points, position, quaternion, skinSize){\n var l = this.lowerBound,\n u = this.upperBound,\n q = quaternion;\n\n // Set to the first point\n l.copy(points[0]);\n if(q){\n q.vmult(l, l);\n }\n u.copy(l);\n\n for(var i = 1; i u.x){ u.x = p.x; }\n if(p.x < l.x){ l.x = p.x; }\n if(p.y > u.y){ u.y = p.y; }\n if(p.y < l.y){ l.y = p.y; }\n if(p.z > u.z){ u.z = p.z; }\n if(p.z < l.z){ l.z = p.z; }\n }\n\n // Add offset\n if (position) {\n position.vadd(l, l);\n position.vadd(u, u);\n }\n\n if(skinSize){\n l.x -= skinSize;\n l.y -= skinSize;\n l.z -= skinSize;\n u.x += skinSize;\n u.y += skinSize;\n u.z += skinSize;\n }\n\n return this;\n};\n\n/**\n * Copy bounds from an AABB to this AABB\n * @method copy\n * @param {AABB} aabb Source to copy from\n * @return {AABB} The this object, for chainability\n */\nAABB.prototype.copy = function(aabb){\n this.lowerBound.copy(aabb.lowerBound);\n this.upperBound.copy(aabb.upperBound);\n return this;\n};\n\n/**\n * Clone an AABB\n * @method clone\n */\nAABB.prototype.clone = function(){\n return new AABB().copy(this);\n};\n\n/**\n * Extend this AABB so that it covers the given AABB too.\n * @method extend\n * @param {AABB} aabb\n */\nAABB.prototype.extend = function(aabb){\n // Extend lower bound\n var l = aabb.lowerBound.x;\n if(this.lowerBound.x > l){\n this.lowerBound.x = l;\n }\n\n // Upper\n var u = aabb.upperBound.x;\n if(this.upperBound.x < u){\n this.upperBound.x = u;\n }\n\n // Extend lower bound\n var l = aabb.lowerBound.y;\n if(this.lowerBound.y > l){\n this.lowerBound.y = l;\n }\n\n // Upper\n var u = aabb.upperBound.y;\n if(this.upperBound.y < u){\n this.upperBound.y = u;\n }\n\n // Extend lower bound\n var l = aabb.lowerBound.z;\n if(this.lowerBound.z > l){\n this.lowerBound.z = l;\n }\n\n // Upper\n var u = aabb.upperBound.z;\n if(this.upperBound.z < u){\n this.upperBound.z = u;\n }\n};\n\n/**\n * Returns true if the given AABB overlaps this AABB.\n * @method overlaps\n * @param {AABB} aabb\n * @return {Boolean}\n */\nAABB.prototype.overlaps = function(aabb){\n var l1 = this.lowerBound,\n u1 = this.upperBound,\n l2 = aabb.lowerBound,\n u2 = aabb.upperBound;\n\n // l2 u2\n // |---------|\n // |--------|\n // l1 u1\n\n return ((l2.x <= u1.x && u1.x <= u2.x) || (l1.x <= u2.x && u2.x <= u1.x)) &&\n ((l2.y <= u1.y && u1.y <= u2.y) || (l1.y <= u2.y && u2.y <= u1.y)) &&\n ((l2.z <= u1.z && u1.z <= u2.z) || (l1.z <= u2.z && u2.z <= u1.z));\n};\n\n/**\n * Returns true if the given AABB is fully contained in this AABB.\n * @method contains\n * @param {AABB} aabb\n * @return {Boolean}\n */\nAABB.prototype.contains = function(aabb){\n var l1 = this.lowerBound,\n u1 = this.upperBound,\n l2 = aabb.lowerBound,\n u2 = aabb.upperBound;\n\n // l2 u2\n // |---------|\n // |---------------|\n // l1 u1\n\n return (\n (l1.x <= l2.x && u1.x >= u2.x) &&\n (l1.y <= l2.y && u1.y >= u2.y) &&\n (l1.z <= l2.z && u1.z >= u2.z)\n );\n};\n\n/**\n * @method getCorners\n * @param {Vec3} a\n * @param {Vec3} b\n * @param {Vec3} c\n * @param {Vec3} d\n * @param {Vec3} e\n * @param {Vec3} f\n * @param {Vec3} g\n * @param {Vec3} h\n */\nAABB.prototype.getCorners = function(a, b, c, d, e, f, g, h){\n var l = this.lowerBound,\n u = this.upperBound;\n\n a.copy(l);\n b.set( u.x, l.y, l.z );\n c.set( u.x, u.y, l.z );\n d.set( l.x, u.y, u.z );\n e.set( u.x, l.y, l.z );\n f.set( l.x, u.y, l.z );\n g.set( l.x, l.y, u.z );\n h.copy(u);\n};\n\nvar transformIntoFrame_corners = [\n new Vec3(),\n new Vec3(),\n new Vec3(),\n new Vec3(),\n new Vec3(),\n new Vec3(),\n new Vec3(),\n new Vec3()\n];\n\n/**\n * Get the representation of an AABB in another frame.\n * @method toLocalFrame\n * @param {Transform} frame\n * @param {AABB} target\n * @return {AABB} The \"target\" AABB object.\n */\nAABB.prototype.toLocalFrame = function(frame, target){\n\n var corners = transformIntoFrame_corners;\n var a = corners[0];\n var b = corners[1];\n var c = corners[2];\n var d = corners[3];\n var e = corners[4];\n var f = corners[5];\n var g = corners[6];\n var h = corners[7];\n\n // Get corners in current frame\n this.getCorners(a, b, c, d, e, f, g, h);\n\n // Transform them to new local frame\n for(var i=0; i !== 8; i++){\n var corner = corners[i];\n frame.pointToLocal(corner, corner);\n }\n\n return target.setFromPoints(corners);\n};\n\n/**\n * Get the representation of an AABB in the global frame.\n * @method toWorldFrame\n * @param {Transform} frame\n * @param {AABB} target\n * @return {AABB} The \"target\" AABB object.\n */\nAABB.prototype.toWorldFrame = function(frame, target){\n\n var corners = transformIntoFrame_corners;\n var a = corners[0];\n var b = corners[1];\n var c = corners[2];\n var d = corners[3];\n var e = corners[4];\n var f = corners[5];\n var g = corners[6];\n var h = corners[7];\n\n // Get corners in current frame\n this.getCorners(a, b, c, d, e, f, g, h);\n\n // Transform them to new local frame\n for(var i=0; i !== 8; i++){\n var corner = corners[i];\n frame.pointToWorld(corner, corner);\n }\n\n return target.setFromPoints(corners);\n};\n\n},{\"../math/Vec3\":30,\"../utils/Utils\":53}],4:[function(_dereq_,module,exports){\nmodule.exports = ArrayCollisionMatrix;\n\n/**\n * Collision \"matrix\". It's actually a triangular-shaped array of whether two bodies are touching this step, for reference next step\n * @class ArrayCollisionMatrix\n * @constructor\n */\nfunction ArrayCollisionMatrix() {\n\n /**\n * The matrix storage\n * @property matrix\n * @type {Array}\n */\n\tthis.matrix = [];\n}\n\n/**\n * Get an element\n * @method get\n * @param {Number} i\n * @param {Number} j\n * @return {Number}\n */\nArrayCollisionMatrix.prototype.get = function(i, j) {\n\ti = i.index;\n\tj = j.index;\n if (j > i) {\n var temp = j;\n j = i;\n i = temp;\n }\n\treturn this.matrix[(i*(i + 1)>>1) + j-1];\n};\n\n/**\n * Set an element\n * @method set\n * @param {Number} i\n * @param {Number} j\n * @param {Number} value\n */\nArrayCollisionMatrix.prototype.set = function(i, j, value) {\n\ti = i.index;\n\tj = j.index;\n if (j > i) {\n var temp = j;\n j = i;\n i = temp;\n }\n\tthis.matrix[(i*(i + 1)>>1) + j-1] = value ? 1 : 0;\n};\n\n/**\n * Sets all elements to zero\n * @method reset\n */\nArrayCollisionMatrix.prototype.reset = function() {\n\tfor (var i=0, l=this.matrix.length; i!==l; i++) {\n\t\tthis.matrix[i]=0;\n\t}\n};\n\n/**\n * Sets the max number of objects\n * @method setNumObjects\n * @param {Number} n\n */\nArrayCollisionMatrix.prototype.setNumObjects = function(n) {\n\tthis.matrix.length = n*(n-1)>>1;\n};\n\n},{}],5:[function(_dereq_,module,exports){\nvar Body = _dereq_('../objects/Body');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Shape = _dereq_('../shapes/Shape');\nvar Plane = _dereq_('../shapes/Plane');\n\nmodule.exports = Broadphase;\n\n/**\n * Base class for broadphase implementations\n * @class Broadphase\n * @constructor\n * @author schteppe\n */\nfunction Broadphase(){\n /**\n * The world to search for collisions in.\n * @property world\n * @type {World}\n */\n this.world = null;\n\n /**\n * If set to true, the broadphase uses bounding boxes for intersection test, else it uses bounding spheres.\n * @property useBoundingBoxes\n * @type {Boolean}\n */\n this.useBoundingBoxes = false;\n\n /**\n * Set to true if the objects in the world moved.\n * @property {Boolean} dirty\n */\n this.dirty = true;\n}\n\n/**\n * Get the collision pairs from the world\n * @method collisionPairs\n * @param {World} world The world to search in\n * @param {Array} p1 Empty array to be filled with body objects\n * @param {Array} p2 Empty array to be filled with body objects\n */\nBroadphase.prototype.collisionPairs = function(world,p1,p2){\n throw new Error(\"collisionPairs not implemented for this BroadPhase class!\");\n};\n\n/**\n * Check if a body pair needs to be intersection tested at all.\n * @method needBroadphaseCollision\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @return {bool}\n */\nvar Broadphase_needBroadphaseCollision_STATIC_OR_KINEMATIC = Body.STATIC | Body.KINEMATIC;\nBroadphase.prototype.needBroadphaseCollision = function(bodyA,bodyB){\n\n // Check collision filter masks\n if( (bodyA.collisionFilterGroup & bodyB.collisionFilterMask)===0 || (bodyB.collisionFilterGroup & bodyA.collisionFilterMask)===0){\n return false;\n }\n\n // Check types\n if(((bodyA.type & Broadphase_needBroadphaseCollision_STATIC_OR_KINEMATIC)!==0 || bodyA.sleepState === Body.SLEEPING) &&\n ((bodyB.type & Broadphase_needBroadphaseCollision_STATIC_OR_KINEMATIC)!==0 || bodyB.sleepState === Body.SLEEPING)) {\n // Both bodies are static, kinematic or sleeping. Skip.\n return false;\n }\n\n return true;\n};\n\n/**\n * Check if the bounding volumes of two bodies intersect.\n * @method intersectionTest\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {array} pairs1\n * @param {array} pairs2\n */\nBroadphase.prototype.intersectionTest = function(bodyA, bodyB, pairs1, pairs2){\n if(this.useBoundingBoxes){\n this.doBoundingBoxBroadphase(bodyA,bodyB,pairs1,pairs2);\n } else {\n this.doBoundingSphereBroadphase(bodyA,bodyB,pairs1,pairs2);\n }\n};\n\n/**\n * Check if the bounding spheres of two bodies are intersecting.\n * @method doBoundingSphereBroadphase\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {Array} pairs1 bodyA is appended to this array if intersection\n * @param {Array} pairs2 bodyB is appended to this array if intersection\n */\nvar Broadphase_collisionPairs_r = new Vec3(), // Temp objects\n Broadphase_collisionPairs_normal = new Vec3(),\n Broadphase_collisionPairs_quat = new Quaternion(),\n Broadphase_collisionPairs_relpos = new Vec3();\nBroadphase.prototype.doBoundingSphereBroadphase = function(bodyA,bodyB,pairs1,pairs2){\n var r = Broadphase_collisionPairs_r;\n bodyB.position.vsub(bodyA.position,r);\n var boundingRadiusSum2 = Math.pow(bodyA.boundingRadius + bodyB.boundingRadius, 2);\n var norm2 = r.norm2();\n if(norm2 < boundingRadiusSum2){\n pairs1.push(bodyA);\n pairs2.push(bodyB);\n }\n};\n\n/**\n * Check if the bounding boxes of two bodies are intersecting.\n * @method doBoundingBoxBroadphase\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {Array} pairs1\n * @param {Array} pairs2\n */\nBroadphase.prototype.doBoundingBoxBroadphase = function(bodyA,bodyB,pairs1,pairs2){\n if(bodyA.aabbNeedsUpdate){\n bodyA.computeAABB();\n }\n if(bodyB.aabbNeedsUpdate){\n bodyB.computeAABB();\n }\n\n // Check AABB / AABB\n if(bodyA.aabb.overlaps(bodyB.aabb)){\n pairs1.push(bodyA);\n pairs2.push(bodyB);\n }\n};\n\n/**\n * Removes duplicate pairs from the pair arrays.\n * @method makePairsUnique\n * @param {Array} pairs1\n * @param {Array} pairs2\n */\nvar Broadphase_makePairsUnique_temp = { keys:[] },\n Broadphase_makePairsUnique_p1 = [],\n Broadphase_makePairsUnique_p2 = [];\nBroadphase.prototype.makePairsUnique = function(pairs1,pairs2){\n var t = Broadphase_makePairsUnique_temp,\n p1 = Broadphase_makePairsUnique_p1,\n p2 = Broadphase_makePairsUnique_p2,\n N = pairs1.length;\n\n for(var i=0; i!==N; i++){\n p1[i] = pairs1[i];\n p2[i] = pairs2[i];\n }\n\n pairs1.length = 0;\n pairs2.length = 0;\n\n for(var i=0; i!==N; i++){\n var id1 = p1[i].id,\n id2 = p2[i].id;\n var key = id1 < id2 ? id1+\",\"+id2 : id2+\",\"+id1;\n t[key] = i;\n t.keys.push(key);\n }\n\n for(var i=0; i!==t.keys.length; i++){\n var key = t.keys.pop(),\n pairIndex = t[key];\n pairs1.push(p1[pairIndex]);\n pairs2.push(p2[pairIndex]);\n delete t[key];\n }\n};\n\n/**\n * To be implemented by subcasses\n * @method setWorld\n * @param {World} world\n */\nBroadphase.prototype.setWorld = function(world){\n};\n\n/**\n * Check if the bounding spheres of two bodies overlap.\n * @method boundingSphereCheck\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @return {boolean}\n */\nvar bsc_dist = new Vec3();\nBroadphase.boundingSphereCheck = function(bodyA,bodyB){\n var dist = bsc_dist;\n bodyA.position.vsub(bodyB.position,dist);\n return Math.pow(bodyA.shape.boundingSphereRadius + bodyB.shape.boundingSphereRadius,2) > dist.norm2();\n};\n\n/**\n * Returns all the bodies within the AABB.\n * @method aabbQuery\n * @param {World} world\n * @param {AABB} aabb\n * @param {array} result An array to store resulting bodies in.\n * @return {array}\n */\nBroadphase.prototype.aabbQuery = function(world, aabb, result){\n console.warn('.aabbQuery is not implemented in this Broadphase subclass.');\n return [];\n};\n},{\"../math/Quaternion\":28,\"../math/Vec3\":30,\"../objects/Body\":31,\"../shapes/Plane\":42,\"../shapes/Shape\":43}],6:[function(_dereq_,module,exports){\nmodule.exports = GridBroadphase;\n\nvar Broadphase = _dereq_('./Broadphase');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Shape = _dereq_('../shapes/Shape');\n\n/**\n * Axis aligned uniform grid broadphase.\n * @class GridBroadphase\n * @constructor\n * @extends Broadphase\n * @todo Needs support for more than just planes and spheres.\n * @param {Vec3} aabbMin\n * @param {Vec3} aabbMax\n * @param {Number} nx Number of boxes along x\n * @param {Number} ny Number of boxes along y\n * @param {Number} nz Number of boxes along z\n */\nfunction GridBroadphase(aabbMin,aabbMax,nx,ny,nz){\n Broadphase.apply(this);\n this.nx = nx || 10;\n this.ny = ny || 10;\n this.nz = nz || 10;\n this.aabbMin = aabbMin || new Vec3(100,100,100);\n this.aabbMax = aabbMax || new Vec3(-100,-100,-100);\n\tvar nbins = this.nx * this.ny * this.nz;\n\tif (nbins <= 0) {\n\t\tthrow \"GridBroadphase: Each dimension's n must be >0\";\n\t}\n this.bins = [];\n\tthis.binLengths = []; //Rather than continually resizing arrays (thrashing the memory), just record length and allow them to grow\n\tthis.bins.length = nbins;\n\tthis.binLengths.length = nbins;\n\tfor (var i=0;i= nx) { xoff0 = nx - 1; }\n\t\tif (yoff0 < 0) { yoff0 = 0; } else if (yoff0 >= ny) { yoff0 = ny - 1; }\n\t\tif (zoff0 < 0) { zoff0 = 0; } else if (zoff0 >= nz) { zoff0 = nz - 1; }\n\t\tif (xoff1 < 0) { xoff1 = 0; } else if (xoff1 >= nx) { xoff1 = nx - 1; }\n\t\tif (yoff1 < 0) { yoff1 = 0; } else if (yoff1 >= ny) { yoff1 = ny - 1; }\n\t\tif (zoff1 < 0) { zoff1 = 0; } else if (zoff1 >= nz) { zoff1 = nz - 1; }\n\n\t\txoff0 *= xstep;\n\t\tyoff0 *= ystep;\n\t\tzoff0 *= zstep;\n\t\txoff1 *= xstep;\n\t\tyoff1 *= ystep;\n\t\tzoff1 *= zstep;\n\n\t\tfor (var xoff = xoff0; xoff <= xoff1; xoff += xstep) {\n\t\t\tfor (var yoff = yoff0; yoff <= yoff1; yoff += ystep) {\n\t\t\t\tfor (var zoff = zoff0; zoff <= zoff1; zoff += zstep) {\n\t\t\t\t\tvar idx = xoff+yoff+zoff;\n\t\t\t\t\tbins[idx][binLengths[idx]++] = bi;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n // Put all bodies into the bins\n for(var i=0; i!==N; i++){\n var bi = bodies[i];\n var si = bi.shape;\n\n switch(si.type){\n case SPHERE:\n // Put in bin\n // check if overlap with other bins\n var x = bi.position.x,\n y = bi.position.y,\n z = bi.position.z;\n var r = si.radius;\n\n\t\t\taddBoxToBins(x-r, y-r, z-r, x+r, y+r, z+r, bi);\n break;\n\n case PLANE:\n if(si.worldNormalNeedsUpdate){\n si.computeWorldNormal(bi.quaternion);\n }\n var planeNormal = si.worldNormal;\n\n\t\t\t//Relative position from origin of plane object to the first bin\n\t\t\t//Incremented as we iterate through the bins\n\t\t\tvar xreset = xmin + binsizeX*0.5 - bi.position.x,\n\t\t\t\tyreset = ymin + binsizeY*0.5 - bi.position.y,\n\t\t\t\tzreset = zmin + binsizeZ*0.5 - bi.position.z;\n\n var d = GridBroadphase_collisionPairs_d;\n\t\t\td.set(xreset, yreset, zreset);\n\n\t\t\tfor (var xi = 0, xoff = 0; xi !== nx; xi++, xoff += xstep, d.y = yreset, d.x += binsizeX) {\n\t\t\t\tfor (var yi = 0, yoff = 0; yi !== ny; yi++, yoff += ystep, d.z = zreset, d.y += binsizeY) {\n\t\t\t\t\tfor (var zi = 0, zoff = 0; zi !== nz; zi++, zoff += zstep, d.z += binsizeZ) {\n\t\t\t\t\t\tif (d.dot(planeNormal) < binRadius) {\n\t\t\t\t\t\t\tvar idx = xoff + yoff + zoff;\n\t\t\t\t\t\t\tbins[idx][binLengths[idx]++] = bi;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n break;\n\n default:\n\t\t\tif (bi.aabbNeedsUpdate) {\n\t\t\t\tbi.computeAABB();\n\t\t\t}\n\n\t\t\taddBoxToBins(\n\t\t\t\tbi.aabb.lowerBound.x,\n\t\t\t\tbi.aabb.lowerBound.y,\n\t\t\t\tbi.aabb.lowerBound.z,\n\t\t\t\tbi.aabb.upperBound.x,\n\t\t\t\tbi.aabb.upperBound.y,\n\t\t\t\tbi.aabb.upperBound.z,\n\t\t\t\tbi);\n break;\n }\n }\n\n // Check each bin\n for(var i=0; i!==Nbins; i++){\n\t\tvar binLength = binLengths[i];\n\t\t//Skip bins with no potential collisions\n\t\tif (binLength > 1) {\n\t\t\tvar bin = bins[i];\n\n\t\t\t// Do N^2 broadphase inside\n\t\t\tfor(var xi=0; xi!==binLength; xi++){\n\t\t\t\tvar bi = bin[xi];\n\t\t\t\tfor(var yi=0; yi!==xi; yi++){\n\t\t\t\t\tvar bj = bin[yi];\n\t\t\t\t\tif(this.needBroadphaseCollision(bi,bj)){\n\t\t\t\t\t\tthis.intersectionTest(bi,bj,pairs1,pairs2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n }\n\n//\tfor (var zi = 0, zoff=0; zi < nz; zi++, zoff+= zstep) {\n//\t\tconsole.log(\"layer \"+zi);\n//\t\tfor (var yi = 0, yoff=0; yi < ny; yi++, yoff += ystep) {\n//\t\t\tvar row = '';\n//\t\t\tfor (var xi = 0, xoff=0; xi < nx; xi++, xoff += xstep) {\n//\t\t\t\tvar idx = xoff + yoff + zoff;\n//\t\t\t\trow += ' ' + binLengths[idx];\n//\t\t\t}\n//\t\t\tconsole.log(row);\n//\t\t}\n//\t}\n\n this.makePairsUnique(pairs1,pairs2);\n};\n\n},{\"../math/Vec3\":30,\"../shapes/Shape\":43,\"./Broadphase\":5}],7:[function(_dereq_,module,exports){\nmodule.exports = NaiveBroadphase;\n\nvar Broadphase = _dereq_('./Broadphase');\nvar AABB = _dereq_('./AABB');\n\n/**\n * Naive broadphase implementation, used in lack of better ones.\n * @class NaiveBroadphase\n * @constructor\n * @description The naive broadphase looks at all possible pairs without restriction, therefore it has complexity N^2 (which is bad)\n * @extends Broadphase\n */\nfunction NaiveBroadphase(){\n Broadphase.apply(this);\n}\nNaiveBroadphase.prototype = new Broadphase();\nNaiveBroadphase.prototype.constructor = NaiveBroadphase;\n\n/**\n * Get all the collision pairs in the physics world\n * @method collisionPairs\n * @param {World} world\n * @param {Array} pairs1\n * @param {Array} pairs2\n */\nNaiveBroadphase.prototype.collisionPairs = function(world,pairs1,pairs2){\n var bodies = world.bodies,\n n = bodies.length,\n i,j,bi,bj;\n\n // Naive N^2 ftw!\n for(i=0; i!==n; i++){\n for(j=0; j!==i; j++){\n\n bi = bodies[i];\n bj = bodies[j];\n\n if(!this.needBroadphaseCollision(bi,bj)){\n continue;\n }\n\n this.intersectionTest(bi,bj,pairs1,pairs2);\n }\n }\n};\n\nvar tmpAABB = new AABB();\n\n/**\n * Returns all the bodies within an AABB.\n * @method aabbQuery\n * @param {World} world\n * @param {AABB} aabb\n * @param {array} result An array to store resulting bodies in.\n * @return {array}\n */\nNaiveBroadphase.prototype.aabbQuery = function(world, aabb, result){\n result = result || [];\n\n for(var i = 0; i < world.bodies.length; i++){\n var b = world.bodies[i];\n\n if(b.aabbNeedsUpdate){\n b.computeAABB();\n }\n\n // Ugly hack until Body gets aabb\n if(b.aabb.overlaps(aabb)){\n result.push(b);\n }\n }\n\n return result;\n};\n},{\"./AABB\":3,\"./Broadphase\":5}],8:[function(_dereq_,module,exports){\nmodule.exports = ObjectCollisionMatrix;\n\n/**\n * Records what objects are colliding with each other\n * @class ObjectCollisionMatrix\n * @constructor\n */\nfunction ObjectCollisionMatrix() {\n\n /**\n * The matrix storage\n * @property matrix\n * @type {Object}\n */\n\tthis.matrix = {};\n}\n\n/**\n * @method get\n * @param {Number} i\n * @param {Number} j\n * @return {Number}\n */\nObjectCollisionMatrix.prototype.get = function(i, j) {\n\ti = i.id;\n\tj = j.id;\n if (j > i) {\n var temp = j;\n j = i;\n i = temp;\n }\n\treturn i+'-'+j in this.matrix;\n};\n\n/**\n * @method set\n * @param {Number} i\n * @param {Number} j\n * @param {Number} value\n */\nObjectCollisionMatrix.prototype.set = function(i, j, value) {\n\ti = i.id;\n\tj = j.id;\n if (j > i) {\n var temp = j;\n j = i;\n i = temp;\n\t}\n\tif (value) {\n\t\tthis.matrix[i+'-'+j] = true;\n\t}\n\telse {\n\t\tdelete this.matrix[i+'-'+j];\n\t}\n};\n\n/**\n * Empty the matrix\n * @method reset\n */\nObjectCollisionMatrix.prototype.reset = function() {\n\tthis.matrix = {};\n};\n\n/**\n * Set max number of objects\n * @method setNumObjects\n * @param {Number} n\n */\nObjectCollisionMatrix.prototype.setNumObjects = function(n) {\n};\n\n},{}],9:[function(_dereq_,module,exports){\nmodule.exports = Ray;\n\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Transform = _dereq_('../math/Transform');\nvar ConvexPolyhedron = _dereq_('../shapes/ConvexPolyhedron');\nvar Box = _dereq_('../shapes/Box');\nvar RaycastResult = _dereq_('../collision/RaycastResult');\nvar Shape = _dereq_('../shapes/Shape');\nvar AABB = _dereq_('../collision/AABB');\n\n/**\n * A line in 3D space that intersects bodies and return points.\n * @class Ray\n * @constructor\n * @param {Vec3} from\n * @param {Vec3} to\n */\nfunction Ray(from, to){\n /**\n * @property {Vec3} from\n */\n this.from = from ? from.clone() : new Vec3();\n\n /**\n * @property {Vec3} to\n */\n this.to = to ? to.clone() : new Vec3();\n\n /**\n * @private\n * @property {Vec3} _direction\n */\n this._direction = new Vec3();\n\n /**\n * The precision of the ray. Used when checking parallelity etc.\n * @property {Number} precision\n */\n this.precision = 0.0001;\n\n /**\n * Set to true if you want the Ray to take .collisionResponse flags into account on bodies and shapes.\n * @property {Boolean} checkCollisionResponse\n */\n this.checkCollisionResponse = true;\n\n /**\n * If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.\n * @property {Boolean} skipBackfaces\n */\n this.skipBackfaces = false;\n\n /**\n * @property {number} collisionFilterMask\n * @default -1\n */\n this.collisionFilterMask = -1;\n\n /**\n * @property {number} collisionFilterGroup\n * @default -1\n */\n this.collisionFilterGroup = -1;\n\n /**\n * The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST.\n * @property {number} mode\n */\n this.mode = Ray.ANY;\n\n /**\n * Current result object.\n * @property {RaycastResult} result\n */\n this.result = new RaycastResult();\n\n /**\n * Will be set to true during intersectWorld() if the ray hit anything.\n * @property {Boolean} hasHit\n */\n this.hasHit = false;\n\n /**\n * Current, user-provided result callback. Will be used if mode is Ray.ALL.\n * @property {Function} callback\n */\n this.callback = function(result){};\n}\nRay.prototype.constructor = Ray;\n\nRay.CLOSEST = 1;\nRay.ANY = 2;\nRay.ALL = 4;\n\nvar tmpAABB = new AABB();\nvar tmpArray = [];\n\n/**\n * Do itersection against all bodies in the given World.\n * @method intersectWorld\n * @param {World} world\n * @param {object} options\n * @return {Boolean} True if the ray hit anything, otherwise false.\n */\nRay.prototype.intersectWorld = function (world, options) {\n this.mode = options.mode || Ray.ANY;\n this.result = options.result || new RaycastResult();\n this.skipBackfaces = !!options.skipBackfaces;\n this.collisionFilterMask = typeof(options.collisionFilterMask) !== 'undefined' ? options.collisionFilterMask : -1;\n this.collisionFilterGroup = typeof(options.collisionFilterGroup) !== 'undefined' ? options.collisionFilterGroup : -1;\n if(options.from){\n this.from.copy(options.from);\n }\n if(options.to){\n this.to.copy(options.to);\n }\n this.callback = options.callback || function(){};\n this.hasHit = false;\n\n this.result.reset();\n this._updateDirection();\n\n this.getAABB(tmpAABB);\n tmpArray.length = 0;\n world.broadphase.aabbQuery(world, tmpAABB, tmpArray);\n this.intersectBodies(tmpArray);\n\n return this.hasHit;\n};\n\nvar v1 = new Vec3(),\n v2 = new Vec3();\n\n/*\n * As per \"Barycentric Technique\" as named here http://www.blackpawn.com/texts/pointinpoly/default.html But without the division\n */\nRay.pointInTriangle = pointInTriangle;\nfunction pointInTriangle(p, a, b, c) {\n c.vsub(a,v0);\n b.vsub(a,v1);\n p.vsub(a,v2);\n\n var dot00 = v0.dot( v0 );\n var dot01 = v0.dot( v1 );\n var dot02 = v0.dot( v2 );\n var dot11 = v1.dot( v1 );\n var dot12 = v1.dot( v2 );\n\n var u,v;\n\n return ( (u = dot11 * dot02 - dot01 * dot12) >= 0 ) &&\n ( (v = dot00 * dot12 - dot01 * dot02) >= 0 ) &&\n ( u + v < ( dot00 * dot11 - dot01 * dot01 ) );\n}\n\n/**\n * Shoot a ray at a body, get back information about the hit.\n * @method intersectBody\n * @private\n * @param {Body} body\n * @param {RaycastResult} [result] Deprecated - set the result property of the Ray instead.\n */\nvar intersectBody_xi = new Vec3();\nvar intersectBody_qi = new Quaternion();\nRay.prototype.intersectBody = function (body, result) {\n if(result){\n this.result = result;\n this._updateDirection();\n }\n var checkCollisionResponse = this.checkCollisionResponse;\n\n if(checkCollisionResponse && !body.collisionResponse){\n return;\n }\n\n if((this.collisionFilterGroup & body.collisionFilterMask)===0 || (body.collisionFilterGroup & this.collisionFilterMask)===0){\n return;\n }\n\n var xi = intersectBody_xi;\n var qi = intersectBody_qi;\n\n for (var i = 0, N = body.shapes.length; i < N; i++) {\n var shape = body.shapes[i];\n\n if(checkCollisionResponse && !shape.collisionResponse){\n continue; // Skip\n }\n\n body.quaternion.mult(body.shapeOrientations[i], qi);\n body.quaternion.vmult(body.shapeOffsets[i], xi);\n xi.vadd(body.position, xi);\n\n this.intersectShape(\n shape,\n qi,\n xi,\n body\n );\n\n if(this.result._shouldStop){\n break;\n }\n }\n};\n\n/**\n * @method intersectBodies\n * @param {Array} bodies An array of Body objects.\n * @param {RaycastResult} [result] Deprecated\n */\nRay.prototype.intersectBodies = function (bodies, result) {\n if(result){\n this.result = result;\n this._updateDirection();\n }\n\n for ( var i = 0, l = bodies.length; !this.result._shouldStop && i < l; i ++ ) {\n this.intersectBody(bodies[i]);\n }\n};\n\n/**\n * Updates the _direction vector.\n * @private\n * @method _updateDirection\n */\nRay.prototype._updateDirection = function(){\n this.to.vsub(this.from, this._direction);\n this._direction.normalize();\n};\n\n/**\n * @method intersectShape\n * @private\n * @param {Shape} shape\n * @param {Quaternion} quat\n * @param {Vec3} position\n * @param {Body} body\n */\nRay.prototype.intersectShape = function(shape, quat, position, body){\n var from = this.from;\n\n\n // Checking boundingSphere\n var distance = distanceFromIntersection(from, this._direction, position);\n if ( distance > shape.boundingSphereRadius ) {\n return;\n }\n\n var intersectMethod = this[shape.type];\n if(intersectMethod){\n intersectMethod.call(this, shape, quat, position, body);\n }\n};\n\nvar vector = new Vec3();\nvar normal = new Vec3();\nvar intersectPoint = new Vec3();\n\nvar a = new Vec3();\nvar b = new Vec3();\nvar c = new Vec3();\nvar d = new Vec3();\n\nvar tmpRaycastResult = new RaycastResult();\n\n/**\n * @method intersectBox\n * @private\n * @param {Shape} shape\n * @param {Quaternion} quat\n * @param {Vec3} position\n * @param {Body} body\n */\nRay.prototype.intersectBox = function(shape, quat, position, body){\n return this.intersectConvex(shape.convexPolyhedronRepresentation, quat, position, body);\n};\nRay.prototype[Shape.types.BOX] = Ray.prototype.intersectBox;\n\n/**\n * @method intersectPlane\n * @private\n * @param {Shape} shape\n * @param {Quaternion} quat\n * @param {Vec3} position\n * @param {Body} body\n */\nRay.prototype.intersectPlane = function(shape, quat, position, body){\n var from = this.from;\n var to = this.to;\n var direction = this._direction;\n\n // Get plane normal\n var worldNormal = new Vec3(0, 0, 1);\n quat.vmult(worldNormal, worldNormal);\n\n var len = new Vec3();\n from.vsub(position, len);\n var planeToFrom = len.dot(worldNormal);\n to.vsub(position, len);\n var planeToTo = len.dot(worldNormal);\n\n if(planeToFrom * planeToTo > 0){\n // \"from\" and \"to\" are on the same side of the plane... bail out\n return;\n }\n\n if(from.distanceTo(to) < planeToFrom){\n return;\n }\n\n var n_dot_dir = worldNormal.dot(direction);\n\n if (Math.abs(n_dot_dir) < this.precision) {\n // No intersection\n return;\n }\n\n var planePointToFrom = new Vec3();\n var dir_scaled_with_t = new Vec3();\n var hitPointWorld = new Vec3();\n\n from.vsub(position, planePointToFrom);\n var t = -worldNormal.dot(planePointToFrom) / n_dot_dir;\n direction.scale(t, dir_scaled_with_t);\n from.vadd(dir_scaled_with_t, hitPointWorld);\n\n this.reportIntersection(worldNormal, hitPointWorld, shape, body, -1);\n};\nRay.prototype[Shape.types.PLANE] = Ray.prototype.intersectPlane;\n\n/**\n * Get the world AABB of the ray.\n * @method getAABB\n * @param {AABB} aabb\n */\nRay.prototype.getAABB = function(result){\n var to = this.to;\n var from = this.from;\n result.lowerBound.x = Math.min(to.x, from.x);\n result.lowerBound.y = Math.min(to.y, from.y);\n result.lowerBound.z = Math.min(to.z, from.z);\n result.upperBound.x = Math.max(to.x, from.x);\n result.upperBound.y = Math.max(to.y, from.y);\n result.upperBound.z = Math.max(to.z, from.z);\n};\n\nvar intersectConvexOptions = {\n faceList: [0]\n};\n\n/**\n * @method intersectHeightfield\n * @private\n * @param {Shape} shape\n * @param {Quaternion} quat\n * @param {Vec3} position\n * @param {Body} body\n */\nRay.prototype.intersectHeightfield = function(shape, quat, position, body){\n var data = shape.data,\n w = shape.elementSize,\n worldPillarOffset = new Vec3();\n\n // Convert the ray to local heightfield coordinates\n var localRay = new Ray(this.from, this.to);\n Transform.pointToLocalFrame(position, quat, localRay.from, localRay.from);\n Transform.pointToLocalFrame(position, quat, localRay.to, localRay.to);\n\n // Get the index of the data points to test against\n var index = [];\n var iMinX = null;\n var iMinY = null;\n var iMaxX = null;\n var iMaxY = null;\n\n var inside = shape.getIndexOfPosition(localRay.from.x, localRay.from.y, index, false);\n if(inside){\n iMinX = index[0];\n iMinY = index[1];\n iMaxX = index[0];\n iMaxY = index[1];\n }\n inside = shape.getIndexOfPosition(localRay.to.x, localRay.to.y, index, false);\n if(inside){\n if (iMinX === null || index[0] < iMinX) { iMinX = index[0]; }\n if (iMaxX === null || index[0] > iMaxX) { iMaxX = index[0]; }\n if (iMinY === null || index[1] < iMinY) { iMinY = index[1]; }\n if (iMaxY === null || index[1] > iMaxY) { iMaxY = index[1]; }\n }\n\n if(iMinX === null){\n return;\n }\n\n var minMax = [];\n shape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax);\n var min = minMax[0];\n var max = minMax[1];\n\n // // Bail out if the ray can't touch the bounding box\n // // TODO\n // var aabb = new AABB();\n // this.getAABB(aabb);\n // if(aabb.intersects()){\n // return;\n // }\n\n for(var i = iMinX; i <= iMaxX; i++){\n for(var j = iMinY; j <= iMaxY; j++){\n\n if(this.result._shouldStop){\n return;\n }\n\n // Lower triangle\n shape.getConvexTrianglePillar(i, j, false);\n Transform.pointToWorldFrame(position, quat, shape.pillarOffset, worldPillarOffset);\n this.intersectConvex(shape.pillarConvex, quat, worldPillarOffset, body, intersectConvexOptions);\n\n if(this.result._shouldStop){\n return;\n }\n\n // Upper triangle\n shape.getConvexTrianglePillar(i, j, true);\n Transform.pointToWorldFrame(position, quat, shape.pillarOffset, worldPillarOffset);\n this.intersectConvex(shape.pillarConvex, quat, worldPillarOffset, body, intersectConvexOptions);\n }\n }\n};\nRay.prototype[Shape.types.HEIGHTFIELD] = Ray.prototype.intersectHeightfield;\n\nvar Ray_intersectSphere_intersectionPoint = new Vec3();\nvar Ray_intersectSphere_normal = new Vec3();\n\n/**\n * @method intersectSphere\n * @private\n * @param {Shape} shape\n * @param {Quaternion} quat\n * @param {Vec3} position\n * @param {Body} body\n */\nRay.prototype.intersectSphere = function(shape, quat, position, body){\n var from = this.from,\n to = this.to,\n r = shape.radius;\n\n var a = Math.pow(to.x - from.x, 2) + Math.pow(to.y - from.y, 2) + Math.pow(to.z - from.z, 2);\n var b = 2 * ((to.x - from.x) * (from.x - position.x) + (to.y - from.y) * (from.y - position.y) + (to.z - from.z) * (from.z - position.z));\n var c = Math.pow(from.x - position.x, 2) + Math.pow(from.y - position.y, 2) + Math.pow(from.z - position.z, 2) - Math.pow(r, 2);\n\n var delta = Math.pow(b, 2) - 4 * a * c;\n\n var intersectionPoint = Ray_intersectSphere_intersectionPoint;\n var normal = Ray_intersectSphere_normal;\n\n if(delta < 0){\n // No intersection\n return;\n\n } else if(delta === 0){\n // single intersection point\n from.lerp(to, delta, intersectionPoint);\n\n intersectionPoint.vsub(position, normal);\n normal.normalize();\n\n this.reportIntersection(normal, intersectionPoint, shape, body, -1);\n\n } else {\n var d1 = (- b - Math.sqrt(delta)) / (2 * a);\n var d2 = (- b + Math.sqrt(delta)) / (2 * a);\n\n if(d1 >= 0 && d1 <= 1){\n from.lerp(to, d1, intersectionPoint);\n intersectionPoint.vsub(position, normal);\n normal.normalize();\n this.reportIntersection(normal, intersectionPoint, shape, body, -1);\n }\n\n if(this.result._shouldStop){\n return;\n }\n\n if(d2 >= 0 && d2 <= 1){\n from.lerp(to, d2, intersectionPoint);\n intersectionPoint.vsub(position, normal);\n normal.normalize();\n this.reportIntersection(normal, intersectionPoint, shape, body, -1);\n }\n }\n};\nRay.prototype[Shape.types.SPHERE] = Ray.prototype.intersectSphere;\n\n\nvar intersectConvex_normal = new Vec3();\nvar intersectConvex_minDistNormal = new Vec3();\nvar intersectConvex_minDistIntersect = new Vec3();\nvar intersectConvex_vector = new Vec3();\n\n/**\n * @method intersectConvex\n * @private\n * @param {Shape} shape\n * @param {Quaternion} quat\n * @param {Vec3} position\n * @param {Body} body\n * @param {object} [options]\n * @param {array} [options.faceList]\n */\nRay.prototype.intersectConvex = function intersectConvex(\n shape,\n quat,\n position,\n body,\n options\n){\n var minDistNormal = intersectConvex_minDistNormal;\n var normal = intersectConvex_normal;\n var vector = intersectConvex_vector;\n var minDistIntersect = intersectConvex_minDistIntersect;\n var faceList = (options && options.faceList) || null;\n\n // Checking faces\n var faces = shape.faces,\n vertices = shape.vertices,\n normals = shape.faceNormals;\n var direction = this._direction;\n\n var from = this.from;\n var to = this.to;\n var fromToDistance = from.distanceTo(to);\n\n var minDist = -1;\n var Nfaces = faceList ? faceList.length : faces.length;\n var result = this.result;\n\n for (var j = 0; !result._shouldStop && j < Nfaces; j++) {\n var fi = faceList ? faceList[j] : j;\n\n var face = faces[fi];\n var faceNormal = normals[fi];\n var q = quat;\n var x = position;\n\n // determine if ray intersects the plane of the face\n // note: this works regardless of the direction of the face normal\n\n // Get plane point in world coordinates...\n vector.copy(vertices[face[0]]);\n q.vmult(vector,vector);\n vector.vadd(x,vector);\n\n // ...but make it relative to the ray from. We'll fix this later.\n vector.vsub(from,vector);\n\n // Get plane normal\n q.vmult(faceNormal,normal);\n\n // If this dot product is negative, we have something interesting\n var dot = direction.dot(normal);\n\n // Bail out if ray and plane are parallel\n if ( Math.abs( dot ) < this.precision ){\n continue;\n }\n\n // calc distance to plane\n var scalar = normal.dot(vector) / dot;\n\n // if negative distance, then plane is behind ray\n if (scalar < 0){\n continue;\n }\n\n // if (dot < 0) {\n\n // Intersection point is from + direction * scalar\n direction.mult(scalar,intersectPoint);\n intersectPoint.vadd(from,intersectPoint);\n\n // a is the point we compare points b and c with.\n a.copy(vertices[face[0]]);\n q.vmult(a,a);\n x.vadd(a,a);\n\n for(var i = 1; !result._shouldStop && i < face.length - 1; i++){\n // Transform 3 vertices to world coords\n b.copy(vertices[face[i]]);\n c.copy(vertices[face[i+1]]);\n q.vmult(b,b);\n q.vmult(c,c);\n x.vadd(b,b);\n x.vadd(c,c);\n\n var distance = intersectPoint.distanceTo(from);\n\n if(!(pointInTriangle(intersectPoint, a, b, c) || pointInTriangle(intersectPoint, b, a, c)) || distance > fromToDistance){\n continue;\n }\n\n this.reportIntersection(normal, intersectPoint, shape, body, fi);\n }\n // }\n }\n};\nRay.prototype[Shape.types.CONVEXPOLYHEDRON] = Ray.prototype.intersectConvex;\n\nvar intersectTrimesh_normal = new Vec3();\nvar intersectTrimesh_localDirection = new Vec3();\nvar intersectTrimesh_localFrom = new Vec3();\nvar intersectTrimesh_localTo = new Vec3();\nvar intersectTrimesh_worldNormal = new Vec3();\nvar intersectTrimesh_worldIntersectPoint = new Vec3();\nvar intersectTrimesh_localAABB = new AABB();\nvar intersectTrimesh_triangles = [];\nvar intersectTrimesh_treeTransform = new Transform();\n\n/**\n * @method intersectTrimesh\n * @private\n * @param {Shape} shape\n * @param {Quaternion} quat\n * @param {Vec3} position\n * @param {Body} body\n * @param {object} [options]\n * @todo Optimize by transforming the world to local space first.\n * @todo Use Octree lookup\n */\nRay.prototype.intersectTrimesh = function intersectTrimesh(\n mesh,\n quat,\n position,\n body,\n options\n){\n var normal = intersectTrimesh_normal;\n var triangles = intersectTrimesh_triangles;\n var treeTransform = intersectTrimesh_treeTransform;\n var minDistNormal = intersectConvex_minDistNormal;\n var vector = intersectConvex_vector;\n var minDistIntersect = intersectConvex_minDistIntersect;\n var localAABB = intersectTrimesh_localAABB;\n var localDirection = intersectTrimesh_localDirection;\n var localFrom = intersectTrimesh_localFrom;\n var localTo = intersectTrimesh_localTo;\n var worldIntersectPoint = intersectTrimesh_worldIntersectPoint;\n var worldNormal = intersectTrimesh_worldNormal;\n var faceList = (options && options.faceList) || null;\n\n // Checking faces\n var indices = mesh.indices,\n vertices = mesh.vertices,\n normals = mesh.faceNormals;\n\n var from = this.from;\n var to = this.to;\n var direction = this._direction;\n\n var minDist = -1;\n treeTransform.position.copy(position);\n treeTransform.quaternion.copy(quat);\n\n // Transform ray to local space!\n Transform.vectorToLocalFrame(position, quat, direction, localDirection);\n //body.vectorToLocalFrame(direction, localDirection);\n Transform.pointToLocalFrame(position, quat, from, localFrom);\n //body.pointToLocalFrame(from, localFrom);\n Transform.pointToLocalFrame(position, quat, to, localTo);\n //body.pointToLocalFrame(to, localTo);\n var fromToDistanceSquared = localFrom.distanceSquared(localTo);\n\n mesh.tree.rayQuery(this, treeTransform, triangles);\n\n for (var i = 0, N = triangles.length; !this.result._shouldStop && i !== N; i++) {\n var trianglesIndex = triangles[i];\n\n mesh.getNormal(trianglesIndex, normal);\n\n // determine if ray intersects the plane of the face\n // note: this works regardless of the direction of the face normal\n\n // Get plane point in world coordinates...\n mesh.getVertex(indices[trianglesIndex * 3], a);\n\n // ...but make it relative to the ray from. We'll fix this later.\n a.vsub(localFrom,vector);\n\n // Get plane normal\n // quat.vmult(normal, normal);\n\n // If this dot product is negative, we have something interesting\n var dot = localDirection.dot(normal);\n\n // Bail out if ray and plane are parallel\n // if (Math.abs( dot ) < this.precision){\n // continue;\n // }\n\n // calc distance to plane\n var scalar = normal.dot(vector) / dot;\n\n // if negative distance, then plane is behind ray\n if (scalar < 0){\n continue;\n }\n\n // Intersection point is from + direction * scalar\n localDirection.scale(scalar,intersectPoint);\n intersectPoint.vadd(localFrom,intersectPoint);\n\n // Get triangle vertices\n mesh.getVertex(indices[trianglesIndex * 3 + 1], b);\n mesh.getVertex(indices[trianglesIndex * 3 + 2], c);\n\n var squaredDistance = intersectPoint.distanceSquared(localFrom);\n\n if(!(pointInTriangle(intersectPoint, b, a, c) || pointInTriangle(intersectPoint, a, b, c)) || squaredDistance > fromToDistanceSquared){\n continue;\n }\n\n // transform intersectpoint and normal to world\n Transform.vectorToWorldFrame(quat, normal, worldNormal);\n //body.vectorToWorldFrame(normal, worldNormal);\n Transform.pointToWorldFrame(position, quat, intersectPoint, worldIntersectPoint);\n //body.pointToWorldFrame(intersectPoint, worldIntersectPoint);\n this.reportIntersection(worldNormal, worldIntersectPoint, mesh, body, trianglesIndex);\n }\n triangles.length = 0;\n};\nRay.prototype[Shape.types.TRIMESH] = Ray.prototype.intersectTrimesh;\n\n\n/**\n * @method reportIntersection\n * @private\n * @param {Vec3} normal\n * @param {Vec3} hitPointWorld\n * @param {Shape} shape\n * @param {Body} body\n * @return {boolean} True if the intersections should continue\n */\nRay.prototype.reportIntersection = function(normal, hitPointWorld, shape, body, hitFaceIndex){\n var from = this.from;\n var to = this.to;\n var distance = from.distanceTo(hitPointWorld);\n var result = this.result;\n\n // Skip back faces?\n if(this.skipBackfaces && normal.dot(this._direction) > 0){\n return;\n }\n\n result.hitFaceIndex = typeof(hitFaceIndex) !== 'undefined' ? hitFaceIndex : -1;\n\n switch(this.mode){\n case Ray.ALL:\n this.hasHit = true;\n result.set(\n from,\n to,\n normal,\n hitPointWorld,\n shape,\n body,\n distance\n );\n result.hasHit = true;\n this.callback(result);\n break;\n\n case Ray.CLOSEST:\n\n // Store if closer than current closest\n if(distance < result.distance || !result.hasHit){\n this.hasHit = true;\n result.hasHit = true;\n result.set(\n from,\n to,\n normal,\n hitPointWorld,\n shape,\n body,\n distance\n );\n }\n break;\n\n case Ray.ANY:\n\n // Report and stop.\n this.hasHit = true;\n result.hasHit = true;\n result.set(\n from,\n to,\n normal,\n hitPointWorld,\n shape,\n body,\n distance\n );\n result._shouldStop = true;\n break;\n }\n};\n\nvar v0 = new Vec3(),\n intersect = new Vec3();\nfunction distanceFromIntersection(from, direction, position) {\n\n // v0 is vector from from to position\n position.vsub(from,v0);\n var dot = v0.dot(direction);\n\n // intersect = direction*dot + from\n direction.mult(dot,intersect);\n intersect.vadd(from,intersect);\n\n var distance = position.distanceTo(intersect);\n\n return distance;\n}\n\n\n},{\"../collision/AABB\":3,\"../collision/RaycastResult\":10,\"../math/Quaternion\":28,\"../math/Transform\":29,\"../math/Vec3\":30,\"../shapes/Box\":37,\"../shapes/ConvexPolyhedron\":38,\"../shapes/Shape\":43}],10:[function(_dereq_,module,exports){\nvar Vec3 = _dereq_('../math/Vec3');\n\nmodule.exports = RaycastResult;\n\n/**\n * Storage for Ray casting data.\n * @class RaycastResult\n * @constructor\n */\nfunction RaycastResult(){\n\n\t/**\n\t * @property {Vec3} rayFromWorld\n\t */\n\tthis.rayFromWorld = new Vec3();\n\n\t/**\n\t * @property {Vec3} rayToWorld\n\t */\n\tthis.rayToWorld = new Vec3();\n\n\t/**\n\t * @property {Vec3} hitNormalWorld\n\t */\n\tthis.hitNormalWorld = new Vec3();\n\n\t/**\n\t * @property {Vec3} hitPointWorld\n\t */\n\tthis.hitPointWorld = new Vec3();\n\n\t/**\n\t * @property {boolean} hasHit\n\t */\n\tthis.hasHit = false;\n\n\t/**\n\t * The hit shape, or null.\n\t * @property {Shape} shape\n\t */\n\tthis.shape = null;\n\n\t/**\n\t * The hit body, or null.\n\t * @property {Body} body\n\t */\n\tthis.body = null;\n\n\t/**\n\t * The index of the hit triangle, if the hit shape was a trimesh.\n\t * @property {number} hitFaceIndex\n\t * @default -1\n\t */\n\tthis.hitFaceIndex = -1;\n\n\t/**\n\t * Distance to the hit. Will be set to -1 if there was no hit.\n\t * @property {number} distance\n\t * @default -1\n\t */\n\tthis.distance = -1;\n\n\t/**\n\t * If the ray should stop traversing the bodies.\n\t * @private\n\t * @property {Boolean} _shouldStop\n\t * @default false\n\t */\n\tthis._shouldStop = false;\n}\n\n/**\n * Reset all result data.\n * @method reset\n */\nRaycastResult.prototype.reset = function () {\n\tthis.rayFromWorld.setZero();\n\tthis.rayToWorld.setZero();\n\tthis.hitNormalWorld.setZero();\n\tthis.hitPointWorld.setZero();\n\tthis.hasHit = false;\n\tthis.shape = null;\n\tthis.body = null;\n\tthis.hitFaceIndex = -1;\n\tthis.distance = -1;\n\tthis._shouldStop = false;\n};\n\n/**\n * @method abort\n */\nRaycastResult.prototype.abort = function(){\n\tthis._shouldStop = true;\n};\n\n/**\n * @method set\n * @param {Vec3} rayFromWorld\n * @param {Vec3} rayToWorld\n * @param {Vec3} hitNormalWorld\n * @param {Vec3} hitPointWorld\n * @param {Shape} shape\n * @param {Body} body\n * @param {number} distance\n */\nRaycastResult.prototype.set = function(\n\trayFromWorld,\n\trayToWorld,\n\thitNormalWorld,\n\thitPointWorld,\n\tshape,\n\tbody,\n\tdistance\n){\n\tthis.rayFromWorld.copy(rayFromWorld);\n\tthis.rayToWorld.copy(rayToWorld);\n\tthis.hitNormalWorld.copy(hitNormalWorld);\n\tthis.hitPointWorld.copy(hitPointWorld);\n\tthis.shape = shape;\n\tthis.body = body;\n\tthis.distance = distance;\n};\n},{\"../math/Vec3\":30}],11:[function(_dereq_,module,exports){\nvar Shape = _dereq_('../shapes/Shape');\nvar Broadphase = _dereq_('../collision/Broadphase');\n\nmodule.exports = SAPBroadphase;\n\n/**\n * Sweep and prune broadphase along one axis.\n *\n * @class SAPBroadphase\n * @constructor\n * @param {World} [world]\n * @extends Broadphase\n */\nfunction SAPBroadphase(world){\n Broadphase.apply(this);\n\n /**\n * List of bodies currently in the broadphase.\n * @property axisList\n * @type {Array}\n */\n this.axisList = [];\n\n /**\n * The world to search in.\n * @property world\n * @type {World}\n */\n this.world = null;\n\n /**\n * Axis to sort the bodies along. Set to 0 for x axis, and 1 for y axis. For best performance, choose an axis that the bodies are spread out more on.\n * @property axisIndex\n * @type {Number}\n */\n this.axisIndex = 0;\n\n var axisList = this.axisList;\n\n this._addBodyHandler = function(e){\n axisList.push(e.body);\n };\n\n this._removeBodyHandler = function(e){\n var idx = axisList.indexOf(e.body);\n if(idx !== -1){\n axisList.splice(idx,1);\n }\n };\n\n if(world){\n this.setWorld(world);\n }\n}\nSAPBroadphase.prototype = new Broadphase();\n\n/**\n * Change the world\n * @method setWorld\n * @param {World} world\n */\nSAPBroadphase.prototype.setWorld = function(world){\n // Clear the old axis array\n this.axisList.length = 0;\n\n // Add all bodies from the new world\n for(var i=0; i=0;j--) {\n if(a[j].aabb.lowerBound.x <= v.aabb.lowerBound.x){\n break;\n }\n a[j+1] = a[j];\n }\n a[j+1] = v;\n }\n return a;\n};\n\n/**\n * @static\n * @method insertionSortY\n * @param {Array} a\n * @return {Array}\n */\nSAPBroadphase.insertionSortY = function(a) {\n for(var i=1,l=a.length;i=0;j--) {\n if(a[j].aabb.lowerBound.y <= v.aabb.lowerBound.y){\n break;\n }\n a[j+1] = a[j];\n }\n a[j+1] = v;\n }\n return a;\n};\n\n/**\n * @static\n * @method insertionSortZ\n * @param {Array} a\n * @return {Array}\n */\nSAPBroadphase.insertionSortZ = function(a) {\n for(var i=1,l=a.length;i=0;j--) {\n if(a[j].aabb.lowerBound.z <= v.aabb.lowerBound.z){\n break;\n }\n a[j+1] = a[j];\n }\n a[j+1] = v;\n }\n return a;\n};\n\n/**\n * Collect all collision pairs\n * @method collisionPairs\n * @param {World} world\n * @param {Array} p1\n * @param {Array} p2\n */\nSAPBroadphase.prototype.collisionPairs = function(world,p1,p2){\n var bodies = this.axisList,\n N = bodies.length,\n axisIndex = this.axisIndex,\n i, j;\n\n if(this.dirty){\n this.sortList();\n this.dirty = false;\n }\n\n // Look through the list\n for(i=0; i !== N; i++){\n var bi = bodies[i];\n\n for(j=i+1; j < N; j++){\n var bj = bodies[j];\n\n if(!this.needBroadphaseCollision(bi,bj)){\n continue;\n }\n\n if(!SAPBroadphase.checkBounds(bi,bj,axisIndex)){\n break;\n }\n\n this.intersectionTest(bi,bj,p1,p2);\n }\n }\n};\n\nSAPBroadphase.prototype.sortList = function(){\n var axisList = this.axisList;\n var axisIndex = this.axisIndex;\n var N = axisList.length;\n\n // Update AABBs\n for(var i = 0; i!==N; i++){\n var bi = axisList[i];\n if(bi.aabbNeedsUpdate){\n bi.computeAABB();\n }\n }\n\n // Sort the list\n if(axisIndex === 0){\n SAPBroadphase.insertionSortX(axisList);\n } else if(axisIndex === 1){\n SAPBroadphase.insertionSortY(axisList);\n } else if(axisIndex === 2){\n SAPBroadphase.insertionSortZ(axisList);\n }\n};\n\n/**\n * Check if the bounds of two bodies overlap, along the given SAP axis.\n * @static\n * @method checkBounds\n * @param {Body} bi\n * @param {Body} bj\n * @param {Number} axisIndex\n * @return {Boolean}\n */\nSAPBroadphase.checkBounds = function(bi, bj, axisIndex){\n var biPos;\n var bjPos;\n\n if(axisIndex === 0){\n biPos = bi.position.x;\n bjPos = bj.position.x;\n } else if(axisIndex === 1){\n biPos = bi.position.y;\n bjPos = bj.position.y;\n } else if(axisIndex === 2){\n biPos = bi.position.z;\n bjPos = bj.position.z;\n }\n\n var ri = bi.boundingRadius,\n rj = bj.boundingRadius,\n boundA1 = biPos - ri,\n boundA2 = biPos + ri,\n boundB1 = bjPos - rj,\n boundB2 = bjPos + rj;\n\n return boundB1 < boundA2;\n};\n\n/**\n * Computes the variance of the body positions and estimates the best\n * axis to use. Will automatically set property .axisIndex.\n * @method autoDetectAxis\n */\nSAPBroadphase.prototype.autoDetectAxis = function(){\n var sumX=0,\n sumX2=0,\n sumY=0,\n sumY2=0,\n sumZ=0,\n sumZ2=0,\n bodies = this.axisList,\n N = bodies.length,\n invN=1/N;\n\n for(var i=0; i!==N; i++){\n var b = bodies[i];\n\n var centerX = b.position.x;\n sumX += centerX;\n sumX2 += centerX*centerX;\n\n var centerY = b.position.y;\n sumY += centerY;\n sumY2 += centerY*centerY;\n\n var centerZ = b.position.z;\n sumZ += centerZ;\n sumZ2 += centerZ*centerZ;\n }\n\n var varianceX = sumX2 - sumX*sumX*invN,\n varianceY = sumY2 - sumY*sumY*invN,\n varianceZ = sumZ2 - sumZ*sumZ*invN;\n\n if(varianceX > varianceY){\n if(varianceX > varianceZ){\n this.axisIndex = 0;\n } else{\n this.axisIndex = 2;\n }\n } else if(varianceY > varianceZ){\n this.axisIndex = 1;\n } else{\n this.axisIndex = 2;\n }\n};\n\n/**\n * Returns all the bodies within an AABB.\n * @method aabbQuery\n * @param {World} world\n * @param {AABB} aabb\n * @param {array} result An array to store resulting bodies in.\n * @return {array}\n */\nSAPBroadphase.prototype.aabbQuery = function(world, aabb, result){\n result = result || [];\n\n if(this.dirty){\n this.sortList();\n this.dirty = false;\n }\n\n var axisIndex = this.axisIndex, axis = 'x';\n if(axisIndex === 1){ axis = 'y'; }\n if(axisIndex === 2){ axis = 'z'; }\n\n var axisList = this.axisList;\n var lower = aabb.lowerBound[axis];\n var upper = aabb.upperBound[axis];\n for(var i = 0; i < axisList.length; i++){\n var b = axisList[i];\n\n if(b.aabbNeedsUpdate){\n b.computeAABB();\n }\n\n if(b.aabb.overlaps(aabb)){\n result.push(b);\n }\n }\n\n return result;\n};\n},{\"../collision/Broadphase\":5,\"../shapes/Shape\":43}],12:[function(_dereq_,module,exports){\nmodule.exports = ConeTwistConstraint;\n\nvar Constraint = _dereq_('./Constraint');\nvar PointToPointConstraint = _dereq_('./PointToPointConstraint');\nvar ConeEquation = _dereq_('../equations/ConeEquation');\nvar RotationalEquation = _dereq_('../equations/RotationalEquation');\nvar ContactEquation = _dereq_('../equations/ContactEquation');\nvar Vec3 = _dereq_('../math/Vec3');\n\n/**\n * @class ConeTwistConstraint\n * @constructor\n * @author schteppe\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {object} [options]\n * @param {Vec3} [options.pivotA]\n * @param {Vec3} [options.pivotB]\n * @param {Vec3} [options.axisA]\n * @param {Vec3} [options.axisB]\n * @param {Number} [options.maxForce=1e6]\n * @extends PointToPointConstraint\n */\nfunction ConeTwistConstraint(bodyA, bodyB, options){\n options = options || {};\n var maxForce = typeof(options.maxForce) !== 'undefined' ? options.maxForce : 1e6;\n\n // Set pivot point in between\n var pivotA = options.pivotA ? options.pivotA.clone() : new Vec3();\n var pivotB = options.pivotB ? options.pivotB.clone() : new Vec3();\n this.axisA = options.axisA ? options.axisA.clone() : new Vec3();\n this.axisB = options.axisB ? options.axisB.clone() : new Vec3();\n\n PointToPointConstraint.call(this, bodyA, pivotA, bodyB, pivotB, maxForce);\n\n this.collideConnected = !!options.collideConnected;\n\n this.angle = typeof(options.angle) !== 'undefined' ? options.angle : 0;\n\n /**\n * @property {ConeEquation} coneEquation\n */\n var c = this.coneEquation = new ConeEquation(bodyA,bodyB,options);\n\n /**\n * @property {RotationalEquation} twistEquation\n */\n var t = this.twistEquation = new RotationalEquation(bodyA,bodyB,options);\n this.twistAngle = typeof(options.twistAngle) !== 'undefined' ? options.twistAngle : 0;\n\n // Make the cone equation push the bodies toward the cone axis, not outward\n c.maxForce = 0;\n c.minForce = -maxForce;\n\n // Make the twist equation add torque toward the initial position\n t.maxForce = 0;\n t.minForce = -maxForce;\n\n this.equations.push(c, t);\n}\nConeTwistConstraint.prototype = new PointToPointConstraint();\nConeTwistConstraint.constructor = ConeTwistConstraint;\n\nvar ConeTwistConstraint_update_tmpVec1 = new Vec3();\nvar ConeTwistConstraint_update_tmpVec2 = new Vec3();\n\nConeTwistConstraint.prototype.update = function(){\n var bodyA = this.bodyA,\n bodyB = this.bodyB,\n cone = this.coneEquation,\n twist = this.twistEquation;\n\n PointToPointConstraint.prototype.update.call(this);\n\n // Update the axes to the cone constraint\n bodyA.vectorToWorldFrame(this.axisA, cone.axisA);\n bodyB.vectorToWorldFrame(this.axisB, cone.axisB);\n\n // Update the world axes in the twist constraint\n this.axisA.tangents(twist.axisA, twist.axisA);\n bodyA.vectorToWorldFrame(twist.axisA, twist.axisA);\n\n this.axisB.tangents(twist.axisB, twist.axisB);\n bodyB.vectorToWorldFrame(twist.axisB, twist.axisB);\n\n cone.angle = this.angle;\n twist.maxAngle = this.twistAngle;\n};\n\n\n},{\"../equations/ConeEquation\":18,\"../equations/ContactEquation\":19,\"../equations/RotationalEquation\":22,\"../math/Vec3\":30,\"./Constraint\":13,\"./PointToPointConstraint\":17}],13:[function(_dereq_,module,exports){\nmodule.exports = Constraint;\n\nvar Utils = _dereq_('../utils/Utils');\n\n/**\n * Constraint base class\n * @class Constraint\n * @author schteppe\n * @constructor\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {object} [options]\n * @param {boolean} [options.collideConnected=true]\n * @param {boolean} [options.wakeUpBodies=true]\n */\nfunction Constraint(bodyA, bodyB, options){\n options = Utils.defaults(options,{\n collideConnected : true,\n wakeUpBodies : true,\n });\n\n /**\n * Equations to be solved in this constraint\n * @property equations\n * @type {Array}\n */\n this.equations = [];\n\n /**\n * @property {Body} bodyA\n */\n this.bodyA = bodyA;\n\n /**\n * @property {Body} bodyB\n */\n this.bodyB = bodyB;\n\n /**\n * @property {Number} id\n */\n this.id = Constraint.idCounter++;\n\n /**\n * Set to true if you want the bodies to collide when they are connected.\n * @property collideConnected\n * @type {boolean}\n */\n this.collideConnected = options.collideConnected;\n\n if(options.wakeUpBodies){\n if(bodyA){\n bodyA.wakeUp();\n }\n if(bodyB){\n bodyB.wakeUp();\n }\n }\n}\n\n/**\n * Update all the equations with data.\n * @method update\n */\nConstraint.prototype.update = function(){\n throw new Error(\"method update() not implmemented in this Constraint subclass!\");\n};\n\n/**\n * Enables all equations in the constraint.\n * @method enable\n */\nConstraint.prototype.enable = function(){\n var eqs = this.equations;\n for(var i=0; i\n // G = [0 axisA 0 -axisB]\n\n GA.rotational.copy(axisA);\n axisB.negate(GB.rotational);\n\n var GW = this.computeGW() - this.targetVelocity,\n GiMf = this.computeGiMf();\n\n var B = - GW * b - h * GiMf;\n\n return B;\n};\n\n},{\"../math/Mat3\":27,\"../math/Vec3\":30,\"./Equation\":20}],24:[function(_dereq_,module,exports){\nvar Utils = _dereq_('../utils/Utils');\n\nmodule.exports = ContactMaterial;\n\n/**\n * Defines what happens when two materials meet.\n * @class ContactMaterial\n * @constructor\n * @param {Material} m1\n * @param {Material} m2\n * @param {object} [options]\n * @param {Number} [options.friction=0.3]\n * @param {Number} [options.restitution=0.3]\n * @param {number} [options.contactEquationStiffness=1e7]\n * @param {number} [options.contactEquationRelaxation=3]\n * @param {number} [options.frictionEquationStiffness=1e7]\n * @param {Number} [options.frictionEquationRelaxation=3]\n */\nfunction ContactMaterial(m1, m2, options){\n options = Utils.defaults(options, {\n friction: 0.3,\n restitution: 0.3,\n contactEquationStiffness: 1e7,\n contactEquationRelaxation: 3,\n frictionEquationStiffness: 1e7,\n frictionEquationRelaxation: 3\n });\n\n /**\n * Identifier of this material\n * @property {Number} id\n */\n this.id = ContactMaterial.idCounter++;\n\n /**\n * Participating materials\n * @property {Array} materials\n * @todo Should be .materialA and .materialB instead\n */\n this.materials = [m1, m2];\n\n /**\n * Friction coefficient\n * @property {Number} friction\n */\n this.friction = options.friction;\n\n /**\n * Restitution coefficient\n * @property {Number} restitution\n */\n this.restitution = options.restitution;\n\n /**\n * Stiffness of the produced contact equations\n * @property {Number} contactEquationStiffness\n */\n this.contactEquationStiffness = options.contactEquationStiffness;\n\n /**\n * Relaxation time of the produced contact equations\n * @property {Number} contactEquationRelaxation\n */\n this.contactEquationRelaxation = options.contactEquationRelaxation;\n\n /**\n * Stiffness of the produced friction equations\n * @property {Number} frictionEquationStiffness\n */\n this.frictionEquationStiffness = options.frictionEquationStiffness;\n\n /**\n * Relaxation time of the produced friction equations\n * @property {Number} frictionEquationRelaxation\n */\n this.frictionEquationRelaxation = options.frictionEquationRelaxation;\n}\n\nContactMaterial.idCounter = 0;\n\n},{\"../utils/Utils\":53}],25:[function(_dereq_,module,exports){\nmodule.exports = Material;\n\n/**\n * Defines a physics material.\n * @class Material\n * @constructor\n * @param {object} [options]\n * @author schteppe\n */\nfunction Material(options){\n var name = '';\n options = options || {};\n\n // Backwards compatibility fix\n if(typeof(options) === 'string'){\n name = options;\n options = {};\n } else if(typeof(options) === 'object') {\n name = '';\n }\n\n /**\n * @property name\n * @type {String}\n */\n this.name = name;\n\n /**\n * material id.\n * @property id\n * @type {number}\n */\n this.id = Material.idCounter++;\n\n /**\n * Friction for this material. If non-negative, it will be used instead of the friction given by ContactMaterials. If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used.\n * @property {number} friction\n */\n this.friction = typeof(options.friction) !== 'undefined' ? options.friction : -1;\n\n /**\n * Restitution for this material. If non-negative, it will be used instead of the restitution given by ContactMaterials. If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used.\n * @property {number} restitution\n */\n this.restitution = typeof(options.restitution) !== 'undefined' ? options.restitution : -1;\n}\n\nMaterial.idCounter = 0;\n\n},{}],26:[function(_dereq_,module,exports){\nmodule.exports = JacobianElement;\n\nvar Vec3 = _dereq_('./Vec3');\n\n/**\n * An element containing 6 entries, 3 spatial and 3 rotational degrees of freedom.\n * @class JacobianElement\n * @constructor\n */\nfunction JacobianElement(){\n\n /**\n * @property {Vec3} spatial\n */\n this.spatial = new Vec3();\n\n /**\n * @property {Vec3} rotational\n */\n this.rotational = new Vec3();\n}\n\n/**\n * Multiply with other JacobianElement\n * @method multiplyElement\n * @param {JacobianElement} element\n * @return {Number}\n */\nJacobianElement.prototype.multiplyElement = function(element){\n return element.spatial.dot(this.spatial) + element.rotational.dot(this.rotational);\n};\n\n/**\n * Multiply with two vectors\n * @method multiplyVectors\n * @param {Vec3} spatial\n * @param {Vec3} rotational\n * @return {Number}\n */\nJacobianElement.prototype.multiplyVectors = function(spatial,rotational){\n return spatial.dot(this.spatial) + rotational.dot(this.rotational);\n};\n\n},{\"./Vec3\":30}],27:[function(_dereq_,module,exports){\nmodule.exports = Mat3;\n\nvar Vec3 = _dereq_('./Vec3');\n\n/**\n * A 3x3 matrix.\n * @class Mat3\n * @constructor\n * @param array elements Array of nine elements. Optional.\n * @author schteppe / http://github.com/schteppe\n */\nfunction Mat3(elements){\n /**\n * A vector of length 9, containing all matrix elements\n * @property {Array} elements\n */\n if(elements){\n this.elements = elements;\n } else {\n this.elements = [0,0,0,0,0,0,0,0,0];\n }\n}\n\n/**\n * Sets the matrix to identity\n * @method identity\n * @todo Should perhaps be renamed to setIdentity() to be more clear.\n * @todo Create another function that immediately creates an identity matrix eg. eye()\n */\nMat3.prototype.identity = function(){\n var e = this.elements;\n e[0] = 1;\n e[1] = 0;\n e[2] = 0;\n\n e[3] = 0;\n e[4] = 1;\n e[5] = 0;\n\n e[6] = 0;\n e[7] = 0;\n e[8] = 1;\n};\n\n/**\n * Set all elements to zero\n * @method setZero\n */\nMat3.prototype.setZero = function(){\n var e = this.elements;\n e[0] = 0;\n e[1] = 0;\n e[2] = 0;\n e[3] = 0;\n e[4] = 0;\n e[5] = 0;\n e[6] = 0;\n e[7] = 0;\n e[8] = 0;\n};\n\n/**\n * Sets the matrix diagonal elements from a Vec3\n * @method setTrace\n * @param {Vec3} vec3\n */\nMat3.prototype.setTrace = function(vec3){\n var e = this.elements;\n e[0] = vec3.x;\n e[4] = vec3.y;\n e[8] = vec3.z;\n};\n\n/**\n * Gets the matrix diagonal elements\n * @method getTrace\n * @return {Vec3}\n */\nMat3.prototype.getTrace = function(target){\n var target = target || new Vec3();\n var e = this.elements;\n target.x = e[0];\n target.y = e[4];\n target.z = e[8];\n};\n\n/**\n * Matrix-Vector multiplication\n * @method vmult\n * @param {Vec3} v The vector to multiply with\n * @param {Vec3} target Optional, target to save the result in.\n */\nMat3.prototype.vmult = function(v,target){\n target = target || new Vec3();\n\n var e = this.elements,\n x = v.x,\n y = v.y,\n z = v.z;\n target.x = e[0]*x + e[1]*y + e[2]*z;\n target.y = e[3]*x + e[4]*y + e[5]*z;\n target.z = e[6]*x + e[7]*y + e[8]*z;\n\n return target;\n};\n\n/**\n * Matrix-scalar multiplication\n * @method smult\n * @param {Number} s\n */\nMat3.prototype.smult = function(s){\n for(var i=0; i1 acos and sqrt will produce errors, this cant happen if quaternion is normalised\n var angle = 2 * Math.acos(this.w);\n var s = Math.sqrt(1-this.w*this.w); // assuming quaternion normalised then w is less than 1, so term always positive.\n if (s < 0.001) { // test to avoid divide by zero, s is always positive due to sqrt\n // if s close to zero then direction of axis not important\n targetAxis.x = this.x; // if it is important that axis is normalised then replace with x=1; y=z=0;\n targetAxis.y = this.y;\n targetAxis.z = this.z;\n } else {\n targetAxis.x = this.x / s; // normalise axis\n targetAxis.y = this.y / s;\n targetAxis.z = this.z / s;\n }\n return [targetAxis,angle];\n};\n\nvar sfv_t1 = new Vec3(),\n sfv_t2 = new Vec3();\n\n/**\n * Set the quaternion value given two vectors. The resulting rotation will be the needed rotation to rotate u to v.\n * @method setFromVectors\n * @param {Vec3} u\n * @param {Vec3} v\n */\nQuaternion.prototype.setFromVectors = function(u,v){\n if(u.isAntiparallelTo(v)){\n var t1 = sfv_t1;\n var t2 = sfv_t2;\n\n u.tangents(t1,t2);\n this.setFromAxisAngle(t1,Math.PI);\n } else {\n var a = u.cross(v);\n this.x = a.x;\n this.y = a.y;\n this.z = a.z;\n this.w = Math.sqrt(Math.pow(u.norm(),2) * Math.pow(v.norm(),2)) + u.dot(v);\n this.normalize();\n }\n};\n\n/**\n * Quaternion multiplication\n * @method mult\n * @param {Quaternion} q\n * @param {Quaternion} target Optional.\n * @return {Quaternion}\n */\nvar Quaternion_mult_va = new Vec3();\nvar Quaternion_mult_vb = new Vec3();\nvar Quaternion_mult_vaxvb = new Vec3();\nQuaternion.prototype.mult = function(q,target){\n target = target || new Quaternion();\n var w = this.w,\n va = Quaternion_mult_va,\n vb = Quaternion_mult_vb,\n vaxvb = Quaternion_mult_vaxvb;\n\n va.set(this.x,this.y,this.z);\n vb.set(q.x,q.y,q.z);\n target.w = w*q.w - va.dot(vb);\n va.cross(vb,vaxvb);\n\n target.x = w * vb.x + q.w*va.x + vaxvb.x;\n target.y = w * vb.y + q.w*va.y + vaxvb.y;\n target.z = w * vb.z + q.w*va.z + vaxvb.z;\n\n return target;\n};\n\n/**\n * Get the inverse quaternion rotation.\n * @method inverse\n * @param {Quaternion} target\n * @return {Quaternion}\n */\nQuaternion.prototype.inverse = function(target){\n var x = this.x, y = this.y, z = this.z, w = this.w;\n target = target || new Quaternion();\n\n this.conjugate(target);\n var inorm2 = 1/(x*x + y*y + z*z + w*w);\n target.x *= inorm2;\n target.y *= inorm2;\n target.z *= inorm2;\n target.w *= inorm2;\n\n return target;\n};\n\n/**\n * Get the quaternion conjugate\n * @method conjugate\n * @param {Quaternion} target\n * @return {Quaternion}\n */\nQuaternion.prototype.conjugate = function(target){\n target = target || new Quaternion();\n\n target.x = -this.x;\n target.y = -this.y;\n target.z = -this.z;\n target.w = this.w;\n\n return target;\n};\n\n/**\n * Normalize the quaternion. Note that this changes the values of the quaternion.\n * @method normalize\n */\nQuaternion.prototype.normalize = function(){\n var l = Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);\n if ( l === 0 ) {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n this.w = 0;\n } else {\n l = 1 / l;\n this.x *= l;\n this.y *= l;\n this.z *= l;\n this.w *= l;\n }\n};\n\n/**\n * Approximation of quaternion normalization. Works best when quat is already almost-normalized.\n * @method normalizeFast\n * @see http://jsperf.com/fast-quaternion-normalization\n * @author unphased, https://github.com/unphased\n */\nQuaternion.prototype.normalizeFast = function () {\n var f = (3.0-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2.0;\n if ( f === 0 ) {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n this.w = 0;\n } else {\n this.x *= f;\n this.y *= f;\n this.z *= f;\n this.w *= f;\n }\n};\n\n/**\n * Multiply the quaternion by a vector\n * @method vmult\n * @param {Vec3} v\n * @param {Vec3} target Optional\n * @return {Vec3}\n */\nQuaternion.prototype.vmult = function(v,target){\n target = target || new Vec3();\n\n var x = v.x,\n y = v.y,\n z = v.z;\n\n var qx = this.x,\n qy = this.y,\n qz = this.z,\n qw = this.w;\n\n // q*v\n var ix = qw * x + qy * z - qz * y,\n iy = qw * y + qz * x - qx * z,\n iz = qw * z + qx * y - qy * x,\n iw = -qx * x - qy * y - qz * z;\n\n target.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n target.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n target.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n\n return target;\n};\n\n/**\n * Copies value of source to this quaternion.\n * @method copy\n * @param {Quaternion} source\n * @return {Quaternion} this\n */\nQuaternion.prototype.copy = function(source){\n this.x = source.x;\n this.y = source.y;\n this.z = source.z;\n this.w = source.w;\n return this;\n};\n\n/**\n * Convert the quaternion to euler angle representation. Order: YZX, as this page describes: http://www.euclideanspace.com/maths/standards/index.htm\n * @method toEuler\n * @param {Vec3} target\n * @param string order Three-character string e.g. \"YZX\", which also is default.\n */\nQuaternion.prototype.toEuler = function(target,order){\n order = order || \"YZX\";\n\n var heading, attitude, bank;\n var x = this.x, y = this.y, z = this.z, w = this.w;\n\n switch(order){\n case \"YZX\":\n var test = x*y + z*w;\n if (test > 0.499) { // singularity at north pole\n heading = 2 * Math.atan2(x,w);\n attitude = Math.PI/2;\n bank = 0;\n }\n if (test < -0.499) { // singularity at south pole\n heading = -2 * Math.atan2(x,w);\n attitude = - Math.PI/2;\n bank = 0;\n }\n if(isNaN(heading)){\n var sqx = x*x;\n var sqy = y*y;\n var sqz = z*z;\n heading = Math.atan2(2*y*w - 2*x*z , 1 - 2*sqy - 2*sqz); // Heading\n attitude = Math.asin(2*test); // attitude\n bank = Math.atan2(2*x*w - 2*y*z , 1 - 2*sqx - 2*sqz); // bank\n }\n break;\n default:\n throw new Error(\"Euler order \"+order+\" not supported yet.\");\n }\n\n target.y = heading;\n target.z = attitude;\n target.x = bank;\n};\n\n/**\n * See http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m\n * @method setFromEuler\n * @param {Number} x\n * @param {Number} y\n * @param {Number} z\n * @param {String} order The order to apply angles: 'XYZ' or 'YXZ' or any other combination\n */\nQuaternion.prototype.setFromEuler = function ( x, y, z, order ) {\n order = order || \"XYZ\";\n\n var c1 = Math.cos( x / 2 );\n var c2 = Math.cos( y / 2 );\n var c3 = Math.cos( z / 2 );\n var s1 = Math.sin( x / 2 );\n var s2 = Math.sin( y / 2 );\n var s3 = Math.sin( z / 2 );\n\n if ( order === 'XYZ' ) {\n\n this.x = s1 * c2 * c3 + c1 * s2 * s3;\n this.y = c1 * s2 * c3 - s1 * c2 * s3;\n this.z = c1 * c2 * s3 + s1 * s2 * c3;\n this.w = c1 * c2 * c3 - s1 * s2 * s3;\n\n } else if ( order === 'YXZ' ) {\n\n this.x = s1 * c2 * c3 + c1 * s2 * s3;\n this.y = c1 * s2 * c3 - s1 * c2 * s3;\n this.z = c1 * c2 * s3 - s1 * s2 * c3;\n this.w = c1 * c2 * c3 + s1 * s2 * s3;\n\n } else if ( order === 'ZXY' ) {\n\n this.x = s1 * c2 * c3 - c1 * s2 * s3;\n this.y = c1 * s2 * c3 + s1 * c2 * s3;\n this.z = c1 * c2 * s3 + s1 * s2 * c3;\n this.w = c1 * c2 * c3 - s1 * s2 * s3;\n\n } else if ( order === 'ZYX' ) {\n\n this.x = s1 * c2 * c3 - c1 * s2 * s3;\n this.y = c1 * s2 * c3 + s1 * c2 * s3;\n this.z = c1 * c2 * s3 - s1 * s2 * c3;\n this.w = c1 * c2 * c3 + s1 * s2 * s3;\n\n } else if ( order === 'YZX' ) {\n\n this.x = s1 * c2 * c3 + c1 * s2 * s3;\n this.y = c1 * s2 * c3 + s1 * c2 * s3;\n this.z = c1 * c2 * s3 - s1 * s2 * c3;\n this.w = c1 * c2 * c3 - s1 * s2 * s3;\n\n } else if ( order === 'XZY' ) {\n\n this.x = s1 * c2 * c3 - c1 * s2 * s3;\n this.y = c1 * s2 * c3 - s1 * c2 * s3;\n this.z = c1 * c2 * s3 + s1 * s2 * c3;\n this.w = c1 * c2 * c3 + s1 * s2 * s3;\n\n }\n\n return this;\n\n};\n\nQuaternion.prototype.clone = function(){\n return new Quaternion(this.x, this.y, this.z, this.w);\n};\n},{\"./Vec3\":30}],29:[function(_dereq_,module,exports){\nvar Vec3 = _dereq_('./Vec3');\nvar Quaternion = _dereq_('./Quaternion');\n\nmodule.exports = Transform;\n\n/**\n * @class Transform\n * @constructor\n */\nfunction Transform(options) {\n options = options || {};\n\n\t/**\n\t * @property {Vec3} position\n\t */\n\tthis.position = new Vec3();\n if(options.position){\n this.position.copy(options.position);\n }\n\n\t/**\n\t * @property {Quaternion} quaternion\n\t */\n\tthis.quaternion = new Quaternion();\n if(options.quaternion){\n this.quaternion.copy(options.quaternion);\n }\n}\n\nvar tmpQuat = new Quaternion();\n\n/**\n * @static\n * @method pointToLocaFrame\n * @param {Vec3} position\n * @param {Quaternion} quaternion\n * @param {Vec3} worldPoint\n * @param {Vec3} result\n */\nTransform.pointToLocalFrame = function(position, quaternion, worldPoint, result){\n var result = result || new Vec3();\n worldPoint.vsub(position, result);\n quaternion.conjugate(tmpQuat);\n tmpQuat.vmult(result, result);\n return result;\n};\n\n/**\n * Get a global point in local transform coordinates.\n * @method pointToLocal\n * @param {Vec3} point\n * @param {Vec3} result\n * @return {Vec3} The \"result\" vector object\n */\nTransform.prototype.pointToLocal = function(worldPoint, result){\n return Transform.pointToLocalFrame(this.position, this.quaternion, worldPoint, result);\n};\n\n/**\n * @static\n * @method pointToWorldFrame\n * @param {Vec3} position\n * @param {Vec3} quaternion\n * @param {Vec3} localPoint\n * @param {Vec3} result\n */\nTransform.pointToWorldFrame = function(position, quaternion, localPoint, result){\n var result = result || new Vec3();\n quaternion.vmult(localPoint, result);\n result.vadd(position, result);\n return result;\n};\n\n/**\n * Get a local point in global transform coordinates.\n * @method pointToWorld\n * @param {Vec3} point\n * @param {Vec3} result\n * @return {Vec3} The \"result\" vector object\n */\nTransform.prototype.pointToWorld = function(localPoint, result){\n return Transform.pointToWorldFrame(this.position, this.quaternion, localPoint, result);\n};\n\n\nTransform.prototype.vectorToWorldFrame = function(localVector, result){\n var result = result || new Vec3();\n this.quaternion.vmult(localVector, result);\n return result;\n};\n\nTransform.vectorToWorldFrame = function(quaternion, localVector, result){\n quaternion.vmult(localVector, result);\n return result;\n};\n\nTransform.vectorToLocalFrame = function(position, quaternion, worldVector, result){\n var result = result || new Vec3();\n quaternion.w *= -1;\n quaternion.vmult(worldVector, result);\n quaternion.w *= -1;\n return result;\n};\n\n},{\"./Quaternion\":28,\"./Vec3\":30}],30:[function(_dereq_,module,exports){\nmodule.exports = Vec3;\n\nvar Mat3 = _dereq_('./Mat3');\n\n/**\n * 3-dimensional vector\n * @class Vec3\n * @constructor\n * @param {Number} x\n * @param {Number} y\n * @param {Number} z\n * @author schteppe\n * @example\n * var v = new Vec3(1, 2, 3);\n * console.log('x=' + v.x); // x=1\n */\nfunction Vec3(x,y,z){\n /**\n * @property x\n * @type {Number}\n */\n this.x = x||0.0;\n\n /**\n * @property y\n * @type {Number}\n */\n this.y = y||0.0;\n\n /**\n * @property z\n * @type {Number}\n */\n this.z = z||0.0;\n}\n\n/**\n * @static\n * @property {Vec3} ZERO\n */\nVec3.ZERO = new Vec3(0, 0, 0);\n\n/**\n * @static\n * @property {Vec3} UNIT_X\n */\nVec3.UNIT_X = new Vec3(1, 0, 0);\n\n/**\n * @static\n * @property {Vec3} UNIT_Y\n */\nVec3.UNIT_Y = new Vec3(0, 1, 0);\n\n/**\n * @static\n * @property {Vec3} UNIT_Z\n */\nVec3.UNIT_Z = new Vec3(0, 0, 1);\n\n/**\n * Vector cross product\n * @method cross\n * @param {Vec3} v\n * @param {Vec3} target Optional. Target to save in.\n * @return {Vec3}\n */\nVec3.prototype.cross = function(v,target){\n var vx=v.x, vy=v.y, vz=v.z, x=this.x, y=this.y, z=this.z;\n target = target || new Vec3();\n\n target.x = (y * vz) - (z * vy);\n target.y = (z * vx) - (x * vz);\n target.z = (x * vy) - (y * vx);\n\n return target;\n};\n\n/**\n * Set the vectors' 3 elements\n * @method set\n * @param {Number} x\n * @param {Number} y\n * @param {Number} z\n * @return Vec3\n */\nVec3.prototype.set = function(x,y,z){\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n};\n\n/**\n * Set all components of the vector to zero.\n * @method setZero\n */\nVec3.prototype.setZero = function(){\n this.x = this.y = this.z = 0;\n};\n\n/**\n * Vector addition\n * @method vadd\n * @param {Vec3} v\n * @param {Vec3} target Optional.\n * @return {Vec3}\n */\nVec3.prototype.vadd = function(v,target){\n if(target){\n target.x = v.x + this.x;\n target.y = v.y + this.y;\n target.z = v.z + this.z;\n } else {\n return new Vec3(this.x + v.x,\n this.y + v.y,\n this.z + v.z);\n }\n};\n\n/**\n * Vector subtraction\n * @method vsub\n * @param {Vec3} v\n * @param {Vec3} target Optional. Target to save in.\n * @return {Vec3}\n */\nVec3.prototype.vsub = function(v,target){\n if(target){\n target.x = this.x - v.x;\n target.y = this.y - v.y;\n target.z = this.z - v.z;\n } else {\n return new Vec3(this.x-v.x,\n this.y-v.y,\n this.z-v.z);\n }\n};\n\n/**\n * Get the cross product matrix a_cross from a vector, such that a x b = a_cross * b = c\n * @method crossmat\n * @see http://www8.cs.umu.se/kurser/TDBD24/VT06/lectures/Lecture6.pdf\n * @return {Mat3}\n */\nVec3.prototype.crossmat = function(){\n return new Mat3([ 0, -this.z, this.y,\n this.z, 0, -this.x,\n -this.y, this.x, 0]);\n};\n\n/**\n * Normalize the vector. Note that this changes the values in the vector.\n * @method normalize\n * @return {Number} Returns the norm of the vector\n */\nVec3.prototype.normalize = function(){\n var x=this.x, y=this.y, z=this.z;\n var n = Math.sqrt(x*x + y*y + z*z);\n if(n>0.0){\n var invN = 1/n;\n this.x *= invN;\n this.y *= invN;\n this.z *= invN;\n } else {\n // Make something up\n this.x = 0;\n this.y = 0;\n this.z = 0;\n }\n return n;\n};\n\n/**\n * Get the version of this vector that is of length 1.\n * @method unit\n * @param {Vec3} target Optional target to save in\n * @return {Vec3} Returns the unit vector\n */\nVec3.prototype.unit = function(target){\n target = target || new Vec3();\n var x=this.x, y=this.y, z=this.z;\n var ninv = Math.sqrt(x*x + y*y + z*z);\n if(ninv>0.0){\n ninv = 1.0/ninv;\n target.x = x * ninv;\n target.y = y * ninv;\n target.z = z * ninv;\n } else {\n target.x = 1;\n target.y = 0;\n target.z = 0;\n }\n return target;\n};\n\n/**\n * Get the length of the vector\n * @method norm\n * @return {Number}\n * @deprecated Use .length() instead\n */\nVec3.prototype.norm = function(){\n var x=this.x, y=this.y, z=this.z;\n return Math.sqrt(x*x + y*y + z*z);\n};\n\n/**\n * Get the length of the vector\n * @method length\n * @return {Number}\n */\nVec3.prototype.length = Vec3.prototype.norm;\n\n/**\n * Get the squared length of the vector\n * @method norm2\n * @return {Number}\n * @deprecated Use .lengthSquared() instead.\n */\nVec3.prototype.norm2 = function(){\n return this.dot(this);\n};\n\n/**\n * Get the squared length of the vector.\n * @method lengthSquared\n * @return {Number}\n */\nVec3.prototype.lengthSquared = Vec3.prototype.norm2;\n\n/**\n * Get distance from this point to another point\n * @method distanceTo\n * @param {Vec3} p\n * @return {Number}\n */\nVec3.prototype.distanceTo = function(p){\n var x=this.x, y=this.y, z=this.z;\n var px=p.x, py=p.y, pz=p.z;\n return Math.sqrt((px-x)*(px-x)+\n (py-y)*(py-y)+\n (pz-z)*(pz-z));\n};\n\n/**\n * Get squared distance from this point to another point\n * @method distanceSquared\n * @param {Vec3} p\n * @return {Number}\n */\nVec3.prototype.distanceSquared = function(p){\n var x=this.x, y=this.y, z=this.z;\n var px=p.x, py=p.y, pz=p.z;\n return (px-x)*(px-x) + (py-y)*(py-y) + (pz-z)*(pz-z);\n};\n\n/**\n * Multiply all the components of the vector with a scalar.\n * @deprecated Use .scale instead\n * @method mult\n * @param {Number} scalar\n * @param {Vec3} target The vector to save the result in.\n * @return {Vec3}\n * @deprecated Use .scale() instead\n */\nVec3.prototype.mult = function(scalar,target){\n target = target || new Vec3();\n var x = this.x,\n y = this.y,\n z = this.z;\n target.x = scalar * x;\n target.y = scalar * y;\n target.z = scalar * z;\n return target;\n};\n\n/**\n * Multiply the vector with a scalar.\n * @method scale\n * @param {Number} scalar\n * @param {Vec3} target\n * @return {Vec3}\n */\nVec3.prototype.scale = Vec3.prototype.mult;\n\n/**\n * Calculate dot product\n * @method dot\n * @param {Vec3} v\n * @return {Number}\n */\nVec3.prototype.dot = function(v){\n return this.x * v.x + this.y * v.y + this.z * v.z;\n};\n\n/**\n * @method isZero\n * @return bool\n */\nVec3.prototype.isZero = function(){\n return this.x===0 && this.y===0 && this.z===0;\n};\n\n/**\n * Make the vector point in the opposite direction.\n * @method negate\n * @param {Vec3} target Optional target to save in\n * @return {Vec3}\n */\nVec3.prototype.negate = function(target){\n target = target || new Vec3();\n target.x = -this.x;\n target.y = -this.y;\n target.z = -this.z;\n return target;\n};\n\n/**\n * Compute two artificial tangents to the vector\n * @method tangents\n * @param {Vec3} t1 Vector object to save the first tangent in\n * @param {Vec3} t2 Vector object to save the second tangent in\n */\nvar Vec3_tangents_n = new Vec3();\nvar Vec3_tangents_randVec = new Vec3();\nVec3.prototype.tangents = function(t1,t2){\n var norm = this.norm();\n if(norm>0.0){\n var n = Vec3_tangents_n;\n var inorm = 1/norm;\n n.set(this.x*inorm,this.y*inorm,this.z*inorm);\n var randVec = Vec3_tangents_randVec;\n if(Math.abs(n.x) < 0.9){\n randVec.set(1,0,0);\n n.cross(randVec,t1);\n } else {\n randVec.set(0,1,0);\n n.cross(randVec,t1);\n }\n n.cross(t1,t2);\n } else {\n // The normal length is zero, make something up\n t1.set(1, 0, 0);\n t2.set(0, 1, 0);\n }\n};\n\n/**\n * Converts to a more readable format\n * @method toString\n * @return string\n */\nVec3.prototype.toString = function(){\n return this.x+\",\"+this.y+\",\"+this.z;\n};\n\n/**\n * Converts to an array\n * @method toArray\n * @return Array\n */\nVec3.prototype.toArray = function(){\n return [this.x, this.y, this.z];\n};\n\n/**\n * Copies value of source to this vector.\n * @method copy\n * @param {Vec3} source\n * @return {Vec3} this\n */\nVec3.prototype.copy = function(source){\n this.x = source.x;\n this.y = source.y;\n this.z = source.z;\n return this;\n};\n\n\n/**\n * Do a linear interpolation between two vectors\n * @method lerp\n * @param {Vec3} v\n * @param {Number} t A number between 0 and 1. 0 will make this function return u, and 1 will make it return v. Numbers in between will generate a vector in between them.\n * @param {Vec3} target\n */\nVec3.prototype.lerp = function(v,t,target){\n var x=this.x, y=this.y, z=this.z;\n target.x = x + (v.x-x)*t;\n target.y = y + (v.y-y)*t;\n target.z = z + (v.z-z)*t;\n};\n\n/**\n * Check if a vector equals is almost equal to another one.\n * @method almostEquals\n * @param {Vec3} v\n * @param {Number} precision\n * @return bool\n */\nVec3.prototype.almostEquals = function(v,precision){\n if(precision===undefined){\n precision = 1e-6;\n }\n if( Math.abs(this.x-v.x)>precision ||\n Math.abs(this.y-v.y)>precision ||\n Math.abs(this.z-v.z)>precision){\n return false;\n }\n return true;\n};\n\n/**\n * Check if a vector is almost zero\n * @method almostZero\n * @param {Number} precision\n */\nVec3.prototype.almostZero = function(precision){\n if(precision===undefined){\n precision = 1e-6;\n }\n if( Math.abs(this.x)>precision ||\n Math.abs(this.y)>precision ||\n Math.abs(this.z)>precision){\n return false;\n }\n return true;\n};\n\nvar antip_neg = new Vec3();\n\n/**\n * Check if the vector is anti-parallel to another vector.\n * @method isAntiparallelTo\n * @param {Vec3} v\n * @param {Number} precision Set to zero for exact comparisons\n * @return {Boolean}\n */\nVec3.prototype.isAntiparallelTo = function(v,precision){\n this.negate(antip_neg);\n return antip_neg.almostEquals(v,precision);\n};\n\n/**\n * Clone the vector\n * @method clone\n * @return {Vec3}\n */\nVec3.prototype.clone = function(){\n return new Vec3(this.x, this.y, this.z);\n};\n},{\"./Mat3\":27}],31:[function(_dereq_,module,exports){\nmodule.exports = Body;\n\nvar EventTarget = _dereq_('../utils/EventTarget');\nvar Shape = _dereq_('../shapes/Shape');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Mat3 = _dereq_('../math/Mat3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Material = _dereq_('../material/Material');\nvar AABB = _dereq_('../collision/AABB');\nvar Box = _dereq_('../shapes/Box');\n\n/**\n * Base class for all body types.\n * @class Body\n * @constructor\n * @extends EventTarget\n * @param {object} [options]\n * @param {Vec3} [options.position]\n * @param {Vec3} [options.velocity]\n * @param {Vec3} [options.angularVelocity]\n * @param {Quaternion} [options.quaternion]\n * @param {number} [options.mass]\n * @param {Material} [options.material]\n * @param {number} [options.type]\n * @param {number} [options.linearDamping=0.01]\n * @param {number} [options.angularDamping=0.01]\n * @param {boolean} [options.allowSleep=true]\n * @param {number} [options.sleepSpeedLimit=0.1]\n * @param {number} [options.sleepTimeLimit=1]\n * @param {number} [options.collisionFilterGroup=1]\n * @param {number} [options.collisionFilterMask=1]\n * @param {boolean} [options.fixedRotation=false]\n * @param {Body} [options.shape]\n * @example\n * var body = new Body({\n * mass: 1\n * });\n * var shape = new Sphere(1);\n * body.addShape(shape);\n * world.add(body);\n */\nfunction Body(options){\n options = options || {};\n\n EventTarget.apply(this);\n\n this.id = Body.idCounter++;\n\n /**\n * Reference to the world the body is living in\n * @property world\n * @type {World}\n */\n this.world = null;\n\n /**\n * Callback function that is used BEFORE stepping the system. Use it to apply forces, for example. Inside the function, \"this\" will refer to this Body object.\n * @property preStep\n * @type {Function}\n * @deprecated Use World events instead\n */\n this.preStep = null;\n\n /**\n * Callback function that is used AFTER stepping the system. Inside the function, \"this\" will refer to this Body object.\n * @property postStep\n * @type {Function}\n * @deprecated Use World events instead\n */\n this.postStep = null;\n\n this.vlambda = new Vec3();\n\n /**\n * @property {Number} collisionFilterGroup\n */\n this.collisionFilterGroup = typeof(options.collisionFilterGroup) === 'number' ? options.collisionFilterGroup : 1;\n\n /**\n * @property {Number} collisionFilterMask\n */\n this.collisionFilterMask = typeof(options.collisionFilterMask) === 'number' ? options.collisionFilterMask : 1;\n\n /**\n * Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled.\n * @property {Number} collisionResponse\n */\n\tthis.collisionResponse = true;\n\n /**\n * @property position\n * @type {Vec3}\n */\n this.position = new Vec3();\n\n if(options.position){\n this.position.copy(options.position);\n }\n\n /**\n * @property {Vec3} previousPosition\n */\n this.previousPosition = new Vec3();\n\n /**\n * Initial position of the body\n * @property initPosition\n * @type {Vec3}\n */\n this.initPosition = new Vec3();\n\n /**\n * @property velocity\n * @type {Vec3}\n */\n this.velocity = new Vec3();\n\n if(options.velocity){\n this.velocity.copy(options.velocity);\n }\n\n /**\n * @property initVelocity\n * @type {Vec3}\n */\n this.initVelocity = new Vec3();\n\n /**\n * Linear force on the body\n * @property force\n * @type {Vec3}\n */\n this.force = new Vec3();\n\n var mass = typeof(options.mass) === 'number' ? options.mass : 0;\n\n /**\n * @property mass\n * @type {Number}\n * @default 0\n */\n this.mass = mass;\n\n /**\n * @property invMass\n * @type {Number}\n */\n this.invMass = mass > 0 ? 1.0 / mass : 0;\n\n /**\n * @property material\n * @type {Material}\n */\n this.material = options.material || null;\n\n /**\n * @property linearDamping\n * @type {Number}\n */\n this.linearDamping = typeof(options.linearDamping) === 'number' ? options.linearDamping : 0.01;\n\n /**\n * One of: Body.DYNAMIC, Body.STATIC and Body.KINEMATIC.\n * @property type\n * @type {Number}\n */\n this.type = (mass <= 0.0 ? Body.STATIC : Body.DYNAMIC);\n if(typeof(options.type) === typeof(Body.STATIC)){\n this.type = options.type;\n }\n\n /**\n * If true, the body will automatically fall to sleep.\n * @property allowSleep\n * @type {Boolean}\n * @default true\n */\n this.allowSleep = typeof(options.allowSleep) !== 'undefined' ? options.allowSleep : true;\n\n /**\n * Current sleep state.\n * @property sleepState\n * @type {Number}\n */\n this.sleepState = 0;\n\n /**\n * If the speed (the norm of the velocity) is smaller than this value, the body is considered sleepy.\n * @property sleepSpeedLimit\n * @type {Number}\n * @default 0.1\n */\n this.sleepSpeedLimit = typeof(options.sleepSpeedLimit) !== 'undefined' ? options.sleepSpeedLimit : 0.1;\n\n /**\n * If the body has been sleepy for this sleepTimeLimit seconds, it is considered sleeping.\n * @property sleepTimeLimit\n * @type {Number}\n * @default 1\n */\n this.sleepTimeLimit = typeof(options.sleepTimeLimit) !== 'undefined' ? options.sleepTimeLimit : 1;\n\n this.timeLastSleepy = 0;\n\n this._wakeUpAfterNarrowphase = false;\n\n\n /**\n * Rotational force on the body, around center of mass\n * @property {Vec3} torque\n */\n this.torque = new Vec3();\n\n /**\n * Orientation of the body\n * @property quaternion\n * @type {Quaternion}\n */\n this.quaternion = new Quaternion();\n\n if(options.quaternion){\n this.quaternion.copy(options.quaternion);\n }\n\n /**\n * @property initQuaternion\n * @type {Quaternion}\n */\n this.initQuaternion = new Quaternion();\n\n /**\n * @property angularVelocity\n * @type {Vec3}\n */\n this.angularVelocity = new Vec3();\n\n if(options.angularVelocity){\n this.angularVelocity.copy(options.angularVelocity);\n }\n\n /**\n * @property initAngularVelocity\n * @type {Vec3}\n */\n this.initAngularVelocity = new Vec3();\n\n this.interpolatedPosition = new Vec3();\n this.interpolatedQuaternion = new Quaternion();\n\n /**\n * @property shapes\n * @type {array}\n */\n this.shapes = [];\n\n /**\n * @property shapeOffsets\n * @type {array}\n */\n this.shapeOffsets = [];\n\n /**\n * @property shapeOrientations\n * @type {array}\n */\n this.shapeOrientations = [];\n\n /**\n * @property inertia\n * @type {Vec3}\n */\n this.inertia = new Vec3();\n\n /**\n * @property {Vec3} invInertia\n */\n this.invInertia = new Vec3();\n\n /**\n * @property {Mat3} invInertiaWorld\n */\n this.invInertiaWorld = new Mat3();\n\n this.invMassSolve = 0;\n\n /**\n * @property {Vec3} invInertiaSolve\n */\n this.invInertiaSolve = new Vec3();\n\n /**\n * @property {Mat3} invInertiaWorldSolve\n */\n this.invInertiaWorldSolve = new Mat3();\n\n /**\n * Set to true if you don't want the body to rotate. Make sure to run .updateMassProperties() after changing this.\n * @property {Boolean} fixedRotation\n * @default false\n */\n this.fixedRotation = typeof(options.fixedRotation) !== \"undefined\" ? options.fixedRotation : false;\n\n /**\n * @property {Number} angularDamping\n */\n this.angularDamping = typeof(options.angularDamping) !== 'undefined' ? options.angularDamping : 0.01;\n\n /**\n * @property aabb\n * @type {AABB}\n */\n this.aabb = new AABB();\n\n /**\n * Indicates if the AABB needs to be updated before use.\n * @property aabbNeedsUpdate\n * @type {Boolean}\n */\n this.aabbNeedsUpdate = true;\n\n this.wlambda = new Vec3();\n\n if(options.shape){\n this.addShape(options.shape);\n }\n\n this.updateMassProperties();\n}\nBody.prototype = new EventTarget();\nBody.prototype.constructor = Body;\n\n/**\n * A dynamic body is fully simulated. Can be moved manually by the user, but normally they move according to forces. A dynamic body can collide with all body types. A dynamic body always has finite, non-zero mass.\n * @static\n * @property DYNAMIC\n * @type {Number}\n */\nBody.DYNAMIC = 1;\n\n/**\n * A static body does not move during simulation and behaves as if it has infinite mass. Static bodies can be moved manually by setting the position of the body. The velocity of a static body is always zero. Static bodies do not collide with other static or kinematic bodies.\n * @static\n * @property STATIC\n * @type {Number}\n */\nBody.STATIC = 2;\n\n/**\n * A kinematic body moves under simulation according to its velocity. They do not respond to forces. They can be moved manually, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass. Kinematic bodies do not collide with other static or kinematic bodies.\n * @static\n * @property KINEMATIC\n * @type {Number}\n */\nBody.KINEMATIC = 4;\n\n\n\n/**\n * @static\n * @property AWAKE\n * @type {number}\n */\nBody.AWAKE = 0;\n\n/**\n * @static\n * @property SLEEPY\n * @type {number}\n */\nBody.SLEEPY = 1;\n\n/**\n * @static\n * @property SLEEPING\n * @type {number}\n */\nBody.SLEEPING = 2;\n\nBody.idCounter = 0;\n\n/**\n * Wake the body up.\n * @method wakeUp\n */\nBody.prototype.wakeUp = function(){\n var s = this.sleepState;\n this.sleepState = 0;\n if(s === Body.SLEEPING){\n this.dispatchEvent({type:\"wakeup\"});\n }\n};\n\n/**\n * Force body sleep\n * @method sleep\n */\nBody.prototype.sleep = function(){\n this.sleepState = Body.SLEEPING;\n this.velocity.set(0,0,0);\n this.angularVelocity.set(0,0,0);\n};\n\nBody.sleepyEvent = {\n type: \"sleepy\"\n};\n\nBody.sleepEvent = {\n type: \"sleep\"\n};\n\n/**\n * Called every timestep to update internal sleep timer and change sleep state if needed.\n * @method sleepTick\n * @param {Number} time The world time in seconds\n */\nBody.prototype.sleepTick = function(time){\n if(this.allowSleep){\n var sleepState = this.sleepState;\n var speedSquared = this.velocity.norm2() + this.angularVelocity.norm2();\n var speedLimitSquared = Math.pow(this.sleepSpeedLimit,2);\n if(sleepState===Body.AWAKE && speedSquared < speedLimitSquared){\n this.sleepState = Body.SLEEPY; // Sleepy\n this.timeLastSleepy = time;\n this.dispatchEvent(Body.sleepyEvent);\n } else if(sleepState===Body.SLEEPY && speedSquared > speedLimitSquared){\n this.wakeUp(); // Wake up\n } else if(sleepState===Body.SLEEPY && (time - this.timeLastSleepy ) > this.sleepTimeLimit){\n this.sleep(); // Sleeping\n this.dispatchEvent(Body.sleepEvent);\n }\n }\n};\n\n/**\n * If the body is sleeping, it should be immovable / have infinite mass during solve. We solve it by having a separate \"solve mass\".\n * @method updateSolveMassProperties\n */\nBody.prototype.updateSolveMassProperties = function(){\n if(this.sleepState === Body.SLEEPING || this.type === Body.KINEMATIC){\n this.invMassSolve = 0;\n this.invInertiaSolve.setZero();\n this.invInertiaWorldSolve.setZero();\n } else {\n this.invMassSolve = this.invMass;\n this.invInertiaSolve.copy(this.invInertia);\n this.invInertiaWorldSolve.copy(this.invInertiaWorld);\n }\n};\n\n/**\n * Convert a world point to local body frame.\n * @method pointToLocalFrame\n * @param {Vec3} worldPoint\n * @param {Vec3} result\n * @return {Vec3}\n */\nBody.prototype.pointToLocalFrame = function(worldPoint,result){\n var result = result || new Vec3();\n worldPoint.vsub(this.position,result);\n this.quaternion.conjugate().vmult(result,result);\n return result;\n};\n\n/**\n * Convert a world vector to local body frame.\n * @method vectorToLocalFrame\n * @param {Vec3} worldPoint\n * @param {Vec3} result\n * @return {Vec3}\n */\nBody.prototype.vectorToLocalFrame = function(worldVector, result){\n var result = result || new Vec3();\n this.quaternion.conjugate().vmult(worldVector,result);\n return result;\n};\n\n/**\n * Convert a local body point to world frame.\n * @method pointToWorldFrame\n * @param {Vec3} localPoint\n * @param {Vec3} result\n * @return {Vec3}\n */\nBody.prototype.pointToWorldFrame = function(localPoint,result){\n var result = result || new Vec3();\n this.quaternion.vmult(localPoint,result);\n result.vadd(this.position,result);\n return result;\n};\n\n/**\n * Convert a local body point to world frame.\n * @method vectorToWorldFrame\n * @param {Vec3} localVector\n * @param {Vec3} result\n * @return {Vec3}\n */\nBody.prototype.vectorToWorldFrame = function(localVector, result){\n var result = result || new Vec3();\n this.quaternion.vmult(localVector, result);\n return result;\n};\n\nvar tmpVec = new Vec3();\nvar tmpQuat = new Quaternion();\n\n/**\n * Add a shape to the body with a local offset and orientation.\n * @method addShape\n * @param {Shape} shape\n * @param {Vec3} offset\n * @param {Quaternion} quaternion\n * @return {Body} The body object, for chainability.\n */\nBody.prototype.addShape = function(shape, _offset, _orientation){\n var offset = new Vec3();\n var orientation = new Quaternion();\n\n if(_offset){\n offset.copy(_offset);\n }\n if(_orientation){\n orientation.copy(_orientation);\n }\n\n this.shapes.push(shape);\n this.shapeOffsets.push(offset);\n this.shapeOrientations.push(orientation);\n this.updateMassProperties();\n this.updateBoundingRadius();\n\n this.aabbNeedsUpdate = true;\n\n return this;\n};\n\n/**\n * Update the bounding radius of the body. Should be done if any of the shapes are changed.\n * @method updateBoundingRadius\n */\nBody.prototype.updateBoundingRadius = function(){\n var shapes = this.shapes,\n shapeOffsets = this.shapeOffsets,\n N = shapes.length,\n radius = 0;\n\n for(var i=0; i!==N; i++){\n var shape = shapes[i];\n shape.updateBoundingSphereRadius();\n var offset = shapeOffsets[i].norm(),\n r = shape.boundingSphereRadius;\n if(offset + r > radius){\n radius = offset + r;\n }\n }\n\n this.boundingRadius = radius;\n};\n\nvar computeAABB_shapeAABB = new AABB();\n\n/**\n * Updates the .aabb\n * @method computeAABB\n * @todo rename to updateAABB()\n */\nBody.prototype.computeAABB = function(){\n var shapes = this.shapes,\n shapeOffsets = this.shapeOffsets,\n shapeOrientations = this.shapeOrientations,\n N = shapes.length,\n offset = tmpVec,\n orientation = tmpQuat,\n bodyQuat = this.quaternion,\n aabb = this.aabb,\n shapeAABB = computeAABB_shapeAABB;\n\n for(var i=0; i!==N; i++){\n var shape = shapes[i];\n\n // Get shape world quaternion\n shapeOrientations[i].mult(bodyQuat, orientation);\n\n // Get shape world position\n orientation.vmult(shapeOffsets[i], offset);\n offset.vadd(this.position, offset);\n\n // vec2.rotate(offset, shapeOffsets[i], bodyAngle);\n // vec2.add(offset, offset, this.position);\n\n // Get shape AABB\n shape.calculateWorldAABB(offset, orientation, shapeAABB.lowerBound, shapeAABB.upperBound);\n\n if(i === 0){\n aabb.copy(shapeAABB);\n } else {\n aabb.extend(shapeAABB);\n }\n }\n\n this.aabbNeedsUpdate = false;\n};\n\nvar uiw_m1 = new Mat3(),\n uiw_m2 = new Mat3(),\n uiw_m3 = new Mat3();\n\n/**\n * Update .inertiaWorld and .invInertiaWorld\n * @method updateInertiaWorld\n */\nBody.prototype.updateInertiaWorld = function(force){\n var I = this.invInertia;\n if (I.x === I.y && I.y === I.z && !force) {\n // If inertia M = s*I, where I is identity and s a scalar, then\n // R*M*R' = R*(s*I)*R' = s*R*I*R' = s*R*R' = s*I = M\n // where R is the rotation matrix.\n // In other words, we don't have to transform the inertia if all\n // inertia diagonal entries are equal.\n } else {\n var m1 = uiw_m1,\n m2 = uiw_m2,\n m3 = uiw_m3;\n m1.setRotationFromQuaternion(this.quaternion);\n m1.transpose(m2);\n m1.scale(I,m1);\n m1.mmult(m2,this.invInertiaWorld);\n //m3.getTrace(this.invInertiaWorld);\n }\n\n /*\n this.quaternion.vmult(this.inertia,this.inertiaWorld);\n this.quaternion.vmult(this.invInertia,this.invInertiaWorld);\n */\n};\n\n/**\n * Apply force to a world point. This could for example be a point on the Body surface. Applying force this way will add to Body.force and Body.torque.\n * @method applyForce\n * @param {Vec3} force The amount of force to add.\n * @param {Vec3} worldPoint A world point to apply the force on.\n */\nvar Body_applyForce_r = new Vec3();\nvar Body_applyForce_rotForce = new Vec3();\nBody.prototype.applyForce = function(force,worldPoint){\n if(this.type !== Body.DYNAMIC){\n return;\n }\n\n // Compute point position relative to the body center\n var r = Body_applyForce_r;\n worldPoint.vsub(this.position,r);\n\n // Compute produced rotational force\n var rotForce = Body_applyForce_rotForce;\n r.cross(force,rotForce);\n\n // Add linear force\n this.force.vadd(force,this.force);\n\n // Add rotational force\n this.torque.vadd(rotForce,this.torque);\n};\n\n/**\n * Apply force to a local point in the body.\n * @method applyLocalForce\n * @param {Vec3} force The force vector to apply, defined locally in the body frame.\n * @param {Vec3} localPoint A local point in the body to apply the force on.\n */\nvar Body_applyLocalForce_worldForce = new Vec3();\nvar Body_applyLocalForce_worldPoint = new Vec3();\nBody.prototype.applyLocalForce = function(localForce, localPoint){\n if(this.type !== Body.DYNAMIC){\n return;\n }\n\n var worldForce = Body_applyLocalForce_worldForce;\n var worldPoint = Body_applyLocalForce_worldPoint;\n\n // Transform the force vector to world space\n this.vectorToWorldFrame(localForce, worldForce);\n this.pointToWorldFrame(localPoint, worldPoint);\n\n this.applyForce(worldForce, worldPoint);\n};\n\n/**\n * Apply impulse to a world point. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity.\n * @method applyImpulse\n * @param {Vec3} impulse The amount of impulse to add.\n * @param {Vec3} worldPoint A world point to apply the force on.\n */\nvar Body_applyImpulse_r = new Vec3();\nvar Body_applyImpulse_velo = new Vec3();\nvar Body_applyImpulse_rotVelo = new Vec3();\nBody.prototype.applyImpulse = function(impulse, worldPoint){\n if(this.type !== Body.DYNAMIC){\n return;\n }\n\n // Compute point position relative to the body center\n var r = Body_applyImpulse_r;\n worldPoint.vsub(this.position,r);\n\n // Compute produced central impulse velocity\n var velo = Body_applyImpulse_velo;\n velo.copy(impulse);\n velo.mult(this.invMass,velo);\n\n // Add linear impulse\n this.velocity.vadd(velo, this.velocity);\n\n // Compute produced rotational impulse velocity\n var rotVelo = Body_applyImpulse_rotVelo;\n r.cross(impulse,rotVelo);\n\n /*\n rotVelo.x *= this.invInertia.x;\n rotVelo.y *= this.invInertia.y;\n rotVelo.z *= this.invInertia.z;\n */\n this.invInertiaWorld.vmult(rotVelo,rotVelo);\n\n // Add rotational Impulse\n this.angularVelocity.vadd(rotVelo, this.angularVelocity);\n};\n\n/**\n * Apply locally-defined impulse to a local point in the body.\n * @method applyLocalImpulse\n * @param {Vec3} force The force vector to apply, defined locally in the body frame.\n * @param {Vec3} localPoint A local point in the body to apply the force on.\n */\nvar Body_applyLocalImpulse_worldImpulse = new Vec3();\nvar Body_applyLocalImpulse_worldPoint = new Vec3();\nBody.prototype.applyLocalImpulse = function(localImpulse, localPoint){\n if(this.type !== Body.DYNAMIC){\n return;\n }\n\n var worldImpulse = Body_applyLocalImpulse_worldImpulse;\n var worldPoint = Body_applyLocalImpulse_worldPoint;\n\n // Transform the force vector to world space\n this.vectorToWorldFrame(localImpulse, worldImpulse);\n this.pointToWorldFrame(localPoint, worldPoint);\n\n this.applyImpulse(worldImpulse, worldPoint);\n};\n\nvar Body_updateMassProperties_halfExtents = new Vec3();\n\n/**\n * Should be called whenever you change the body shape or mass.\n * @method updateMassProperties\n */\nBody.prototype.updateMassProperties = function(){\n var halfExtents = Body_updateMassProperties_halfExtents;\n\n this.invMass = this.mass > 0 ? 1.0 / this.mass : 0;\n var I = this.inertia;\n var fixed = this.fixedRotation;\n\n // Approximate with AABB box\n this.computeAABB();\n halfExtents.set(\n (this.aabb.upperBound.x-this.aabb.lowerBound.x) / 2,\n (this.aabb.upperBound.y-this.aabb.lowerBound.y) / 2,\n (this.aabb.upperBound.z-this.aabb.lowerBound.z) / 2\n );\n Box.calculateInertia(halfExtents, this.mass, I);\n\n this.invInertia.set(\n I.x > 0 && !fixed ? 1.0 / I.x : 0,\n I.y > 0 && !fixed ? 1.0 / I.y : 0,\n I.z > 0 && !fixed ? 1.0 / I.z : 0\n );\n this.updateInertiaWorld(true);\n};\n\n/**\n * Get world velocity of a point in the body.\n * @method getVelocityAtWorldPoint\n * @param {Vec3} worldPoint\n * @param {Vec3} result\n * @return {Vec3} The result vector.\n */\nBody.prototype.getVelocityAtWorldPoint = function(worldPoint, result){\n var r = new Vec3();\n worldPoint.vsub(this.position, r);\n this.angularVelocity.cross(r, result);\n this.velocity.vadd(result, result);\n return result;\n};\n\n},{\"../collision/AABB\":3,\"../material/Material\":25,\"../math/Mat3\":27,\"../math/Quaternion\":28,\"../math/Vec3\":30,\"../shapes/Box\":37,\"../shapes/Shape\":43,\"../utils/EventTarget\":49}],32:[function(_dereq_,module,exports){\nvar Body = _dereq_('./Body');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar RaycastResult = _dereq_('../collision/RaycastResult');\nvar Ray = _dereq_('../collision/Ray');\nvar WheelInfo = _dereq_('../objects/WheelInfo');\n\nmodule.exports = RaycastVehicle;\n\n/**\n * Vehicle helper class that casts rays from the wheel positions towards the ground and applies forces.\n * @class RaycastVehicle\n * @constructor\n * @param {object} [options]\n * @param {Body} [options.chassisBody] The car chassis body.\n * @param {integer} [options.indexRightAxis] Axis to use for right. x=0, y=1, z=2\n * @param {integer} [options.indexLeftAxis]\n * @param {integer} [options.indexUpAxis]\n */\nfunction RaycastVehicle(options){\n\n /**\n * @property {Body} chassisBody\n */\n this.chassisBody = options.chassisBody;\n\n /**\n * An array of WheelInfo objects.\n * @property {array} wheelInfos\n */\n this.wheelInfos = [];\n\n /**\n * Will be set to true if the car is sliding.\n * @property {boolean} sliding\n */\n this.sliding = false;\n\n /**\n * @property {World} world\n */\n this.world = null;\n\n /**\n * Index of the right axis, 0=x, 1=y, 2=z\n * @property {integer} indexRightAxis\n * @default 1\n */\n this.indexRightAxis = typeof(options.indexRightAxis) !== 'undefined' ? options.indexRightAxis : 1;\n\n /**\n * Index of the forward axis, 0=x, 1=y, 2=z\n * @property {integer} indexForwardAxis\n * @default 0\n */\n this.indexForwardAxis = typeof(options.indexForwardAxis) !== 'undefined' ? options.indexForwardAxis : 0;\n\n /**\n * Index of the up axis, 0=x, 1=y, 2=z\n * @property {integer} indexUpAxis\n * @default 2\n */\n this.indexUpAxis = typeof(options.indexUpAxis) !== 'undefined' ? options.indexUpAxis : 2;\n}\n\nvar tmpVec1 = new Vec3();\nvar tmpVec2 = new Vec3();\nvar tmpVec3 = new Vec3();\nvar tmpVec4 = new Vec3();\nvar tmpVec5 = new Vec3();\nvar tmpVec6 = new Vec3();\nvar tmpRay = new Ray();\n\n/**\n * Add a wheel. For information about the options, see WheelInfo.\n * @method addWheel\n * @param {object} [options]\n */\nRaycastVehicle.prototype.addWheel = function(options){\n options = options || {};\n\n var info = new WheelInfo(options);\n var index = this.wheelInfos.length;\n this.wheelInfos.push(info);\n\n return index;\n};\n\n/**\n * Set the steering value of a wheel.\n * @method setSteeringValue\n * @param {number} value\n * @param {integer} wheelIndex\n */\nRaycastVehicle.prototype.setSteeringValue = function(value, wheelIndex){\n var wheel = this.wheelInfos[wheelIndex];\n wheel.steering = value;\n};\n\nvar torque = new Vec3();\n\n/**\n * Set the wheel force to apply on one of the wheels each time step\n * @method applyEngineForce\n * @param {number} value\n * @param {integer} wheelIndex\n */\nRaycastVehicle.prototype.applyEngineForce = function(value, wheelIndex){\n this.wheelInfos[wheelIndex].engineForce = value;\n};\n\n/**\n * Set the braking force of a wheel\n * @method setBrake\n * @param {number} brake\n * @param {integer} wheelIndex\n */\nRaycastVehicle.prototype.setBrake = function(brake, wheelIndex){\n this.wheelInfos[wheelIndex].brake = brake;\n};\n\n/**\n * Add the vehicle including its constraints to the world.\n * @method addToWorld\n * @param {World} world\n */\nRaycastVehicle.prototype.addToWorld = function(world){\n var constraints = this.constraints;\n world.add(this.chassisBody);\n var that = this;\n this.preStepCallback = function(){\n that.updateVehicle(world.dt);\n };\n world.addEventListener('preStep', this.preStepCallback);\n this.world = world;\n};\n\n/**\n * Get one of the wheel axles, world-oriented.\n * @private\n * @method getVehicleAxisWorld\n * @param {integer} axisIndex\n * @param {Vec3} result\n */\nRaycastVehicle.prototype.getVehicleAxisWorld = function(axisIndex, result){\n result.set(\n axisIndex === 0 ? 1 : 0,\n axisIndex === 1 ? 1 : 0,\n axisIndex === 2 ? 1 : 0\n );\n this.chassisBody.vectorToWorldFrame(result, result);\n};\n\nRaycastVehicle.prototype.updateVehicle = function(timeStep){\n var wheelInfos = this.wheelInfos;\n var numWheels = wheelInfos.length;\n var chassisBody = this.chassisBody;\n\n for (var i = 0; i < numWheels; i++) {\n this.updateWheelTransform(i);\n }\n\n this.currentVehicleSpeedKmHour = 3.6 * chassisBody.velocity.norm();\n\n var forwardWorld = new Vec3();\n this.getVehicleAxisWorld(this.indexForwardAxis, forwardWorld);\n\n if (forwardWorld.dot(chassisBody.velocity) < 0){\n this.currentVehicleSpeedKmHour *= -1;\n }\n\n // simulate suspension\n for (var i = 0; i < numWheels; i++) {\n this.castRay(wheelInfos[i]);\n }\n\n this.updateSuspension(timeStep);\n\n var impulse = new Vec3();\n var relpos = new Vec3();\n for (var i = 0; i < numWheels; i++) {\n //apply suspension force\n var wheel = wheelInfos[i];\n var suspensionForce = wheel.suspensionForce;\n if (suspensionForce > wheel.maxSuspensionForce) {\n suspensionForce = wheel.maxSuspensionForce;\n }\n wheel.raycastResult.hitNormalWorld.scale(suspensionForce * timeStep, impulse);\n\n wheel.raycastResult.hitPointWorld.vsub(chassisBody.position, relpos);\n chassisBody.applyImpulse(impulse, wheel.raycastResult.hitPointWorld/*relpos*/);\n }\n\n this.updateFriction(timeStep);\n\n var hitNormalWorldScaledWithProj = new Vec3();\n var fwd = new Vec3();\n var vel = new Vec3();\n for (i = 0; i < numWheels; i++) {\n var wheel = wheelInfos[i];\n //var relpos = new Vec3();\n //wheel.chassisConnectionPointWorld.vsub(chassisBody.position, relpos);\n chassisBody.getVelocityAtWorldPoint(wheel.chassisConnectionPointWorld, vel);\n\n // Hack to get the rotation in the correct direction\n var m = 1;\n switch(this.indexUpAxis){\n case 1:\n m = -1;\n break;\n }\n\n if (wheel.isInContact) {\n\n this.getVehicleAxisWorld(this.indexForwardAxis, fwd);\n var proj = fwd.dot(wheel.raycastResult.hitNormalWorld);\n wheel.raycastResult.hitNormalWorld.scale(proj, hitNormalWorldScaledWithProj);\n\n fwd.vsub(hitNormalWorldScaledWithProj, fwd);\n\n var proj2 = fwd.dot(vel);\n wheel.deltaRotation = m * proj2 * timeStep / wheel.radius;\n }\n\n if((wheel.sliding || !wheel.isInContact) && wheel.engineForce !== 0 && wheel.useCustomSlidingRotationalSpeed){\n // Apply custom rotation when accelerating and sliding\n wheel.deltaRotation = (wheel.engineForce > 0 ? 1 : -1) * wheel.customSlidingRotationalSpeed * timeStep;\n }\n\n // Lock wheels\n if(Math.abs(wheel.brake) > Math.abs(wheel.engineForce)){\n wheel.deltaRotation = 0;\n }\n\n wheel.rotation += wheel.deltaRotation; // Use the old value\n wheel.deltaRotation *= 0.99; // damping of rotation when not in contact\n }\n};\n\nRaycastVehicle.prototype.updateSuspension = function(deltaTime) {\n var chassisBody = this.chassisBody;\n var chassisMass = chassisBody.mass;\n var wheelInfos = this.wheelInfos;\n var numWheels = wheelInfos.length;\n\n for (var w_it = 0; w_it < numWheels; w_it++){\n var wheel = wheelInfos[w_it];\n\n if (wheel.isInContact){\n var force;\n\n // Spring\n var susp_length = wheel.suspensionRestLength;\n var current_length = wheel.suspensionLength;\n var length_diff = (susp_length - current_length);\n\n force = wheel.suspensionStiffness * length_diff * wheel.clippedInvContactDotSuspension;\n\n // Damper\n var projected_rel_vel = wheel.suspensionRelativeVelocity;\n var susp_damping;\n if (projected_rel_vel < 0) {\n susp_damping = wheel.dampingCompression;\n } else {\n susp_damping = wheel.dampingRelaxation;\n }\n force -= susp_damping * projected_rel_vel;\n\n wheel.suspensionForce = force * chassisMass;\n if (wheel.suspensionForce < 0) {\n wheel.suspensionForce = 0;\n }\n } else {\n wheel.suspensionForce = 0;\n }\n }\n};\n\n/**\n * Remove the vehicle including its constraints from the world.\n * @method removeFromWorld\n * @param {World} world\n */\nRaycastVehicle.prototype.removeFromWorld = function(world){\n var constraints = this.constraints;\n world.remove(this.chassisBody);\n world.removeEventListener('preStep', this.preStepCallback);\n this.world = null;\n};\n\nvar castRay_rayvector = new Vec3();\nvar castRay_target = new Vec3();\nRaycastVehicle.prototype.castRay = function(wheel) {\n var rayvector = castRay_rayvector;\n var target = castRay_target;\n\n this.updateWheelTransformWorld(wheel);\n var chassisBody = this.chassisBody;\n\n var depth = -1;\n\n var raylen = wheel.suspensionRestLength + wheel.radius;\n\n wheel.directionWorld.scale(raylen, rayvector);\n var source = wheel.chassisConnectionPointWorld;\n source.vadd(rayvector, target);\n var raycastResult = wheel.raycastResult;\n\n var param = 0;\n\n raycastResult.reset();\n // Turn off ray collision with the chassis temporarily\n var oldState = chassisBody.collisionResponse;\n chassisBody.collisionResponse = false;\n\n // Cast ray against world\n this.world.rayTest(source, target, raycastResult);\n chassisBody.collisionResponse = oldState;\n\n var object = raycastResult.body;\n\n wheel.raycastResult.groundObject = 0;\n\n if (object) {\n depth = raycastResult.distance;\n wheel.raycastResult.hitNormalWorld = raycastResult.hitNormalWorld;\n wheel.isInContact = true;\n\n var hitDistance = raycastResult.distance;\n wheel.suspensionLength = hitDistance - wheel.radius;\n\n // clamp on max suspension travel\n var minSuspensionLength = wheel.suspensionRestLength - wheel.maxSuspensionTravel;\n var maxSuspensionLength = wheel.suspensionRestLength + wheel.maxSuspensionTravel;\n if (wheel.suspensionLength < minSuspensionLength) {\n wheel.suspensionLength = minSuspensionLength;\n }\n if (wheel.suspensionLength > maxSuspensionLength) {\n wheel.suspensionLength = maxSuspensionLength;\n wheel.raycastResult.reset();\n }\n\n var denominator = wheel.raycastResult.hitNormalWorld.dot(wheel.directionWorld);\n\n var chassis_velocity_at_contactPoint = new Vec3();\n chassisBody.getVelocityAtWorldPoint(wheel.raycastResult.hitPointWorld, chassis_velocity_at_contactPoint);\n\n var projVel = wheel.raycastResult.hitNormalWorld.dot( chassis_velocity_at_contactPoint );\n\n if (denominator >= -0.1) {\n wheel.suspensionRelativeVelocity = 0;\n wheel.clippedInvContactDotSuspension = 1 / 0.1;\n } else {\n var inv = -1 / denominator;\n wheel.suspensionRelativeVelocity = projVel * inv;\n wheel.clippedInvContactDotSuspension = inv;\n }\n\n } else {\n\n //put wheel info as in rest position\n wheel.suspensionLength = wheel.suspensionRestLength + 0 * wheel.maxSuspensionTravel;\n wheel.suspensionRelativeVelocity = 0.0;\n wheel.directionWorld.scale(-1, wheel.raycastResult.hitNormalWorld);\n wheel.clippedInvContactDotSuspension = 1.0;\n }\n\n return depth;\n};\n\nRaycastVehicle.prototype.updateWheelTransformWorld = function(wheel){\n wheel.isInContact = false;\n var chassisBody = this.chassisBody;\n chassisBody.pointToWorldFrame(wheel.chassisConnectionPointLocal, wheel.chassisConnectionPointWorld);\n chassisBody.vectorToWorldFrame(wheel.directionLocal, wheel.directionWorld);\n chassisBody.vectorToWorldFrame(wheel.axleLocal, wheel.axleWorld);\n};\n\n\n/**\n * Update one of the wheel transform.\n * Note when rendering wheels: during each step, wheel transforms are updated BEFORE the chassis; ie. their position becomes invalid after the step. Thus when you render wheels, you must update wheel transforms before rendering them. See raycastVehicle demo for an example.\n * @method updateWheelTransform\n * @param {integer} wheelIndex The wheel index to update.\n */\nRaycastVehicle.prototype.updateWheelTransform = function(wheelIndex){\n var up = tmpVec4;\n var right = tmpVec5;\n var fwd = tmpVec6;\n\n var wheel = this.wheelInfos[wheelIndex];\n this.updateWheelTransformWorld(wheel);\n\n wheel.directionLocal.scale(-1, up);\n right.copy(wheel.axleLocal);\n up.cross(right, fwd);\n fwd.normalize();\n right.normalize();\n\n // Rotate around steering over the wheelAxle\n var steering = wheel.steering;\n var steeringOrn = new Quaternion();\n steeringOrn.setFromAxisAngle(up, steering);\n\n var rotatingOrn = new Quaternion();\n rotatingOrn.setFromAxisAngle(right, wheel.rotation);\n\n // World rotation of the wheel\n var q = wheel.worldTransform.quaternion;\n this.chassisBody.quaternion.mult(steeringOrn, q);\n q.mult(rotatingOrn, q);\n\n q.normalize();\n\n // world position of the wheel\n var p = wheel.worldTransform.position;\n p.copy(wheel.directionWorld);\n p.scale(wheel.suspensionLength, p);\n p.vadd(wheel.chassisConnectionPointWorld, p);\n};\n\nvar directions = [\n new Vec3(1, 0, 0),\n new Vec3(0, 1, 0),\n new Vec3(0, 0, 1)\n];\n\n/**\n * Get the world transform of one of the wheels\n * @method getWheelTransformWorld\n * @param {integer} wheelIndex\n * @return {Transform}\n */\nRaycastVehicle.prototype.getWheelTransformWorld = function(wheelIndex) {\n return this.wheelInfos[wheelIndex].worldTransform;\n};\n\n\nvar updateFriction_surfNormalWS_scaled_proj = new Vec3();\nvar updateFriction_axle = [];\nvar updateFriction_forwardWS = [];\nvar sideFrictionStiffness2 = 1;\nRaycastVehicle.prototype.updateFriction = function(timeStep) {\n var surfNormalWS_scaled_proj = updateFriction_surfNormalWS_scaled_proj;\n\n //calculate the impulse, so that the wheels don't move sidewards\n var wheelInfos = this.wheelInfos;\n var numWheels = wheelInfos.length;\n var chassisBody = this.chassisBody;\n var forwardWS = updateFriction_forwardWS;\n var axle = updateFriction_axle;\n\n var numWheelsOnGround = 0;\n\n for (var i = 0; i < numWheels; i++) {\n var wheel = wheelInfos[i];\n\n var groundObject = wheel.raycastResult.body;\n if (groundObject){\n numWheelsOnGround++;\n }\n\n wheel.sideImpulse = 0;\n wheel.forwardImpulse = 0;\n if(!forwardWS[i]){\n forwardWS[i] = new Vec3();\n }\n if(!axle[i]){\n axle[i] = new Vec3();\n }\n }\n\n for (var i = 0; i < numWheels; i++){\n var wheel = wheelInfos[i];\n\n var groundObject = wheel.raycastResult.body;\n\n if (groundObject) {\n var axlei = axle[i];\n var wheelTrans = this.getWheelTransformWorld(i);\n\n // Get world axle\n wheelTrans.vectorToWorldFrame(directions[this.indexRightAxis], axlei);\n\n var surfNormalWS = wheel.raycastResult.hitNormalWorld;\n var proj = axlei.dot(surfNormalWS);\n surfNormalWS.scale(proj, surfNormalWS_scaled_proj);\n axlei.vsub(surfNormalWS_scaled_proj, axlei);\n axlei.normalize();\n\n surfNormalWS.cross(axlei, forwardWS[i]);\n forwardWS[i].normalize();\n\n wheel.sideImpulse = resolveSingleBilateral(\n chassisBody,\n wheel.raycastResult.hitPointWorld,\n groundObject,\n wheel.raycastResult.hitPointWorld,\n axlei\n );\n\n wheel.sideImpulse *= sideFrictionStiffness2;\n }\n }\n\n var sideFactor = 1;\n var fwdFactor = 0.5;\n\n this.sliding = false;\n for (var i = 0; i < numWheels; i++) {\n var wheel = wheelInfos[i];\n var groundObject = wheel.raycastResult.body;\n\n var rollingFriction = 0;\n\n wheel.slipInfo = 1;\n if (groundObject) {\n var defaultRollingFrictionImpulse = 0;\n var maxImpulse = wheel.brake ? wheel.brake : defaultRollingFrictionImpulse;\n\n // btWheelContactPoint contactPt(chassisBody,groundObject,wheelInfraycastInfo.hitPointWorld,forwardWS[wheel],maxImpulse);\n // rollingFriction = calcRollingFriction(contactPt);\n rollingFriction = calcRollingFriction(chassisBody, groundObject, wheel.raycastResult.hitPointWorld, forwardWS[i], maxImpulse);\n\n rollingFriction += wheel.engineForce * timeStep;\n\n // rollingFriction = 0;\n var factor = maxImpulse / rollingFriction;\n wheel.slipInfo *= factor;\n }\n\n //switch between active rolling (throttle), braking and non-active rolling friction (nthrottle/break)\n\n wheel.forwardImpulse = 0;\n wheel.skidInfo = 1;\n\n if (groundObject) {\n wheel.skidInfo = 1;\n\n var maximp = wheel.suspensionForce * timeStep * wheel.frictionSlip;\n var maximpSide = maximp;\n\n var maximpSquared = maximp * maximpSide;\n\n wheel.forwardImpulse = rollingFriction;//wheelInfo.engineForce* timeStep;\n\n var x = wheel.forwardImpulse * fwdFactor;\n var y = wheel.sideImpulse * sideFactor;\n\n var impulseSquared = x * x + y * y;\n\n wheel.sliding = false;\n if (impulseSquared > maximpSquared) {\n this.sliding = true;\n wheel.sliding = true;\n\n var factor = maximp / Math.sqrt(impulseSquared);\n\n wheel.skidInfo *= factor;\n }\n }\n }\n\n if (this.sliding) {\n for (var i = 0; i < numWheels; i++) {\n var wheel = wheelInfos[i];\n if (wheel.sideImpulse !== 0) {\n if (wheel.skidInfo < 1){\n wheel.forwardImpulse *= wheel.skidInfo;\n wheel.sideImpulse *= wheel.skidInfo;\n }\n }\n }\n }\n\n // apply the impulses\n for (var i = 0; i < numWheels; i++) {\n var wheel = wheelInfos[i];\n\n var rel_pos = new Vec3();\n //wheel.raycastResult.hitPointWorld.vsub(chassisBody.position, rel_pos);\n // cannons applyimpulse is using world coord for the position\n rel_pos.copy(wheel.raycastResult.hitPointWorld);\n\n if (wheel.forwardImpulse !== 0) {\n var impulse = new Vec3();\n forwardWS[i].scale(wheel.forwardImpulse, impulse);\n chassisBody.applyImpulse(impulse, rel_pos);\n }\n\n if (wheel.sideImpulse !== 0){\n var groundObject = wheel.raycastResult.body;\n\n var rel_pos2 = new Vec3();\n //wheel.raycastResult.hitPointWorld.vsub(groundObject.position, rel_pos2);\n rel_pos2.copy(wheel.raycastResult.hitPointWorld);\n var sideImp = new Vec3();\n axle[i].scale(wheel.sideImpulse, sideImp);\n\n // Scale the relative position in the up direction with rollInfluence.\n // If rollInfluence is 1, the impulse will be applied on the hitPoint (easy to roll over), if it is zero it will be applied in the same plane as the center of mass (not easy to roll over).\n chassisBody.pointToLocalFrame(rel_pos, rel_pos);\n rel_pos['xyz'[this.indexUpAxis]] *= wheel.rollInfluence;\n chassisBody.pointToWorldFrame(rel_pos, rel_pos);\n chassisBody.applyImpulse(sideImp, rel_pos);\n\n //apply friction impulse on the ground\n sideImp.scale(-1, sideImp);\n groundObject.applyImpulse(sideImp, rel_pos2);\n }\n }\n};\n\nvar calcRollingFriction_vel1 = new Vec3();\nvar calcRollingFriction_vel2 = new Vec3();\nvar calcRollingFriction_vel = new Vec3();\n\nfunction calcRollingFriction(body0, body1, frictionPosWorld, frictionDirectionWorld, maxImpulse) {\n var j1 = 0;\n var contactPosWorld = frictionPosWorld;\n\n // var rel_pos1 = new Vec3();\n // var rel_pos2 = new Vec3();\n var vel1 = calcRollingFriction_vel1;\n var vel2 = calcRollingFriction_vel2;\n var vel = calcRollingFriction_vel;\n // contactPosWorld.vsub(body0.position, rel_pos1);\n // contactPosWorld.vsub(body1.position, rel_pos2);\n\n body0.getVelocityAtWorldPoint(contactPosWorld, vel1);\n body1.getVelocityAtWorldPoint(contactPosWorld, vel2);\n vel1.vsub(vel2, vel);\n\n var vrel = frictionDirectionWorld.dot(vel);\n\n var denom0 = computeImpulseDenominator(body0, frictionPosWorld, frictionDirectionWorld);\n var denom1 = computeImpulseDenominator(body1, frictionPosWorld, frictionDirectionWorld);\n var relaxation = 1;\n var jacDiagABInv = relaxation / (denom0 + denom1);\n\n // calculate j that moves us to zero relative velocity\n j1 = -vrel * jacDiagABInv;\n\n if (maxImpulse < j1) {\n j1 = maxImpulse;\n }\n if (j1 < -maxImpulse) {\n j1 = -maxImpulse;\n }\n\n return j1;\n}\n\nvar computeImpulseDenominator_r0 = new Vec3();\nvar computeImpulseDenominator_c0 = new Vec3();\nvar computeImpulseDenominator_vec = new Vec3();\nvar computeImpulseDenominator_m = new Vec3();\nfunction computeImpulseDenominator(body, pos, normal) {\n var r0 = computeImpulseDenominator_r0;\n var c0 = computeImpulseDenominator_c0;\n var vec = computeImpulseDenominator_vec;\n var m = computeImpulseDenominator_m;\n\n pos.vsub(body.position, r0);\n r0.cross(normal, c0);\n body.invInertiaWorld.vmult(c0, m);\n m.cross(r0, vec);\n\n return body.invMass + normal.dot(vec);\n}\n\n\nvar resolveSingleBilateral_vel1 = new Vec3();\nvar resolveSingleBilateral_vel2 = new Vec3();\nvar resolveSingleBilateral_vel = new Vec3();\n\n//bilateral constraint between two dynamic objects\nfunction resolveSingleBilateral(body1, pos1, body2, pos2, normal, impulse){\n var normalLenSqr = normal.norm2();\n if (normalLenSqr > 1.1){\n return 0; // no impulse\n }\n // var rel_pos1 = new Vec3();\n // var rel_pos2 = new Vec3();\n // pos1.vsub(body1.position, rel_pos1);\n // pos2.vsub(body2.position, rel_pos2);\n\n var vel1 = resolveSingleBilateral_vel1;\n var vel2 = resolveSingleBilateral_vel2;\n var vel = resolveSingleBilateral_vel;\n body1.getVelocityAtWorldPoint(pos1, vel1);\n body2.getVelocityAtWorldPoint(pos2, vel2);\n\n vel1.vsub(vel2, vel);\n\n var rel_vel = normal.dot(vel);\n\n var contactDamping = 0.2;\n var massTerm = 1 / (body1.invMass + body2.invMass);\n var impulse = - contactDamping * rel_vel * massTerm;\n\n return impulse;\n}\n},{\"../collision/Ray\":9,\"../collision/RaycastResult\":10,\"../math/Quaternion\":28,\"../math/Vec3\":30,\"../objects/WheelInfo\":36,\"./Body\":31}],33:[function(_dereq_,module,exports){\nvar Body = _dereq_('./Body');\nvar Sphere = _dereq_('../shapes/Sphere');\nvar Box = _dereq_('../shapes/Box');\nvar Vec3 = _dereq_('../math/Vec3');\nvar HingeConstraint = _dereq_('../constraints/HingeConstraint');\n\nmodule.exports = RigidVehicle;\n\n/**\n * Simple vehicle helper class with spherical rigid body wheels.\n * @class RigidVehicle\n * @constructor\n * @param {Body} [options.chassisBody]\n */\nfunction RigidVehicle(options){\n this.wheelBodies = [];\n\n /**\n * @property coordinateSystem\n * @type {Vec3}\n */\n this.coordinateSystem = typeof(options.coordinateSystem)==='undefined' ? new Vec3(1, 2, 3) : options.coordinateSystem.clone();\n\n /**\n * @property {Body} chassisBody\n */\n this.chassisBody = options.chassisBody;\n\n if(!this.chassisBody){\n // No chassis body given. Create it!\n var chassisShape = new Box(new Vec3(5, 2, 0.5));\n this.chassisBody = new Body(1, chassisShape);\n }\n\n /**\n * @property constraints\n * @type {Array}\n */\n this.constraints = [];\n\n this.wheelAxes = [];\n this.wheelForces = [];\n}\n\n/**\n * Add a wheel\n * @method addWheel\n * @param {object} options\n * @param {boolean} [options.isFrontWheel]\n * @param {Vec3} [options.position] Position of the wheel, locally in the chassis body.\n * @param {Vec3} [options.direction] Slide direction of the wheel along the suspension.\n * @param {Vec3} [options.axis] Axis of rotation of the wheel, locally defined in the chassis.\n * @param {Body} [options.body] The wheel body.\n */\nRigidVehicle.prototype.addWheel = function(options){\n options = options || {};\n var wheelBody = options.body;\n if(!wheelBody){\n wheelBody = new Body(1, new Sphere(1.2));\n }\n this.wheelBodies.push(wheelBody);\n this.wheelForces.push(0);\n\n // Position constrain wheels\n var zero = new Vec3();\n var position = typeof(options.position) !== 'undefined' ? options.position.clone() : new Vec3();\n\n // Set position locally to the chassis\n var worldPosition = new Vec3();\n this.chassisBody.pointToWorldFrame(position, worldPosition);\n wheelBody.position.set(worldPosition.x, worldPosition.y, worldPosition.z);\n\n // Constrain wheel\n var axis = typeof(options.axis) !== 'undefined' ? options.axis.clone() : new Vec3(0, 1, 0);\n this.wheelAxes.push(axis);\n\n var hingeConstraint = new HingeConstraint(this.chassisBody, wheelBody, {\n pivotA: position,\n axisA: axis,\n pivotB: Vec3.ZERO,\n axisB: axis,\n collideConnected: false\n });\n this.constraints.push(hingeConstraint);\n\n return this.wheelBodies.length - 1;\n};\n\n/**\n * Set the steering value of a wheel.\n * @method setSteeringValue\n * @param {number} value\n * @param {integer} wheelIndex\n * @todo check coordinateSystem\n */\nRigidVehicle.prototype.setSteeringValue = function(value, wheelIndex){\n // Set angle of the hinge axis\n var axis = this.wheelAxes[wheelIndex];\n\n var c = Math.cos(value),\n s = Math.sin(value),\n x = axis.x,\n y = axis.y;\n this.constraints[wheelIndex].axisA.set(\n c*x -s*y,\n s*x +c*y,\n 0\n );\n};\n\n/**\n * Set the target rotational speed of the hinge constraint.\n * @method setMotorSpeed\n * @param {number} value\n * @param {integer} wheelIndex\n */\nRigidVehicle.prototype.setMotorSpeed = function(value, wheelIndex){\n var hingeConstraint = this.constraints[wheelIndex];\n hingeConstraint.enableMotor();\n hingeConstraint.motorTargetVelocity = value;\n};\n\n/**\n * Set the target rotational speed of the hinge constraint.\n * @method disableMotor\n * @param {number} value\n * @param {integer} wheelIndex\n */\nRigidVehicle.prototype.disableMotor = function(wheelIndex){\n var hingeConstraint = this.constraints[wheelIndex];\n hingeConstraint.disableMotor();\n};\n\nvar torque = new Vec3();\n\n/**\n * Set the wheel force to apply on one of the wheels each time step\n * @method setWheelForce\n * @param {number} value\n * @param {integer} wheelIndex\n */\nRigidVehicle.prototype.setWheelForce = function(value, wheelIndex){\n this.wheelForces[wheelIndex] = value;\n};\n\n/**\n * Apply a torque on one of the wheels.\n * @method applyWheelForce\n * @param {number} value\n * @param {integer} wheelIndex\n */\nRigidVehicle.prototype.applyWheelForce = function(value, wheelIndex){\n var axis = this.wheelAxes[wheelIndex];\n var wheelBody = this.wheelBodies[wheelIndex];\n var bodyTorque = wheelBody.torque;\n\n axis.scale(value, torque);\n wheelBody.vectorToWorldFrame(torque, torque);\n bodyTorque.vadd(torque, bodyTorque);\n};\n\n/**\n * Add the vehicle including its constraints to the world.\n * @method addToWorld\n * @param {World} world\n */\nRigidVehicle.prototype.addToWorld = function(world){\n var constraints = this.constraints;\n var bodies = this.wheelBodies.concat([this.chassisBody]);\n\n for (var i = 0; i < bodies.length; i++) {\n world.add(bodies[i]);\n }\n\n for (var i = 0; i < constraints.length; i++) {\n world.addConstraint(constraints[i]);\n }\n\n world.addEventListener('preStep', this._update.bind(this));\n};\n\nRigidVehicle.prototype._update = function(){\n var wheelForces = this.wheelForces;\n for (var i = 0; i < wheelForces.length; i++) {\n this.applyWheelForce(wheelForces[i], i);\n }\n};\n\n/**\n * Remove the vehicle including its constraints from the world.\n * @method removeFromWorld\n * @param {World} world\n */\nRigidVehicle.prototype.removeFromWorld = function(world){\n var constraints = this.constraints;\n var bodies = this.wheelBodies.concat([this.chassisBody]);\n\n for (var i = 0; i < bodies.length; i++) {\n world.remove(bodies[i]);\n }\n\n for (var i = 0; i < constraints.length; i++) {\n world.removeConstraint(constraints[i]);\n }\n};\n\nvar worldAxis = new Vec3();\n\n/**\n * Get current rotational velocity of a wheel\n * @method getWheelSpeed\n * @param {integer} wheelIndex\n */\nRigidVehicle.prototype.getWheelSpeed = function(wheelIndex){\n var axis = this.wheelAxes[wheelIndex];\n var wheelBody = this.wheelBodies[wheelIndex];\n var w = wheelBody.angularVelocity;\n this.chassisBody.vectorToWorldFrame(axis, worldAxis);\n return w.dot(worldAxis);\n};\n\n},{\"../constraints/HingeConstraint\":15,\"../math/Vec3\":30,\"../shapes/Box\":37,\"../shapes/Sphere\":44,\"./Body\":31}],34:[function(_dereq_,module,exports){\nmodule.exports = SPHSystem;\n\nvar Shape = _dereq_('../shapes/Shape');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Particle = _dereq_('../shapes/Particle');\nvar Body = _dereq_('../objects/Body');\nvar Material = _dereq_('../material/Material');\n\n/**\n * Smoothed-particle hydrodynamics system\n * @class SPHSystem\n * @constructor\n */\nfunction SPHSystem(){\n this.particles = [];\n\t\n /**\n * Density of the system (kg/m3).\n * @property {number} density\n */\n this.density = 1;\n\t\n /**\n * Distance below which two particles are considered to be neighbors.\n * It should be adjusted so there are about 15-20 neighbor particles within this radius.\n * @property {number} smoothingRadius\n */\n this.smoothingRadius = 1;\n this.speedOfSound = 1;\n\t\n /**\n * Viscosity of the system.\n * @property {number} viscosity\n */\n this.viscosity = 0.01;\n this.eps = 0.000001;\n\n // Stuff Computed per particle\n this.pressures = [];\n this.densities = [];\n this.neighbors = [];\n}\n\n/**\n * Add a particle to the system.\n * @method add\n * @param {Body} particle\n */\nSPHSystem.prototype.add = function(particle){\n this.particles.push(particle);\n if(this.neighbors.length < this.particles.length){\n this.neighbors.push([]);\n }\n};\n\n/**\n * Remove a particle from the system.\n * @method remove\n * @param {Body} particle\n */\nSPHSystem.prototype.remove = function(particle){\n var idx = this.particles.indexOf(particle);\n if(idx !== -1){\n this.particles.splice(idx,1);\n if(this.neighbors.length > this.particles.length){\n this.neighbors.pop();\n }\n }\n};\n\n/**\n * Get neighbors within smoothing volume, save in the array neighbors\n * @method getNeighbors\n * @param {Body} particle\n * @param {Array} neighbors\n */\nvar SPHSystem_getNeighbors_dist = new Vec3();\nSPHSystem.prototype.getNeighbors = function(particle,neighbors){\n var N = this.particles.length,\n id = particle.id,\n R2 = this.smoothingRadius * this.smoothingRadius,\n dist = SPHSystem_getNeighbors_dist;\n for(var i=0; i!==N; i++){\n var p = this.particles[i];\n p.position.vsub(particle.position,dist);\n if(id!==p.id && dist.norm2() < R2){\n neighbors.push(p);\n }\n }\n};\n\n// Temp vectors for calculation\nvar SPHSystem_update_dist = new Vec3(),\n SPHSystem_update_a_pressure = new Vec3(),\n SPHSystem_update_a_visc = new Vec3(),\n SPHSystem_update_gradW = new Vec3(),\n SPHSystem_update_r_vec = new Vec3(),\n SPHSystem_update_u = new Vec3(); // Relative velocity\nSPHSystem.prototype.update = function(){\n var N = this.particles.length,\n dist = SPHSystem_update_dist,\n cs = this.speedOfSound,\n eps = this.eps;\n\n for(var i=0; i!==N; i++){\n var p = this.particles[i]; // Current particle\n var neighbors = this.neighbors[i];\n\n // Get neighbors\n neighbors.length = 0;\n this.getNeighbors(p,neighbors);\n neighbors.push(this.particles[i]); // Add current too\n var numNeighbors = neighbors.length;\n\n // Accumulate density for the particle\n var sum = 0.0;\n for(var j=0; j!==numNeighbors; j++){\n\n //printf(\"Current particle has position %f %f %f\\n\",objects[id].pos.x(),objects[id].pos.y(),objects[id].pos.z());\n p.position.vsub(neighbors[j].position, dist);\n var len = dist.norm();\n\n var weight = this.w(len);\n sum += neighbors[j].mass * weight;\n }\n\n // Save\n this.densities[i] = sum;\n this.pressures[i] = cs * cs * (this.densities[i] - this.density);\n }\n\n // Add forces\n\n // Sum to these accelerations\n var a_pressure= SPHSystem_update_a_pressure;\n var a_visc = SPHSystem_update_a_visc;\n var gradW = SPHSystem_update_gradW;\n var r_vec = SPHSystem_update_r_vec;\n var u = SPHSystem_update_u;\n\n for(var i=0; i!==N; i++){\n\n var particle = this.particles[i];\n\n a_pressure.set(0,0,0);\n a_visc.set(0,0,0);\n\n // Init vars\n var Pij;\n var nabla;\n var Vij;\n\n // Sum up for all other neighbors\n var neighbors = this.neighbors[i];\n var numNeighbors = neighbors.length;\n\n //printf(\"Neighbors: \");\n for(var j=0; j!==numNeighbors; j++){\n\n var neighbor = neighbors[j];\n //printf(\"%d \",nj);\n\n // Get r once for all..\n particle.position.vsub(neighbor.position,r_vec);\n var r = r_vec.norm();\n\n // Pressure contribution\n Pij = -neighbor.mass * (this.pressures[i] / (this.densities[i]*this.densities[i] + eps) + this.pressures[j] / (this.densities[j]*this.densities[j] + eps));\n this.gradw(r_vec, gradW);\n // Add to pressure acceleration\n gradW.mult(Pij , gradW);\n a_pressure.vadd(gradW, a_pressure);\n\n // Viscosity contribution\n neighbor.velocity.vsub(particle.velocity, u);\n u.mult( 1.0 / (0.0001+this.densities[i] * this.densities[j]) * this.viscosity * neighbor.mass , u );\n nabla = this.nablaw(r);\n u.mult(nabla,u);\n // Add to viscosity acceleration\n a_visc.vadd( u, a_visc );\n }\n\n // Calculate force\n a_visc.mult(particle.mass, a_visc);\n a_pressure.mult(particle.mass, a_pressure);\n\n // Add force to particles\n particle.force.vadd(a_visc, particle.force);\n particle.force.vadd(a_pressure, particle.force);\n }\n};\n\n// Calculate the weight using the W(r) weightfunction\nSPHSystem.prototype.w = function(r){\n // 315\n var h = this.smoothingRadius;\n return 315.0/(64.0*Math.PI*Math.pow(h,9)) * Math.pow(h*h-r*r,3);\n};\n\n// calculate gradient of the weight function\nSPHSystem.prototype.gradw = function(rVec,resultVec){\n var r = rVec.norm(),\n h = this.smoothingRadius;\n rVec.mult(945.0/(32.0*Math.PI*Math.pow(h,9)) * Math.pow((h*h-r*r),2) , resultVec);\n};\n\n// Calculate nabla(W)\nSPHSystem.prototype.nablaw = function(r){\n var h = this.smoothingRadius;\n var nabla = 945.0/(32.0*Math.PI*Math.pow(h,9)) * (h*h-r*r)*(7*r*r - 3*h*h);\n return nabla;\n};\n\n},{\"../material/Material\":25,\"../math/Quaternion\":28,\"../math/Vec3\":30,\"../objects/Body\":31,\"../shapes/Particle\":41,\"../shapes/Shape\":43}],35:[function(_dereq_,module,exports){\nvar Vec3 = _dereq_('../math/Vec3');\n\nmodule.exports = Spring;\n\n/**\n * A spring, connecting two bodies.\n *\n * @class Spring\n * @constructor\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {Object} [options]\n * @param {number} [options.restLength] A number > 0. Default: 1\n * @param {number} [options.stiffness] A number >= 0. Default: 100\n * @param {number} [options.damping] A number >= 0. Default: 1\n * @param {Vec3} [options.worldAnchorA] Where to hook the spring to body A, in world coordinates.\n * @param {Vec3} [options.worldAnchorB]\n * @param {Vec3} [options.localAnchorA] Where to hook the spring to body A, in local body coordinates.\n * @param {Vec3} [options.localAnchorB]\n */\nfunction Spring(bodyA,bodyB,options){\n options = options || {};\n\n /**\n * Rest length of the spring.\n * @property restLength\n * @type {number}\n */\n this.restLength = typeof(options.restLength) === \"number\" ? options.restLength : 1;\n\n /**\n * Stiffness of the spring.\n * @property stiffness\n * @type {number}\n */\n this.stiffness = options.stiffness || 100;\n\n /**\n * Damping of the spring.\n * @property damping\n * @type {number}\n */\n this.damping = options.damping || 1;\n\n /**\n * First connected body.\n * @property bodyA\n * @type {Body}\n */\n this.bodyA = bodyA;\n\n /**\n * Second connected body.\n * @property bodyB\n * @type {Body}\n */\n this.bodyB = bodyB;\n\n /**\n * Anchor for bodyA in local bodyA coordinates.\n * @property localAnchorA\n * @type {Vec3}\n */\n this.localAnchorA = new Vec3();\n\n /**\n * Anchor for bodyB in local bodyB coordinates.\n * @property localAnchorB\n * @type {Vec3}\n */\n this.localAnchorB = new Vec3();\n\n if(options.localAnchorA){\n this.localAnchorA.copy(options.localAnchorA);\n }\n if(options.localAnchorB){\n this.localAnchorB.copy(options.localAnchorB);\n }\n if(options.worldAnchorA){\n this.setWorldAnchorA(options.worldAnchorA);\n }\n if(options.worldAnchorB){\n this.setWorldAnchorB(options.worldAnchorB);\n }\n}\n\n/**\n * Set the anchor point on body A, using world coordinates.\n * @method setWorldAnchorA\n * @param {Vec3} worldAnchorA\n */\nSpring.prototype.setWorldAnchorA = function(worldAnchorA){\n this.bodyA.pointToLocalFrame(worldAnchorA,this.localAnchorA);\n};\n\n/**\n * Set the anchor point on body B, using world coordinates.\n * @method setWorldAnchorB\n * @param {Vec3} worldAnchorB\n */\nSpring.prototype.setWorldAnchorB = function(worldAnchorB){\n this.bodyB.pointToLocalFrame(worldAnchorB,this.localAnchorB);\n};\n\n/**\n * Get the anchor point on body A, in world coordinates.\n * @method getWorldAnchorA\n * @param {Vec3} result The vector to store the result in.\n */\nSpring.prototype.getWorldAnchorA = function(result){\n this.bodyA.pointToWorldFrame(this.localAnchorA,result);\n};\n\n/**\n * Get the anchor point on body B, in world coordinates.\n * @method getWorldAnchorB\n * @param {Vec3} result The vector to store the result in.\n */\nSpring.prototype.getWorldAnchorB = function(result){\n this.bodyB.pointToWorldFrame(this.localAnchorB,result);\n};\n\nvar applyForce_r = new Vec3(),\n applyForce_r_unit = new Vec3(),\n applyForce_u = new Vec3(),\n applyForce_f = new Vec3(),\n applyForce_worldAnchorA = new Vec3(),\n applyForce_worldAnchorB = new Vec3(),\n applyForce_ri = new Vec3(),\n applyForce_rj = new Vec3(),\n applyForce_ri_x_f = new Vec3(),\n applyForce_rj_x_f = new Vec3(),\n applyForce_tmp = new Vec3();\n\n/**\n * Apply the spring force to the connected bodies.\n * @method applyForce\n */\nSpring.prototype.applyForce = function(){\n var k = this.stiffness,\n d = this.damping,\n l = this.restLength,\n bodyA = this.bodyA,\n bodyB = this.bodyB,\n r = applyForce_r,\n r_unit = applyForce_r_unit,\n u = applyForce_u,\n f = applyForce_f,\n tmp = applyForce_tmp;\n\n var worldAnchorA = applyForce_worldAnchorA,\n worldAnchorB = applyForce_worldAnchorB,\n ri = applyForce_ri,\n rj = applyForce_rj,\n ri_x_f = applyForce_ri_x_f,\n rj_x_f = applyForce_rj_x_f;\n\n // Get world anchors\n this.getWorldAnchorA(worldAnchorA);\n this.getWorldAnchorB(worldAnchorB);\n\n // Get offset points\n worldAnchorA.vsub(bodyA.position,ri);\n worldAnchorB.vsub(bodyB.position,rj);\n\n // Compute distance vector between world anchor points\n worldAnchorB.vsub(worldAnchorA,r);\n var rlen = r.norm();\n r_unit.copy(r);\n r_unit.normalize();\n\n // Compute relative velocity of the anchor points, u\n bodyB.velocity.vsub(bodyA.velocity,u);\n // Add rotational velocity\n\n bodyB.angularVelocity.cross(rj,tmp);\n u.vadd(tmp,u);\n bodyA.angularVelocity.cross(ri,tmp);\n u.vsub(tmp,u);\n\n // F = - k * ( x - L ) - D * ( u )\n r_unit.mult(-k*(rlen-l) - d*u.dot(r_unit), f);\n\n // Add forces to bodies\n bodyA.force.vsub(f,bodyA.force);\n bodyB.force.vadd(f,bodyB.force);\n\n // Angular force\n ri.cross(f,ri_x_f);\n rj.cross(f,rj_x_f);\n bodyA.torque.vsub(ri_x_f,bodyA.torque);\n bodyB.torque.vadd(rj_x_f,bodyB.torque);\n};\n\n},{\"../math/Vec3\":30}],36:[function(_dereq_,module,exports){\nvar Vec3 = _dereq_('../math/Vec3');\nvar Transform = _dereq_('../math/Transform');\nvar RaycastResult = _dereq_('../collision/RaycastResult');\nvar Utils = _dereq_('../utils/Utils');\n\nmodule.exports = WheelInfo;\n\n/**\n * @class WheelInfo\n * @constructor\n * @param {Object} [options]\n *\n * @param {Vec3} [options.chassisConnectionPointLocal]\n * @param {Vec3} [options.chassisConnectionPointWorld]\n * @param {Vec3} [options.directionLocal]\n * @param {Vec3} [options.directionWorld]\n * @param {Vec3} [options.axleLocal]\n * @param {Vec3} [options.axleWorld]\n * @param {number} [options.suspensionRestLength=1]\n * @param {number} [options.suspensionMaxLength=2]\n * @param {number} [options.radius=1]\n * @param {number} [options.suspensionStiffness=100]\n * @param {number} [options.dampingCompression=10]\n * @param {number} [options.dampingRelaxation=10]\n * @param {number} [options.frictionSlip=10000]\n * @param {number} [options.steering=0]\n * @param {number} [options.rotation=0]\n * @param {number} [options.deltaRotation=0]\n * @param {number} [options.rollInfluence=0.01]\n * @param {number} [options.maxSuspensionForce]\n * @param {boolean} [options.isFrontWheel=true]\n * @param {number} [options.clippedInvContactDotSuspension=1]\n * @param {number} [options.suspensionRelativeVelocity=0]\n * @param {number} [options.suspensionForce=0]\n * @param {number} [options.skidInfo=0]\n * @param {number} [options.suspensionLength=0]\n * @param {number} [options.maxSuspensionTravel=1]\n * @param {boolean} [options.useCustomSlidingRotationalSpeed=false]\n * @param {number} [options.customSlidingRotationalSpeed=-0.1]\n */\nfunction WheelInfo(options){\n options = Utils.defaults(options, {\n chassisConnectionPointLocal: new Vec3(),\n chassisConnectionPointWorld: new Vec3(),\n directionLocal: new Vec3(),\n directionWorld: new Vec3(),\n axleLocal: new Vec3(),\n axleWorld: new Vec3(),\n suspensionRestLength: 1,\n suspensionMaxLength: 2,\n radius: 1,\n suspensionStiffness: 100,\n dampingCompression: 10,\n dampingRelaxation: 10,\n frictionSlip: 10000,\n steering: 0,\n rotation: 0,\n deltaRotation: 0,\n rollInfluence: 0.01,\n maxSuspensionForce: Number.MAX_VALUE,\n isFrontWheel: true,\n clippedInvContactDotSuspension: 1,\n suspensionRelativeVelocity: 0,\n suspensionForce: 0,\n skidInfo: 0,\n suspensionLength: 0,\n maxSuspensionTravel: 1,\n useCustomSlidingRotationalSpeed: false,\n customSlidingRotationalSpeed: -0.1\n });\n\n /**\n * Max travel distance of the suspension, in meters.\n * @property {number} maxSuspensionTravel\n */\n this.maxSuspensionTravel = options.maxSuspensionTravel;\n\n /**\n * Speed to apply to the wheel rotation when the wheel is sliding.\n * @property {number} customSlidingRotationalSpeed\n */\n this.customSlidingRotationalSpeed = options.customSlidingRotationalSpeed;\n\n /**\n * If the customSlidingRotationalSpeed should be used.\n * @property {Boolean} useCustomSlidingRotationalSpeed\n */\n this.useCustomSlidingRotationalSpeed = options.useCustomSlidingRotationalSpeed;\n\n /**\n * @property {Boolean} sliding\n */\n this.sliding = false;\n\n /**\n * Connection point, defined locally in the chassis body frame.\n * @property {Vec3} chassisConnectionPointLocal\n */\n this.chassisConnectionPointLocal = options.chassisConnectionPointLocal.clone();\n\n /**\n * @property {Vec3} chassisConnectionPointWorld\n */\n this.chassisConnectionPointWorld = options.chassisConnectionPointWorld.clone();\n\n /**\n * @property {Vec3} directionLocal\n */\n this.directionLocal = options.directionLocal.clone();\n\n /**\n * @property {Vec3} directionWorld\n */\n this.directionWorld = options.directionWorld.clone();\n\n /**\n * @property {Vec3} axleLocal\n */\n this.axleLocal = options.axleLocal.clone();\n\n /**\n * @property {Vec3} axleWorld\n */\n this.axleWorld = options.axleWorld.clone();\n\n /**\n * @property {number} suspensionRestLength\n */\n this.suspensionRestLength = options.suspensionRestLength;\n\n /**\n * @property {number} suspensionMaxLength\n */\n this.suspensionMaxLength = options.suspensionMaxLength;\n\n /**\n * @property {number} radius\n */\n this.radius = options.radius;\n\n /**\n * @property {number} suspensionStiffness\n */\n this.suspensionStiffness = options.suspensionStiffness;\n\n /**\n * @property {number} dampingCompression\n */\n this.dampingCompression = options.dampingCompression;\n\n /**\n * @property {number} dampingRelaxation\n */\n this.dampingRelaxation = options.dampingRelaxation;\n\n /**\n * @property {number} frictionSlip\n */\n this.frictionSlip = options.frictionSlip;\n\n /**\n * @property {number} steering\n */\n this.steering = 0;\n\n /**\n * Rotation value, in radians.\n * @property {number} rotation\n */\n this.rotation = 0;\n\n /**\n * @property {number} deltaRotation\n */\n this.deltaRotation = 0;\n\n /**\n * @property {number} rollInfluence\n */\n this.rollInfluence = options.rollInfluence;\n\n /**\n * @property {number} maxSuspensionForce\n */\n this.maxSuspensionForce = options.maxSuspensionForce;\n\n /**\n * @property {number} engineForce\n */\n this.engineForce = 0;\n\n /**\n * @property {number} brake\n */\n this.brake = 0;\n\n /**\n * @property {number} isFrontWheel\n */\n this.isFrontWheel = options.isFrontWheel;\n\n /**\n * @property {number} clippedInvContactDotSuspension\n */\n this.clippedInvContactDotSuspension = 1;\n\n /**\n * @property {number} suspensionRelativeVelocity\n */\n this.suspensionRelativeVelocity = 0;\n\n /**\n * @property {number} suspensionForce\n */\n this.suspensionForce = 0;\n\n /**\n * @property {number} skidInfo\n */\n this.skidInfo = 0;\n\n /**\n * @property {number} suspensionLength\n */\n this.suspensionLength = 0;\n\n /**\n * @property {number} sideImpulse\n */\n this.sideImpulse = 0;\n\n /**\n * @property {number} forwardImpulse\n */\n this.forwardImpulse = 0;\n\n /**\n * The result from raycasting\n * @property {RaycastResult} raycastResult\n */\n this.raycastResult = new RaycastResult();\n\n /**\n * Wheel world transform\n * @property {Transform} worldTransform\n */\n this.worldTransform = new Transform();\n\n /**\n * @property {boolean} isInContact\n */\n this.isInContact = false;\n}\n\nvar chassis_velocity_at_contactPoint = new Vec3();\nvar relpos = new Vec3();\nvar chassis_velocity_at_contactPoint = new Vec3();\nWheelInfo.prototype.updateWheel = function(chassis){\n var raycastResult = this.raycastResult;\n\n if (this.isInContact){\n var project= raycastResult.hitNormalWorld.dot(raycastResult.directionWorld);\n raycastResult.hitPointWorld.vsub(chassis.position, relpos);\n chassis.getVelocityAtWorldPoint(relpos, chassis_velocity_at_contactPoint);\n var projVel = raycastResult.hitNormalWorld.dot( chassis_velocity_at_contactPoint );\n if (project >= -0.1) {\n this.suspensionRelativeVelocity = 0.0;\n this.clippedInvContactDotSuspension = 1.0 / 0.1;\n } else {\n var inv = -1 / project;\n this.suspensionRelativeVelocity = projVel * inv;\n this.clippedInvContactDotSuspension = inv;\n }\n\n } else {\n // Not in contact : position wheel in a nice (rest length) position\n raycastResult.suspensionLength = this.suspensionRestLength;\n this.suspensionRelativeVelocity = 0.0;\n raycastResult.directionWorld.scale(-1, raycastResult.hitNormalWorld);\n this.clippedInvContactDotSuspension = 1.0;\n }\n};\n},{\"../collision/RaycastResult\":10,\"../math/Transform\":29,\"../math/Vec3\":30,\"../utils/Utils\":53}],37:[function(_dereq_,module,exports){\nmodule.exports = Box;\n\nvar Shape = _dereq_('./Shape');\nvar Vec3 = _dereq_('../math/Vec3');\nvar ConvexPolyhedron = _dereq_('./ConvexPolyhedron');\n\n/**\n * A 3d box shape.\n * @class Box\n * @constructor\n * @param {Vec3} halfExtents\n * @author schteppe\n * @extends Shape\n */\nfunction Box(halfExtents){\n Shape.call(this);\n\n this.type = Shape.types.BOX;\n\n /**\n * @property halfExtents\n * @type {Vec3}\n */\n this.halfExtents = halfExtents;\n\n /**\n * Used by the contact generator to make contacts with other convex polyhedra for example\n * @property convexPolyhedronRepresentation\n * @type {ConvexPolyhedron}\n */\n this.convexPolyhedronRepresentation = null;\n\n this.updateConvexPolyhedronRepresentation();\n this.updateBoundingSphereRadius();\n}\nBox.prototype = new Shape();\nBox.prototype.constructor = Box;\n\n/**\n * Updates the local convex polyhedron representation used for some collisions.\n * @method updateConvexPolyhedronRepresentation\n */\nBox.prototype.updateConvexPolyhedronRepresentation = function(){\n var sx = this.halfExtents.x;\n var sy = this.halfExtents.y;\n var sz = this.halfExtents.z;\n var V = Vec3;\n\n var vertices = [\n new V(-sx,-sy,-sz),\n new V( sx,-sy,-sz),\n new V( sx, sy,-sz),\n new V(-sx, sy,-sz),\n new V(-sx,-sy, sz),\n new V( sx,-sy, sz),\n new V( sx, sy, sz),\n new V(-sx, sy, sz)\n ];\n\n var indices = [\n [3,2,1,0], // -z\n [4,5,6,7], // +z\n [5,4,0,1], // -y\n [2,3,7,6], // +y\n [0,4,7,3], // -x\n [1,2,6,5], // +x\n ];\n\n var axes = [\n new V(0, 0, 1),\n new V(0, 1, 0),\n new V(1, 0, 0)\n ];\n\n var h = new ConvexPolyhedron(vertices, indices);\n this.convexPolyhedronRepresentation = h;\n h.material = this.material;\n};\n\n/**\n * @method calculateLocalInertia\n * @param {Number} mass\n * @param {Vec3} target\n * @return {Vec3}\n */\nBox.prototype.calculateLocalInertia = function(mass,target){\n target = target || new Vec3();\n Box.calculateInertia(this.halfExtents, mass, target);\n return target;\n};\n\nBox.calculateInertia = function(halfExtents,mass,target){\n var e = halfExtents;\n target.x = 1.0 / 12.0 * mass * ( 2*e.y*2*e.y + 2*e.z*2*e.z );\n target.y = 1.0 / 12.0 * mass * ( 2*e.x*2*e.x + 2*e.z*2*e.z );\n target.z = 1.0 / 12.0 * mass * ( 2*e.y*2*e.y + 2*e.x*2*e.x );\n};\n\n/**\n * Get the box 6 side normals\n * @method getSideNormals\n * @param {array} sixTargetVectors An array of 6 vectors, to store the resulting side normals in.\n * @param {Quaternion} quat Orientation to apply to the normal vectors. If not provided, the vectors will be in respect to the local frame.\n * @return {array}\n */\nBox.prototype.getSideNormals = function(sixTargetVectors,quat){\n var sides = sixTargetVectors;\n var ex = this.halfExtents;\n sides[0].set( ex.x, 0, 0);\n sides[1].set( 0, ex.y, 0);\n sides[2].set( 0, 0, ex.z);\n sides[3].set( -ex.x, 0, 0);\n sides[4].set( 0, -ex.y, 0);\n sides[5].set( 0, 0, -ex.z);\n\n if(quat!==undefined){\n for(var i=0; i!==sides.length; i++){\n quat.vmult(sides[i],sides[i]);\n }\n }\n\n return sides;\n};\n\nBox.prototype.volume = function(){\n return 8.0 * this.halfExtents.x * this.halfExtents.y * this.halfExtents.z;\n};\n\nBox.prototype.updateBoundingSphereRadius = function(){\n this.boundingSphereRadius = this.halfExtents.norm();\n};\n\nvar worldCornerTempPos = new Vec3();\nvar worldCornerTempNeg = new Vec3();\nBox.prototype.forEachWorldCorner = function(pos,quat,callback){\n\n var e = this.halfExtents;\n var corners = [[ e.x, e.y, e.z],\n [ -e.x, e.y, e.z],\n [ -e.x, -e.y, e.z],\n [ -e.x, -e.y, -e.z],\n [ e.x, -e.y, -e.z],\n [ e.x, e.y, -e.z],\n [ -e.x, e.y, -e.z],\n [ e.x, -e.y, e.z]];\n for(var i=0; i max.x){\n max.x = x;\n }\n if(y > max.y){\n max.y = y;\n }\n if(z > max.z){\n max.z = z;\n }\n\n if(x < min.x){\n min.x = x;\n }\n if(y < min.y){\n min.y = y;\n }\n if(z < min.z){\n min.z = z;\n }\n }\n\n // Get each axis max\n // min.set(Infinity,Infinity,Infinity);\n // max.set(-Infinity,-Infinity,-Infinity);\n // this.forEachWorldCorner(pos,quat,function(x,y,z){\n // if(x > max.x){\n // max.x = x;\n // }\n // if(y > max.y){\n // max.y = y;\n // }\n // if(z > max.z){\n // max.z = z;\n // }\n\n // if(x < min.x){\n // min.x = x;\n // }\n // if(y < min.y){\n // min.y = y;\n // }\n // if(z < min.z){\n // min.z = z;\n // }\n // });\n};\n\n},{\"../math/Vec3\":30,\"./ConvexPolyhedron\":38,\"./Shape\":43}],38:[function(_dereq_,module,exports){\nmodule.exports = ConvexPolyhedron;\n\nvar Shape = _dereq_('./Shape');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Transform = _dereq_('../math/Transform');\n\n/**\n * A set of polygons describing a convex shape.\n * @class ConvexPolyhedron\n * @constructor\n * @extends Shape\n * @description The shape MUST be convex for the code to work properly. No polygons may be coplanar (contained\n * in the same 3D plane), instead these should be merged into one polygon.\n *\n * @param {array} points An array of Vec3's\n * @param {array} faces Array of integer arrays, describing which vertices that is included in each face.\n *\n * @author qiao / https://github.com/qiao (original author, see https://github.com/qiao/three.js/commit/85026f0c769e4000148a67d45a9e9b9c5108836f)\n * @author schteppe / https://github.com/schteppe\n * @see http://www.altdevblogaday.com/2011/05/13/contact-generation-between-3d-convex-meshes/\n * @see http://bullet.googlecode.com/svn/trunk/src/BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp\n *\n * @todo Move the clipping functions to ContactGenerator?\n * @todo Automatically merge coplanar polygons in constructor.\n */\nfunction ConvexPolyhedron(points, faces, uniqueAxes) {\n var that = this;\n Shape.call(this);\n this.type = Shape.types.CONVEXPOLYHEDRON;\n\n /**\n * Array of Vec3\n * @property vertices\n * @type {Array}\n */\n this.vertices = points||[];\n\n this.worldVertices = []; // World transformed version of .vertices\n this.worldVerticesNeedsUpdate = true;\n\n /**\n * Array of integer arrays, indicating which vertices each face consists of\n * @property faces\n * @type {Array}\n */\n this.faces = faces||[];\n\n /**\n * Array of Vec3\n * @property faceNormals\n * @type {Array}\n */\n this.faceNormals = [];\n this.computeNormals();\n\n this.worldFaceNormalsNeedsUpdate = true;\n this.worldFaceNormals = []; // World transformed version of .faceNormals\n\n /**\n * Array of Vec3\n * @property uniqueEdges\n * @type {Array}\n */\n this.uniqueEdges = [];\n\n /**\n * If given, these locally defined, normalized axes are the only ones being checked when doing separating axis check.\n * @property {Array} uniqueAxes\n */\n this.uniqueAxes = uniqueAxes ? uniqueAxes.slice() : null;\n\n this.computeEdges();\n this.updateBoundingSphereRadius();\n}\nConvexPolyhedron.prototype = new Shape();\nConvexPolyhedron.prototype.constructor = ConvexPolyhedron;\n\nvar computeEdges_tmpEdge = new Vec3();\n/**\n * Computes uniqueEdges\n * @method computeEdges\n */\nConvexPolyhedron.prototype.computeEdges = function(){\n var faces = this.faces;\n var vertices = this.vertices;\n var nv = vertices.length;\n var edges = this.uniqueEdges;\n\n edges.length = 0;\n\n var edge = computeEdges_tmpEdge;\n\n for(var i=0; i !== faces.length; i++){\n var face = faces[i];\n var numVertices = face.length;\n for(var j = 0; j !== numVertices; j++){\n var k = ( j+1 ) % numVertices;\n vertices[face[j]].vsub(vertices[face[k]], edge);\n edge.normalize();\n var found = false;\n for(var p=0; p !== edges.length; p++){\n if (edges[p].almostEquals(edge) || edges[p].almostEquals(edge)){\n found = true;\n break;\n }\n }\n\n if (!found){\n edges.push(edge.clone());\n }\n }\n }\n};\n\n/**\n * Compute the normals of the faces. Will reuse existing Vec3 objects in the .faceNormals array if they exist.\n * @method computeNormals\n */\nConvexPolyhedron.prototype.computeNormals = function(){\n this.faceNormals.length = this.faces.length;\n\n // Generate normals\n for(var i=0; i dmax){\n dmax = d;\n closestFaceB = face;\n }\n }\n var worldVertsB1 = [];\n var polyB = hullB.faces[closestFaceB];\n var numVertices = polyB.length;\n for(var e0=0; e0=0){\n this.clipFaceAgainstHull(separatingNormal,\n posA,\n quatA,\n worldVertsB1,\n minDist,\n maxDist,\n result);\n }\n};\n\n/**\n * Find the separating axis between this hull and another\n * @method findSeparatingAxis\n * @param {ConvexPolyhedron} hullB\n * @param {Vec3} posA\n * @param {Quaternion} quatA\n * @param {Vec3} posB\n * @param {Quaternion} quatB\n * @param {Vec3} target The target vector to save the axis in\n * @return {bool} Returns false if a separation is found, else true\n */\nvar fsa_faceANormalWS3 = new Vec3(),\n fsa_Worldnormal1 = new Vec3(),\n fsa_deltaC = new Vec3(),\n fsa_worldEdge0 = new Vec3(),\n fsa_worldEdge1 = new Vec3(),\n fsa_Cross = new Vec3();\nConvexPolyhedron.prototype.findSeparatingAxis = function(hullB,posA,quatA,posB,quatB,target, faceListA, faceListB){\n var faceANormalWS3 = fsa_faceANormalWS3,\n Worldnormal1 = fsa_Worldnormal1,\n deltaC = fsa_deltaC,\n worldEdge0 = fsa_worldEdge0,\n worldEdge1 = fsa_worldEdge1,\n Cross = fsa_Cross;\n\n var dmin = Number.MAX_VALUE;\n var hullA = this;\n var curPlaneTests=0;\n\n if(!hullA.uniqueAxes){\n\n var numFacesA = faceListA ? faceListA.length : hullA.faces.length;\n\n // Test face normals from hullA\n for(var i=0; i0.0){\n target.negate(target);\n }\n\n return true;\n};\n\nvar maxminA=[], maxminB=[];\n\n/**\n * Test separating axis against two hulls. Both hulls are projected onto the axis and the overlap size is returned if there is one.\n * @method testSepAxis\n * @param {Vec3} axis\n * @param {ConvexPolyhedron} hullB\n * @param {Vec3} posA\n * @param {Quaternion} quatA\n * @param {Vec3} posB\n * @param {Quaternion} quatB\n * @return {number} The overlap depth, or FALSE if no penetration.\n */\nConvexPolyhedron.prototype.testSepAxis = function(axis, hullB, posA, quatA, posB, quatB){\n var hullA=this;\n ConvexPolyhedron.project(hullA, axis, posA, quatA, maxminA);\n ConvexPolyhedron.project(hullB, axis, posB, quatB, maxminB);\n var maxA = maxminA[0];\n var minA = maxminA[1];\n var maxB = maxminB[0];\n var minB = maxminB[1];\n if(maxA= 0, so output intersection\n var newv = new Vec3();\n firstVertex.lerp(lastVertex,\n n_dot_first / (n_dot_first - n_dot_last),\n newv);\n outVertices.push(newv);\n }\n } else {\n if(n_dot_last<0){\n // Start >= 0, end < 0 so output intersection and end\n var newv = new Vec3();\n firstVertex.lerp(lastVertex,\n n_dot_first / (n_dot_first - n_dot_last),\n newv);\n outVertices.push(newv);\n outVertices.push(lastVertex);\n }\n }\n firstVertex = lastVertex;\n n_dot_first = n_dot_last;\n }\n return outVertices;\n};\n\n// Updates .worldVertices and sets .worldVerticesNeedsUpdate to false.\nConvexPolyhedron.prototype.computeWorldVertices = function(position,quat){\n var N = this.vertices.length;\n while(this.worldVertices.length < N){\n this.worldVertices.push( new Vec3() );\n }\n\n var verts = this.vertices,\n worldVerts = this.worldVertices;\n for(var i=0; i!==N; i++){\n quat.vmult( verts[i] , worldVerts[i] );\n position.vadd( worldVerts[i] , worldVerts[i] );\n }\n\n this.worldVerticesNeedsUpdate = false;\n};\n\nvar computeLocalAABB_worldVert = new Vec3();\nConvexPolyhedron.prototype.computeLocalAABB = function(aabbmin,aabbmax){\n var n = this.vertices.length,\n vertices = this.vertices,\n worldVert = computeLocalAABB_worldVert;\n\n aabbmin.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\n aabbmax.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\n\n for(var i=0; i aabbmax.x){\n aabbmax.x = v.x;\n }\n if (v.y < aabbmin.y){\n aabbmin.y = v.y;\n } else if(v.y > aabbmax.y){\n aabbmax.y = v.y;\n }\n if (v.z < aabbmin.z){\n aabbmin.z = v.z;\n } else if(v.z > aabbmax.z){\n aabbmax.z = v.z;\n }\n }\n};\n\n/**\n * Updates .worldVertices and sets .worldVerticesNeedsUpdate to false.\n * @method computeWorldFaceNormals\n * @param {Quaternion} quat\n */\nConvexPolyhedron.prototype.computeWorldFaceNormals = function(quat){\n var N = this.faceNormals.length;\n while(this.worldFaceNormals.length < N){\n this.worldFaceNormals.push( new Vec3() );\n }\n\n var normals = this.faceNormals,\n worldNormals = this.worldFaceNormals;\n for(var i=0; i!==N; i++){\n quat.vmult( normals[i] , worldNormals[i] );\n }\n\n this.worldFaceNormalsNeedsUpdate = false;\n};\n\n/**\n * @method updateBoundingSphereRadius\n */\nConvexPolyhedron.prototype.updateBoundingSphereRadius = function(){\n // Assume points are distributed with local (0,0,0) as center\n var max2 = 0;\n var verts = this.vertices;\n for(var i=0, N=verts.length; i!==N; i++) {\n var norm2 = verts[i].norm2();\n if(norm2 > max2){\n max2 = norm2;\n }\n }\n this.boundingSphereRadius = Math.sqrt(max2);\n};\n\nvar tempWorldVertex = new Vec3();\n\n/**\n * @method calculateWorldAABB\n * @param {Vec3} pos\n * @param {Quaternion} quat\n * @param {Vec3} min\n * @param {Vec3} max\n */\nConvexPolyhedron.prototype.calculateWorldAABB = function(pos,quat,min,max){\n var n = this.vertices.length, verts = this.vertices;\n var minx,miny,minz,maxx,maxy,maxz;\n for(var i=0; i maxx || maxx===undefined){\n maxx = v.x;\n }\n\n if (v.y < miny || miny===undefined){\n miny = v.y;\n } else if(v.y > maxy || maxy===undefined){\n maxy = v.y;\n }\n\n if (v.z < minz || minz===undefined){\n minz = v.z;\n } else if(v.z > maxz || maxz===undefined){\n maxz = v.z;\n }\n }\n min.set(minx,miny,minz);\n max.set(maxx,maxy,maxz);\n};\n\n/**\n * Get approximate convex volume\n * @method volume\n * @return {Number}\n */\nConvexPolyhedron.prototype.volume = function(){\n return 4.0 * Math.PI * this.boundingSphereRadius / 3.0;\n};\n\n/**\n * Get an average of all the vertices positions\n * @method getAveragePointLocal\n * @param {Vec3} target\n * @return {Vec3}\n */\nConvexPolyhedron.prototype.getAveragePointLocal = function(target){\n target = target || new Vec3();\n var n = this.vertices.length,\n verts = this.vertices;\n for(var i=0; i0) || (r1>0 && r2<0)){\n return false; // Encountered some other sign. Exit.\n } else {\n }\n }\n\n // If we got here, all dot products were of the same sign.\n return positiveResult ? 1 : -1;\n};\n\n/**\n * Get max and min dot product of a convex hull at position (pos,quat) projected onto an axis. Results are saved in the array maxmin.\n * @static\n * @method project\n * @param {ConvexPolyhedron} hull\n * @param {Vec3} axis\n * @param {Vec3} pos\n * @param {Quaternion} quat\n * @param {array} result result[0] and result[1] will be set to maximum and minimum, respectively.\n */\nvar project_worldVertex = new Vec3();\nvar project_localAxis = new Vec3();\nvar project_localOrigin = new Vec3();\nConvexPolyhedron.project = function(hull, axis, pos, quat, result){\n var n = hull.vertices.length,\n worldVertex = project_worldVertex,\n localAxis = project_localAxis,\n max = 0,\n min = 0,\n localOrigin = project_localOrigin,\n vs = hull.vertices;\n\n localOrigin.setZero();\n\n // Transform the axis to local\n Transform.vectorToLocalFrame(pos, quat, axis, localAxis);\n Transform.pointToLocalFrame(pos, quat, localOrigin, localOrigin);\n var add = localOrigin.dot(localAxis);\n\n min = max = vs[0].dot(localAxis);\n\n for(var i = 1; i < n; i++){\n var val = vs[i].dot(localAxis);\n\n if(val > max){\n max = val;\n }\n\n if(val < min){\n min = val;\n }\n }\n\n min -= add;\n max -= add;\n\n if(min > max){\n // Inconsistent - swap\n var temp = min;\n min = max;\n max = temp;\n }\n // Output\n result[0] = max;\n result[1] = min;\n};\n\n},{\"../math/Quaternion\":28,\"../math/Transform\":29,\"../math/Vec3\":30,\"./Shape\":43}],39:[function(_dereq_,module,exports){\nmodule.exports = Cylinder;\n\nvar Shape = _dereq_('./Shape');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar ConvexPolyhedron = _dereq_('./ConvexPolyhedron');\n\n/**\n * @class Cylinder\n * @constructor\n * @extends ConvexPolyhedron\n * @author schteppe / https://github.com/schteppe\n * @param {Number} radiusTop\n * @param {Number} radiusBottom\n * @param {Number} height\n * @param {Number} numSegments The number of segments to build the cylinder out of\n */\nfunction Cylinder( radiusTop, radiusBottom, height , numSegments ) {\n var N = numSegments,\n verts = [],\n axes = [],\n faces = [],\n bottomface = [],\n topface = [],\n cos = Math.cos,\n sin = Math.sin;\n\n // First bottom point\n verts.push(new Vec3(radiusBottom*cos(0),\n radiusBottom*sin(0),\n -height*0.5));\n bottomface.push(0);\n\n // First top point\n verts.push(new Vec3(radiusTop*cos(0),\n radiusTop*sin(0),\n height*0.5));\n topface.push(1);\n\n for(var i=0; i { convex: ..., offset: ... }\n // for example:\n // _cachedPillars[\"0_2_1\"]\n this._cachedPillars = {};\n}\nHeightfield.prototype = new Shape();\n\n/**\n * Call whenever you change the data array.\n * @method update\n */\nHeightfield.prototype.update = function(){\n this._cachedPillars = {};\n};\n\n/**\n * Update the .minValue property\n * @method updateMinValue\n */\nHeightfield.prototype.updateMinValue = function(){\n var data = this.data;\n var minValue = data[0][0];\n for(var i=0; i !== data.length; i++){\n for(var j=0; j !== data[i].length; j++){\n var v = data[i][j];\n if(v < minValue){\n minValue = v;\n }\n }\n }\n this.minValue = minValue;\n};\n\n/**\n * Update the .maxValue property\n * @method updateMaxValue\n */\nHeightfield.prototype.updateMaxValue = function(){\n var data = this.data;\n var maxValue = data[0][0];\n for(var i=0; i !== data.length; i++){\n for(var j=0; j !== data[i].length; j++){\n var v = data[i][j];\n if(v > maxValue){\n maxValue = v;\n }\n }\n }\n this.maxValue = maxValue;\n};\n\n/**\n * Set the height value at an index. Don't forget to update maxValue and minValue after you're done.\n * @method setHeightValueAtIndex\n * @param {integer} xi\n * @param {integer} yi\n * @param {number} value\n */\nHeightfield.prototype.setHeightValueAtIndex = function(xi, yi, value){\n var data = this.data;\n data[xi][yi] = value;\n\n // Invalidate cache\n this.clearCachedConvexTrianglePillar(xi, yi, false);\n if(xi > 0){\n this.clearCachedConvexTrianglePillar(xi - 1, yi, true);\n this.clearCachedConvexTrianglePillar(xi - 1, yi, false);\n }\n if(yi > 0){\n this.clearCachedConvexTrianglePillar(xi, yi - 1, true);\n this.clearCachedConvexTrianglePillar(xi, yi - 1, false);\n }\n if(yi > 0 && xi > 0){\n this.clearCachedConvexTrianglePillar(xi - 1, yi - 1, true);\n }\n};\n\n/**\n * Get max/min in a rectangle in the matrix data\n * @method getRectMinMax\n * @param {integer} iMinX\n * @param {integer} iMinY\n * @param {integer} iMaxX\n * @param {integer} iMaxY\n * @param {array} [result] An array to store the results in.\n * @return {array} The result array, if it was passed in. Minimum will be at position 0 and max at 1.\n */\nHeightfield.prototype.getRectMinMax = function (iMinX, iMinY, iMaxX, iMaxY, result) {\n result = result || [];\n\n // Get max and min of the data\n var data = this.data,\n max = this.minValue; // Set first value\n for(var i = iMinX; i <= iMaxX; i++){\n for(var j = iMinY; j <= iMaxY; j++){\n var height = data[i][j];\n if(height > max){\n max = height;\n }\n }\n }\n\n result[0] = this.minValue;\n result[1] = max;\n};\n\n/**\n * Get the index of a local position on the heightfield. The indexes indicate the rectangles, so if your terrain is made of N x N height data points, you will have rectangle indexes ranging from 0 to N-1.\n * @method getIndexOfPosition\n * @param {number} x\n * @param {number} y\n * @param {array} result Two-element array\n * @param {boolean} clamp If the position should be clamped to the heightfield edge.\n * @return {boolean}\n */\nHeightfield.prototype.getIndexOfPosition = function (x, y, result, clamp) {\n\n // Get the index of the data points to test against\n var w = this.elementSize;\n var data = this.data;\n var xi = Math.floor(x / w);\n var yi = Math.floor(y / w);\n\n result[0] = xi;\n result[1] = yi;\n\n if(clamp){\n // Clamp index to edges\n if(xi < 0){ xi = 0; }\n if(yi < 0){ yi = 0; }\n if(xi >= data.length - 1){ xi = data.length - 1; }\n if(yi >= data[0].length - 1){ yi = data[0].length - 1; }\n }\n\n // Bail out if we are out of the terrain\n if(xi < 0 || yi < 0 || xi >= data.length-1 || yi >= data[0].length-1){\n return false;\n }\n\n return true;\n};\n\nHeightfield.prototype.getHeightAt = function(x, y, edgeClamp){\n var idx = [];\n this.getIndexOfPosition(x, y, idx, edgeClamp);\n\n // TODO: get upper or lower triangle, then use barycentric interpolation to get the height in the triangle.\n var minmax = [];\n this.getRectMinMax(idx[0], idx[1] + 1, idx[0], idx[1] + 1, minmax);\n\n return (minmax[0] + minmax[1]) / 2; // average\n};\n\nHeightfield.prototype.getCacheConvexTrianglePillarKey = function(xi, yi, getUpperTriangle){\n return xi + '_' + yi + '_' + (getUpperTriangle ? 1 : 0);\n};\n\nHeightfield.prototype.getCachedConvexTrianglePillar = function(xi, yi, getUpperTriangle){\n return this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)];\n};\n\nHeightfield.prototype.setCachedConvexTrianglePillar = function(xi, yi, getUpperTriangle, convex, offset){\n this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)] = {\n convex: convex,\n offset: offset\n };\n};\n\nHeightfield.prototype.clearCachedConvexTrianglePillar = function(xi, yi, getUpperTriangle){\n delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)];\n};\n\n/**\n * Get a triangle in the terrain in the form of a triangular convex shape.\n * @method getConvexTrianglePillar\n * @param {integer} i\n * @param {integer} j\n * @param {boolean} getUpperTriangle\n */\nHeightfield.prototype.getConvexTrianglePillar = function(xi, yi, getUpperTriangle){\n var result = this.pillarConvex;\n var offsetResult = this.pillarOffset;\n\n if(this.cacheEnabled){\n var data = this.getCachedConvexTrianglePillar(xi, yi, getUpperTriangle);\n if(data){\n this.pillarConvex = data.convex;\n this.pillarOffset = data.offset;\n return;\n }\n\n result = new ConvexPolyhedron();\n offsetResult = new Vec3();\n\n this.pillarConvex = result;\n this.pillarOffset = offsetResult;\n }\n\n var data = this.data;\n var elementSize = this.elementSize;\n var faces = result.faces;\n\n // Reuse verts if possible\n result.vertices.length = 6;\n for (var i = 0; i < 6; i++) {\n if(!result.vertices[i]){\n result.vertices[i] = new Vec3();\n }\n }\n\n // Reuse faces if possible\n faces.length = 5;\n for (var i = 0; i < 5; i++) {\n if(!faces[i]){\n faces[i] = [];\n }\n }\n\n var verts = result.vertices;\n\n var h = (Math.min(\n data[xi][yi],\n data[xi+1][yi],\n data[xi][yi+1],\n data[xi+1][yi+1]\n ) - this.minValue ) / 2 + this.minValue;\n\n if (!getUpperTriangle) {\n\n // Center of the triangle pillar - all polygons are given relative to this one\n offsetResult.set(\n (xi + 0.25) * elementSize, // sort of center of a triangle\n (yi + 0.25) * elementSize,\n h // vertical center\n );\n\n // Top triangle verts\n verts[0].set(\n -0.25 * elementSize,\n -0.25 * elementSize,\n data[xi][yi] - h\n );\n verts[1].set(\n 0.75 * elementSize,\n -0.25 * elementSize,\n data[xi + 1][yi] - h\n );\n verts[2].set(\n -0.25 * elementSize,\n 0.75 * elementSize,\n data[xi][yi + 1] - h\n );\n\n // bottom triangle verts\n verts[3].set(\n -0.25 * elementSize,\n -0.25 * elementSize,\n -h-1\n );\n verts[4].set(\n 0.75 * elementSize,\n -0.25 * elementSize,\n -h-1\n );\n verts[5].set(\n -0.25 * elementSize,\n 0.75 * elementSize,\n -h-1\n );\n\n // top triangle\n faces[0][0] = 0;\n faces[0][1] = 1;\n faces[0][2] = 2;\n\n // bottom triangle\n faces[1][0] = 5;\n faces[1][1] = 4;\n faces[1][2] = 3;\n\n // -x facing quad\n faces[2][0] = 0;\n faces[2][1] = 2;\n faces[2][2] = 5;\n faces[2][3] = 3;\n\n // -y facing quad\n faces[3][0] = 1;\n faces[3][1] = 0;\n faces[3][2] = 3;\n faces[3][3] = 4;\n\n // +xy facing quad\n faces[4][0] = 4;\n faces[4][1] = 5;\n faces[4][2] = 2;\n faces[4][3] = 1;\n\n\n } else {\n\n // Center of the triangle pillar - all polygons are given relative to this one\n offsetResult.set(\n (xi + 0.75) * elementSize, // sort of center of a triangle\n (yi + 0.75) * elementSize,\n h // vertical center\n );\n\n // Top triangle verts\n verts[0].set(\n 0.25 * elementSize,\n 0.25 * elementSize,\n data[xi + 1][yi + 1] - h\n );\n verts[1].set(\n -0.75 * elementSize,\n 0.25 * elementSize,\n data[xi][yi + 1] - h\n );\n verts[2].set(\n 0.25 * elementSize,\n -0.75 * elementSize,\n data[xi + 1][yi] - h\n );\n\n // bottom triangle verts\n verts[3].set(\n 0.25 * elementSize,\n 0.25 * elementSize,\n - h-1\n );\n verts[4].set(\n -0.75 * elementSize,\n 0.25 * elementSize,\n - h-1\n );\n verts[5].set(\n 0.25 * elementSize,\n -0.75 * elementSize,\n - h-1\n );\n\n // Top triangle\n faces[0][0] = 0;\n faces[0][1] = 1;\n faces[0][2] = 2;\n\n // bottom triangle\n faces[1][0] = 5;\n faces[1][1] = 4;\n faces[1][2] = 3;\n\n // +x facing quad\n faces[2][0] = 2;\n faces[2][1] = 5;\n faces[2][2] = 3;\n faces[2][3] = 0;\n\n // +y facing quad\n faces[3][0] = 3;\n faces[3][1] = 4;\n faces[3][2] = 1;\n faces[3][3] = 0;\n\n // -xy facing quad\n faces[4][0] = 1;\n faces[4][1] = 4;\n faces[4][2] = 5;\n faces[4][3] = 2;\n }\n\n result.computeNormals();\n result.computeEdges();\n result.updateBoundingSphereRadius();\n\n this.setCachedConvexTrianglePillar(xi, yi, getUpperTriangle, result, offsetResult);\n};\n\nHeightfield.prototype.calculateLocalInertia = function(mass, target){\n target = target || new Vec3();\n target.set(0, 0, 0);\n return target;\n};\n\nHeightfield.prototype.volume = function(){\n return Number.MAX_VALUE; // The terrain is infinite\n};\n\nHeightfield.prototype.calculateWorldAABB = function(pos, quat, min, max){\n // TODO: do it properly\n min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\n max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\n};\n\nHeightfield.prototype.updateBoundingSphereRadius = function(){\n // Use the bounding box of the min/max values\n var data = this.data,\n s = this.elementSize;\n this.boundingSphereRadius = new Vec3(data.length * s, data[0].length * s, Math.max(Math.abs(this.maxValue), Math.abs(this.minValue))).norm();\n};\n\n},{\"../math/Vec3\":30,\"../utils/Utils\":53,\"./ConvexPolyhedron\":38,\"./Shape\":43}],41:[function(_dereq_,module,exports){\nmodule.exports = Particle;\n\nvar Shape = _dereq_('./Shape');\nvar Vec3 = _dereq_('../math/Vec3');\n\n/**\n * Particle shape.\n * @class Particle\n * @constructor\n * @author schteppe\n * @extends Shape\n */\nfunction Particle(){\n Shape.call(this);\n\n this.type = Shape.types.PARTICLE;\n}\nParticle.prototype = new Shape();\nParticle.prototype.constructor = Particle;\n\n/**\n * @method calculateLocalInertia\n * @param {Number} mass\n * @param {Vec3} target\n * @return {Vec3}\n */\nParticle.prototype.calculateLocalInertia = function(mass,target){\n target = target || new Vec3();\n target.set(0, 0, 0);\n return target;\n};\n\nParticle.prototype.volume = function(){\n return 0;\n};\n\nParticle.prototype.updateBoundingSphereRadius = function(){\n this.boundingSphereRadius = 0;\n};\n\nParticle.prototype.calculateWorldAABB = function(pos,quat,min,max){\n // Get each axis max\n min.copy(pos);\n max.copy(pos);\n};\n\n},{\"../math/Vec3\":30,\"./Shape\":43}],42:[function(_dereq_,module,exports){\nmodule.exports = Plane;\n\nvar Shape = _dereq_('./Shape');\nvar Vec3 = _dereq_('../math/Vec3');\n\n/**\n * A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a RigidBody and rotate that body. See the demos.\n * @class Plane\n * @constructor\n * @extends Shape\n * @author schteppe\n */\nfunction Plane(){\n Shape.call(this);\n this.type = Shape.types.PLANE;\n\n // World oriented normal\n this.worldNormal = new Vec3();\n this.worldNormalNeedsUpdate = true;\n\n this.boundingSphereRadius = Number.MAX_VALUE;\n}\nPlane.prototype = new Shape();\nPlane.prototype.constructor = Plane;\n\nPlane.prototype.computeWorldNormal = function(quat){\n var n = this.worldNormal;\n n.set(0,0,1);\n quat.vmult(n,n);\n this.worldNormalNeedsUpdate = false;\n};\n\nPlane.prototype.calculateLocalInertia = function(mass,target){\n target = target || new Vec3();\n return target;\n};\n\nPlane.prototype.volume = function(){\n return Number.MAX_VALUE; // The plane is infinite...\n};\n\nvar tempNormal = new Vec3();\nPlane.prototype.calculateWorldAABB = function(pos, quat, min, max){\n // The plane AABB is infinite, except if the normal is pointing along any axis\n tempNormal.set(0,0,1); // Default plane normal is z\n quat.vmult(tempNormal,tempNormal);\n var maxVal = Number.MAX_VALUE;\n min.set(-maxVal, -maxVal, -maxVal);\n max.set(maxVal, maxVal, maxVal);\n\n if(tempNormal.x === 1){ max.x = pos.x; }\n if(tempNormal.y === 1){ max.y = pos.y; }\n if(tempNormal.z === 1){ max.z = pos.z; }\n\n if(tempNormal.x === -1){ min.x = pos.x; }\n if(tempNormal.y === -1){ min.y = pos.y; }\n if(tempNormal.z === -1){ min.z = pos.z; }\n};\n\nPlane.prototype.updateBoundingSphereRadius = function(){\n this.boundingSphereRadius = Number.MAX_VALUE;\n};\n},{\"../math/Vec3\":30,\"./Shape\":43}],43:[function(_dereq_,module,exports){\nmodule.exports = Shape;\n\nvar Shape = _dereq_('./Shape');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Material = _dereq_('../material/Material');\n\n/**\n * Base class for shapes\n * @class Shape\n * @constructor\n * @author schteppe\n * @todo Should have a mechanism for caching bounding sphere radius instead of calculating it each time\n */\nfunction Shape(){\n\n /**\n * Identifyer of the Shape.\n * @property {number} id\n */\n this.id = Shape.idCounter++;\n\n /**\n * The type of this shape. Must be set to an int > 0 by subclasses.\n * @property type\n * @type {Number}\n * @see Shape.types\n */\n this.type = 0;\n\n /**\n * The local bounding sphere radius of this shape.\n * @property {Number} boundingSphereRadius\n */\n this.boundingSphereRadius = 0;\n\n /**\n * Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled.\n * @property {boolean} collisionResponse\n */\n this.collisionResponse = true;\n\n /**\n * @property {Material} material\n */\n this.material = null;\n}\nShape.prototype.constructor = Shape;\n\n/**\n * Computes the bounding sphere radius. The result is stored in the property .boundingSphereRadius\n * @method updateBoundingSphereRadius\n * @return {Number}\n */\nShape.prototype.updateBoundingSphereRadius = function(){\n throw \"computeBoundingSphereRadius() not implemented for shape type \"+this.type;\n};\n\n/**\n * Get the volume of this shape\n * @method volume\n * @return {Number}\n */\nShape.prototype.volume = function(){\n throw \"volume() not implemented for shape type \"+this.type;\n};\n\n/**\n * Calculates the inertia in the local frame for this shape.\n * @method calculateLocalInertia\n * @return {Vec3}\n * @see http://en.wikipedia.org/wiki/List_of_moments_of_inertia\n */\nShape.prototype.calculateLocalInertia = function(mass,target){\n throw \"calculateLocalInertia() not implemented for shape type \"+this.type;\n};\n\nShape.idCounter = 0;\n\n/**\n * The available shape types.\n * @static\n * @property types\n * @type {Object}\n */\nShape.types = {\n SPHERE:1,\n PLANE:2,\n BOX:4,\n COMPOUND:8,\n CONVEXPOLYHEDRON:16,\n HEIGHTFIELD:32,\n PARTICLE:64,\n CYLINDER:128,\n TRIMESH:256\n};\n\n\n},{\"../material/Material\":25,\"../math/Quaternion\":28,\"../math/Vec3\":30,\"./Shape\":43}],44:[function(_dereq_,module,exports){\nmodule.exports = Sphere;\n\nvar Shape = _dereq_('./Shape');\nvar Vec3 = _dereq_('../math/Vec3');\n\n/**\n * Spherical shape\n * @class Sphere\n * @constructor\n * @extends Shape\n * @param {Number} radius The radius of the sphere, a non-negative number.\n * @author schteppe / http://github.com/schteppe\n */\nfunction Sphere(radius){\n Shape.call(this);\n\n /**\n * @property {Number} radius\n */\n this.radius = radius!==undefined ? Number(radius) : 1.0;\n this.type = Shape.types.SPHERE;\n\n if(this.radius < 0){\n throw new Error('The sphere radius cannot be negative.');\n }\n\n this.updateBoundingSphereRadius();\n}\nSphere.prototype = new Shape();\nSphere.prototype.constructor = Sphere;\n\nSphere.prototype.calculateLocalInertia = function(mass,target){\n target = target || new Vec3();\n var I = 2.0*mass*this.radius*this.radius/5.0;\n target.x = I;\n target.y = I;\n target.z = I;\n return target;\n};\n\nSphere.prototype.volume = function(){\n return 4.0 * Math.PI * this.radius / 3.0;\n};\n\nSphere.prototype.updateBoundingSphereRadius = function(){\n this.boundingSphereRadius = this.radius;\n};\n\nSphere.prototype.calculateWorldAABB = function(pos,quat,min,max){\n var r = this.radius;\n var axes = ['x','y','z'];\n for(var i=0; i u.x){\n u.x = v.x;\n }\n\n if(v.y < l.y){\n l.y = v.y;\n } else if(v.y > u.y){\n u.y = v.y;\n }\n\n if(v.z < l.z){\n l.z = v.z;\n } else if(v.z > u.z){\n u.z = v.z;\n }\n }\n};\n\n\n/**\n * Update the .aabb property\n * @method updateAABB\n */\nTrimesh.prototype.updateAABB = function(){\n this.computeLocalAABB(this.aabb);\n};\n\n/**\n * Will update the .boundingSphereRadius property\n * @method updateBoundingSphereRadius\n */\nTrimesh.prototype.updateBoundingSphereRadius = function(){\n // Assume points are distributed with local (0,0,0) as center\n var max2 = 0;\n var vertices = this.vertices;\n var v = new Vec3();\n for(var i=0, N=vertices.length / 3; i !== N; i++) {\n this.getVertex(i, v);\n var norm2 = v.norm2();\n if(norm2 > max2){\n max2 = norm2;\n }\n }\n this.boundingSphereRadius = Math.sqrt(max2);\n};\n\nvar tempWorldVertex = new Vec3();\nvar calculateWorldAABB_frame = new Transform();\nvar calculateWorldAABB_aabb = new AABB();\n\n/**\n * @method calculateWorldAABB\n * @param {Vec3} pos\n * @param {Quaternion} quat\n * @param {Vec3} min\n * @param {Vec3} max\n */\nTrimesh.prototype.calculateWorldAABB = function(pos,quat,min,max){\n /*\n var n = this.vertices.length / 3,\n verts = this.vertices;\n var minx,miny,minz,maxx,maxy,maxz;\n\n var v = tempWorldVertex;\n for(var i=0; i maxx || maxx===undefined){\n maxx = v.x;\n }\n\n if (v.y < miny || miny===undefined){\n miny = v.y;\n } else if(v.y > maxy || maxy===undefined){\n maxy = v.y;\n }\n\n if (v.z < minz || minz===undefined){\n minz = v.z;\n } else if(v.z > maxz || maxz===undefined){\n maxz = v.z;\n }\n }\n min.set(minx,miny,minz);\n max.set(maxx,maxy,maxz);\n */\n\n // Faster approximation using local AABB\n var frame = calculateWorldAABB_frame;\n var result = calculateWorldAABB_aabb;\n frame.position = pos;\n frame.quaternion = quat;\n this.aabb.toWorldFrame(frame, result);\n min.copy(result.lowerBound);\n max.copy(result.upperBound);\n};\n\n/**\n * Get approximate volume\n * @method volume\n * @return {Number}\n */\nTrimesh.prototype.volume = function(){\n return 4.0 * Math.PI * this.boundingSphereRadius / 3.0;\n};\n\n/**\n * Create a Trimesh instance, shaped as a torus.\n * @static\n * @method createTorus\n * @param {number} [radius=1]\n * @param {number} [tube=0.5]\n * @param {number} [radialSegments=8]\n * @param {number} [tubularSegments=6]\n * @param {number} [arc=6.283185307179586]\n * @return {Trimesh} A torus\n */\nTrimesh.createTorus = function (radius, tube, radialSegments, tubularSegments, arc) {\n radius = radius || 1;\n tube = tube || 0.5;\n radialSegments = radialSegments || 8;\n tubularSegments = tubularSegments || 6;\n arc = arc || Math.PI * 2;\n\n var vertices = [];\n var indices = [];\n\n for ( var j = 0; j <= radialSegments; j ++ ) {\n for ( var i = 0; i <= tubularSegments; i ++ ) {\n var u = i / tubularSegments * arc;\n var v = j / radialSegments * Math.PI * 2;\n\n var x = ( radius + tube * Math.cos( v ) ) * Math.cos( u );\n var y = ( radius + tube * Math.cos( v ) ) * Math.sin( u );\n var z = tube * Math.sin( v );\n\n vertices.push( x, y, z );\n }\n }\n\n for ( var j = 1; j <= radialSegments; j ++ ) {\n for ( var i = 1; i <= tubularSegments; i ++ ) {\n var a = ( tubularSegments + 1 ) * j + i - 1;\n var b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;\n var c = ( tubularSegments + 1 ) * ( j - 1 ) + i;\n var d = ( tubularSegments + 1 ) * j + i;\n\n indices.push(a, b, d);\n indices.push(b, c, d);\n }\n }\n\n return new Trimesh(vertices, indices);\n};\n\n},{\"../collision/AABB\":3,\"../math/Quaternion\":28,\"../math/Transform\":29,\"../math/Vec3\":30,\"../utils/Octree\":50,\"./Shape\":43}],46:[function(_dereq_,module,exports){\nmodule.exports = GSSolver;\n\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Solver = _dereq_('./Solver');\n\n/**\n * Constraint equation Gauss-Seidel solver.\n * @class GSSolver\n * @constructor\n * @todo The spook parameters should be specified for each constraint, not globally.\n * @author schteppe / https://github.com/schteppe\n * @see https://www8.cs.umu.se/kurser/5DV058/VT09/lectures/spooknotes.pdf\n * @extends Solver\n */\nfunction GSSolver(){\n Solver.call(this);\n\n /**\n * The number of solver iterations determines quality of the constraints in the world. The more iterations, the more correct simulation. More iterations need more computations though. If you have a large gravity force in your world, you will need more iterations.\n * @property iterations\n * @type {Number}\n * @todo write more about solver and iterations in the wiki\n */\n this.iterations = 10;\n\n /**\n * When tolerance is reached, the system is assumed to be converged.\n * @property tolerance\n * @type {Number}\n */\n this.tolerance = 1e-7;\n}\nGSSolver.prototype = new Solver();\n\nvar GSSolver_solve_lambda = []; // Just temporary number holders that we want to reuse each solve.\nvar GSSolver_solve_invCs = [];\nvar GSSolver_solve_Bs = [];\nGSSolver.prototype.solve = function(dt,world){\n var iter = 0,\n maxIter = this.iterations,\n tolSquared = this.tolerance*this.tolerance,\n equations = this.equations,\n Neq = equations.length,\n bodies = world.bodies,\n Nbodies = bodies.length,\n h = dt,\n q, B, invC, deltalambda, deltalambdaTot, GWlambda, lambdaj;\n\n // Update solve mass\n if(Neq !== 0){\n for(var i=0; i!==Nbodies; i++){\n bodies[i].updateSolveMassProperties();\n }\n }\n\n // Things that does not change during iteration can be computed once\n var invCs = GSSolver_solve_invCs,\n Bs = GSSolver_solve_Bs,\n lambda = GSSolver_solve_lambda;\n invCs.length = Neq;\n Bs.length = Neq;\n lambda.length = Neq;\n for(var i=0; i!==Neq; i++){\n var c = equations[i];\n lambda[i] = 0.0;\n Bs[i] = c.computeB(h);\n invCs[i] = 1.0 / c.computeC();\n }\n\n if(Neq !== 0){\n\n // Reset vlambda\n for(var i=0; i!==Nbodies; i++){\n var b=bodies[i],\n vlambda=b.vlambda,\n wlambda=b.wlambda;\n vlambda.set(0,0,0);\n if(wlambda){\n wlambda.set(0,0,0);\n }\n }\n\n // Iterate over equations\n for(iter=0; iter!==maxIter; iter++){\n\n // Accumulate the total error for each iteration.\n deltalambdaTot = 0.0;\n\n for(var j=0; j!==Neq; j++){\n\n var c = equations[j];\n\n // Compute iteration\n B = Bs[j];\n invC = invCs[j];\n lambdaj = lambda[j];\n GWlambda = c.computeGWlambda();\n deltalambda = invC * ( B - GWlambda - c.eps * lambdaj );\n\n // Clamp if we are not within the min/max interval\n if(lambdaj + deltalambda < c.minForce){\n deltalambda = c.minForce - lambdaj;\n } else if(lambdaj + deltalambda > c.maxForce){\n deltalambda = c.maxForce - lambdaj;\n }\n lambda[j] += deltalambda;\n\n deltalambdaTot += deltalambda > 0.0 ? deltalambda : -deltalambda; // abs(deltalambda)\n\n c.addToWlambda(deltalambda);\n }\n\n // If the total error is small enough - stop iterate\n if(deltalambdaTot*deltalambdaTot < tolSquared){\n break;\n }\n }\n\n // Add result to velocity\n for(var i=0; i!==Nbodies; i++){\n var b=bodies[i],\n v=b.velocity,\n w=b.angularVelocity;\n v.vadd(b.vlambda, v);\n if(w){\n w.vadd(b.wlambda, w);\n }\n }\n }\n\n return iter;\n};\n\n},{\"../math/Quaternion\":28,\"../math/Vec3\":30,\"./Solver\":47}],47:[function(_dereq_,module,exports){\nmodule.exports = Solver;\n\n/**\n * Constraint equation solver base class.\n * @class Solver\n * @constructor\n * @author schteppe / https://github.com/schteppe\n */\nfunction Solver(){\n /**\n * All equations to be solved\n * @property {Array} equations\n */\n this.equations = [];\n}\n\n/**\n * Should be implemented in subclasses!\n * @method solve\n * @param {Number} dt\n * @param {World} world\n */\nSolver.prototype.solve = function(dt,world){\n // Should return the number of iterations done!\n return 0;\n};\n\n/**\n * Add an equation\n * @method addEquation\n * @param {Equation} eq\n */\nSolver.prototype.addEquation = function(eq){\n if (eq.enabled) {\n this.equations.push(eq);\n }\n};\n\n/**\n * Remove an equation\n * @method removeEquation\n * @param {Equation} eq\n */\nSolver.prototype.removeEquation = function(eq){\n var eqs = this.equations;\n var i = eqs.indexOf(eq);\n if(i !== -1){\n eqs.splice(i,1);\n }\n};\n\n/**\n * Add all equations\n * @method removeAllEquations\n */\nSolver.prototype.removeAllEquations = function(){\n this.equations.length = 0;\n};\n\n\n},{}],48:[function(_dereq_,module,exports){\nmodule.exports = SplitSolver;\n\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Solver = _dereq_('./Solver');\nvar Body = _dereq_('../objects/Body');\n\n/**\n * Splits the equations into islands and solves them independently. Can improve performance.\n * @class SplitSolver\n * @constructor\n * @extends Solver\n * @param {Solver} subsolver\n */\nfunction SplitSolver(subsolver){\n Solver.call(this);\n this.iterations = 10;\n this.tolerance = 1e-7;\n this.subsolver = subsolver;\n this.nodes = [];\n this.nodePool = [];\n\n // Create needed nodes, reuse if possible\n while(this.nodePool.length < 128){\n this.nodePool.push(this.createNode());\n }\n}\nSplitSolver.prototype = new Solver();\n\n// Returns the number of subsystems\nvar SplitSolver_solve_nodes = []; // All allocated node objects\nvar SplitSolver_solve_nodePool = []; // All allocated node objects\nvar SplitSolver_solve_eqs = []; // Temp array\nvar SplitSolver_solve_bds = []; // Temp array\nvar SplitSolver_solve_dummyWorld = {bodies:[]}; // Temp object\n\nvar STATIC = Body.STATIC;\nfunction getUnvisitedNode(nodes){\n var Nnodes = nodes.length;\n for(var i=0; i!==Nnodes; i++){\n var node = nodes[i];\n if(!node.visited && !(node.body.type & STATIC)){\n return node;\n }\n }\n return false;\n}\n\nvar queue = [];\nfunction bfs(root,visitFunc,bds,eqs){\n queue.push(root);\n root.visited = true;\n visitFunc(root,bds,eqs);\n while(queue.length) {\n var node = queue.pop();\n // Loop over unvisited child nodes\n var child;\n while((child = getUnvisitedNode(node.children))) {\n child.visited = true;\n visitFunc(child,bds,eqs);\n queue.push(child);\n }\n }\n}\n\nfunction visitFunc(node,bds,eqs){\n bds.push(node.body);\n var Neqs = node.eqs.length;\n for(var i=0; i!==Neqs; i++){\n var eq = node.eqs[i];\n if(eqs.indexOf(eq) === -1){\n eqs.push(eq);\n }\n }\n}\n\nSplitSolver.prototype.createNode = function(){\n return { body:null, children:[], eqs:[], visited:false };\n};\n\n/**\n * Solve the subsystems\n * @method solve\n * @param {Number} dt\n * @param {World} world\n */\nSplitSolver.prototype.solve = function(dt,world){\n var nodes=SplitSolver_solve_nodes,\n nodePool=this.nodePool,\n bodies=world.bodies,\n equations=this.equations,\n Neq=equations.length,\n Nbodies=bodies.length,\n subsolver=this.subsolver;\n\n // Create needed nodes, reuse if possible\n while(nodePool.length < Nbodies){\n nodePool.push(this.createNode());\n }\n nodes.length = Nbodies;\n for (var i = 0; i < Nbodies; i++) {\n nodes[i] = nodePool[i];\n }\n\n // Reset node values\n for(var i=0; i!==Nbodies; i++){\n var node = nodes[i];\n node.body = bodies[i];\n node.children.length = 0;\n node.eqs.length = 0;\n node.visited = false;\n }\n for(var k=0; k!==Neq; k++){\n var eq=equations[k],\n i=bodies.indexOf(eq.bi),\n j=bodies.indexOf(eq.bj),\n ni=nodes[i],\n nj=nodes[j];\n ni.children.push(nj);\n ni.eqs.push(eq);\n nj.children.push(ni);\n nj.eqs.push(eq);\n }\n\n var child, n=0, eqs=SplitSolver_solve_eqs;\n\n subsolver.tolerance = this.tolerance;\n subsolver.iterations = this.iterations;\n\n var dummyWorld = SplitSolver_solve_dummyWorld;\n while((child = getUnvisitedNode(nodes))){\n eqs.length = 0;\n dummyWorld.bodies.length = 0;\n bfs(child, visitFunc, dummyWorld.bodies, eqs);\n\n var Neqs = eqs.length;\n\n eqs = eqs.sort(sortById);\n\n for(var i=0; i!==Neqs; i++){\n subsolver.addEquation(eqs[i]);\n }\n\n var iter = subsolver.solve(dt,dummyWorld);\n subsolver.removeAllEquations();\n n++;\n }\n\n return n;\n};\n\nfunction sortById(a, b){\n return b.id - a.id;\n}\n},{\"../math/Quaternion\":28,\"../math/Vec3\":30,\"../objects/Body\":31,\"./Solver\":47}],49:[function(_dereq_,module,exports){\n/**\n * Base class for objects that dispatches events.\n * @class EventTarget\n * @constructor\n */\nvar EventTarget = function () {\n\n};\n\nmodule.exports = EventTarget;\n\nEventTarget.prototype = {\n constructor: EventTarget,\n\n /**\n * Add an event listener\n * @method addEventListener\n * @param {String} type\n * @param {Function} listener\n * @return {EventTarget} The self object, for chainability.\n */\n addEventListener: function ( type, listener ) {\n if ( this._listeners === undefined ){ this._listeners = {}; }\n var listeners = this._listeners;\n if ( listeners[ type ] === undefined ) {\n listeners[ type ] = [];\n }\n if ( listeners[ type ].indexOf( listener ) === - 1 ) {\n listeners[ type ].push( listener );\n }\n return this;\n },\n\n /**\n * Check if an event listener is added\n * @method hasEventListener\n * @param {String} type\n * @param {Function} listener\n * @return {Boolean}\n */\n hasEventListener: function ( type, listener ) {\n if ( this._listeners === undefined ){ return false; }\n var listeners = this._listeners;\n if ( listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1 ) {\n return true;\n }\n return false;\n },\n\n /**\n * Remove an event listener\n * @method removeEventListener\n * @param {String} type\n * @param {Function} listener\n * @return {EventTarget} The self object, for chainability.\n */\n removeEventListener: function ( type, listener ) {\n if ( this._listeners === undefined ){ return this; }\n var listeners = this._listeners;\n if ( listeners[type] === undefined ){ return this; }\n var index = listeners[ type ].indexOf( listener );\n if ( index !== - 1 ) {\n listeners[ type ].splice( index, 1 );\n }\n return this;\n },\n\n /**\n * Emit an event.\n * @method dispatchEvent\n * @param {Object} event\n * @param {String} event.type\n * @return {EventTarget} The self object, for chainability.\n */\n dispatchEvent: function ( event ) {\n if ( this._listeners === undefined ){ return this; }\n var listeners = this._listeners;\n var listenerArray = listeners[ event.type ];\n if ( listenerArray !== undefined ) {\n event.target = this;\n for ( var i = 0, l = listenerArray.length; i < l; i ++ ) {\n listenerArray[ i ].call( this, event );\n }\n }\n return this;\n }\n};\n\n},{}],50:[function(_dereq_,module,exports){\nvar AABB = _dereq_('../collision/AABB');\nvar Vec3 = _dereq_('../math/Vec3');\n\nmodule.exports = Octree;\n\n/**\n * @class OctreeNode\n * @param {object} [options]\n * @param {Octree} [options.root]\n * @param {AABB} [options.aabb]\n */\nfunction OctreeNode(options){\n options = options || {};\n\n /**\n * The root node\n * @property {OctreeNode} root\n */\n this.root = options.root || null;\n\n /**\n * Boundary of this node\n * @property {AABB} aabb\n */\n this.aabb = options.aabb ? options.aabb.clone() : new AABB();\n\n /**\n * Contained data at the current node level.\n * @property {Array} data\n */\n this.data = [];\n\n /**\n * Children to this node\n * @property {Array} children\n */\n this.children = [];\n}\n\n/**\n * @class Octree\n * @param {AABB} aabb The total AABB of the tree\n * @param {object} [options]\n * @param {number} [options.maxDepth=8]\n * @extends OctreeNode\n */\nfunction Octree(aabb, options){\n options = options || {};\n options.root = null;\n options.aabb = aabb;\n OctreeNode.call(this, options);\n\n /**\n * Maximum subdivision depth\n * @property {number} maxDepth\n */\n this.maxDepth = typeof(options.maxDepth) !== 'undefined' ? options.maxDepth : 8;\n}\nOctree.prototype = new OctreeNode();\n\nOctreeNode.prototype.reset = function(aabb, options){\n this.children.length = this.data.length = 0;\n};\n\n/**\n * Insert data into this node\n * @method insert\n * @param {AABB} aabb\n * @param {object} elementData\n * @return {boolean} True if successful, otherwise false\n */\nOctreeNode.prototype.insert = function(aabb, elementData, level){\n var nodeData = this.data;\n level = level || 0;\n\n // Ignore objects that do not belong in this node\n if (!this.aabb.contains(aabb)){\n return false; // object cannot be added\n }\n\n var children = this.children;\n\n if(level < (this.maxDepth || this.root.maxDepth)){\n // Subdivide if there are no children yet\n var subdivided = false;\n if (!children.length){\n this.subdivide();\n subdivided = true;\n }\n\n // add to whichever node will accept it\n for (var i = 0; i !== 8; i++) {\n if (children[i].insert(aabb, elementData, level + 1)){\n return true;\n }\n }\n\n if(subdivided){\n // No children accepted! Might as well just remove em since they contain none\n children.length = 0;\n }\n }\n\n // Too deep, or children didnt want it. add it in current node\n nodeData.push(elementData);\n\n return true;\n};\n\nvar halfDiagonal = new Vec3();\n\n/**\n * Create 8 equally sized children nodes and put them in the .children array.\n * @method subdivide\n */\nOctreeNode.prototype.subdivide = function() {\n var aabb = this.aabb;\n var l = aabb.lowerBound;\n var u = aabb.upperBound;\n\n var children = this.children;\n\n children.push(\n new OctreeNode({ aabb: new AABB({ lowerBound: new Vec3(0,0,0) }) }),\n new OctreeNode({ aabb: new AABB({ lowerBound: new Vec3(1,0,0) }) }),\n new OctreeNode({ aabb: new AABB({ lowerBound: new Vec3(1,1,0) }) }),\n new OctreeNode({ aabb: new AABB({ lowerBound: new Vec3(1,1,1) }) }),\n new OctreeNode({ aabb: new AABB({ lowerBound: new Vec3(0,1,1) }) }),\n new OctreeNode({ aabb: new AABB({ lowerBound: new Vec3(0,0,1) }) }),\n new OctreeNode({ aabb: new AABB({ lowerBound: new Vec3(1,0,1) }) }),\n new OctreeNode({ aabb: new AABB({ lowerBound: new Vec3(0,1,0) }) })\n );\n\n u.vsub(l, halfDiagonal);\n halfDiagonal.scale(0.5, halfDiagonal);\n\n var root = this.root || this;\n\n for (var i = 0; i !== 8; i++) {\n var child = children[i];\n\n // Set current node as root\n child.root = root;\n\n // Compute bounds\n var lowerBound = child.aabb.lowerBound;\n lowerBound.x *= halfDiagonal.x;\n lowerBound.y *= halfDiagonal.y;\n lowerBound.z *= halfDiagonal.z;\n\n lowerBound.vadd(l, lowerBound);\n\n // Upper bound is always lower bound + halfDiagonal\n lowerBound.vadd(halfDiagonal, child.aabb.upperBound);\n }\n};\n\n/**\n * Get all data, potentially within an AABB\n * @method aabbQuery\n * @param {AABB} aabb\n * @param {array} result\n * @return {array} The \"result\" object\n */\nOctreeNode.prototype.aabbQuery = function(aabb, result) {\n\n var nodeData = this.data;\n\n // abort if the range does not intersect this node\n // if (!this.aabb.overlaps(aabb)){\n // return result;\n // }\n\n // Add objects at this level\n // Array.prototype.push.apply(result, nodeData);\n\n // Add child data\n // @todo unwrap recursion into a queue / loop, that's faster in JS\n var children = this.children;\n\n\n // for (var i = 0, N = this.children.length; i !== N; i++) {\n // children[i].aabbQuery(aabb, result);\n // }\n\n var queue = [this];\n while (queue.length) {\n var node = queue.pop();\n if (node.aabb.overlaps(aabb)){\n Array.prototype.push.apply(result, node.data);\n }\n Array.prototype.push.apply(queue, node.children);\n }\n\n return result;\n};\n\nvar tmpAABB = new AABB();\n\n/**\n * Get all data, potentially intersected by a ray.\n * @method rayQuery\n * @param {Ray} ray\n * @param {Transform} treeTransform\n * @param {array} result\n * @return {array} The \"result\" object\n */\nOctreeNode.prototype.rayQuery = function(ray, treeTransform, result) {\n\n // Use aabb query for now.\n // @todo implement real ray query which needs less lookups\n ray.getAABB(tmpAABB);\n tmpAABB.toLocalFrame(treeTransform, tmpAABB);\n this.aabbQuery(tmpAABB, result);\n\n return result;\n};\n\n/**\n * @method removeEmptyNodes\n */\nOctreeNode.prototype.removeEmptyNodes = function() {\n var queue = [this];\n while (queue.length) {\n var node = queue.pop();\n for (var i = node.children.length - 1; i >= 0; i--) {\n if(!node.children[i].data.length){\n node.children.splice(i, 1);\n }\n }\n Array.prototype.push.apply(queue, node.children);\n }\n};\n\n},{\"../collision/AABB\":3,\"../math/Vec3\":30}],51:[function(_dereq_,module,exports){\nmodule.exports = Pool;\n\n/**\n * For pooling objects that can be reused.\n * @class Pool\n * @constructor\n */\nfunction Pool(){\n /**\n * The pooled objects\n * @property {Array} objects\n */\n this.objects = [];\n\n /**\n * Constructor of the objects\n * @property {mixed} type\n */\n this.type = Object;\n}\n\n/**\n * Release an object after use\n * @method release\n * @param {Object} obj\n */\nPool.prototype.release = function(){\n var Nargs = arguments.length;\n for(var i=0; i!==Nargs; i++){\n this.objects.push(arguments[i]);\n }\n};\n\n/**\n * Get an object\n * @method get\n * @return {mixed}\n */\nPool.prototype.get = function(){\n if(this.objects.length===0){\n return this.constructObject();\n } else {\n return this.objects.pop();\n }\n};\n\n/**\n * Construct an object. Should be implmented in each subclass.\n * @method constructObject\n * @return {mixed}\n */\nPool.prototype.constructObject = function(){\n throw new Error(\"constructObject() not implemented in this Pool subclass yet!\");\n};\n\n},{}],52:[function(_dereq_,module,exports){\nmodule.exports = TupleDictionary;\n\n/**\n * @class TupleDictionary\n * @constructor\n */\nfunction TupleDictionary() {\n\n /**\n * The data storage\n * @property data\n * @type {Object}\n */\n this.data = { keys:[] };\n}\n\n/**\n * @method get\n * @param {Number} i\n * @param {Number} j\n * @return {Number}\n */\nTupleDictionary.prototype.get = function(i, j) {\n if (i > j) {\n // swap\n var temp = j;\n j = i;\n i = temp;\n }\n return this.data[i+'-'+j];\n};\n\n/**\n * @method set\n * @param {Number} i\n * @param {Number} j\n * @param {Number} value\n */\nTupleDictionary.prototype.set = function(i, j, value) {\n if (i > j) {\n var temp = j;\n j = i;\n i = temp;\n }\n var key = i+'-'+j;\n\n // Check if key already exists\n if(!this.get(i,j)){\n this.data.keys.push(key);\n }\n\n this.data[key] = value;\n};\n\n/**\n * @method reset\n */\nTupleDictionary.prototype.reset = function() {\n var data = this.data,\n keys = data.keys;\n while(keys.length > 0){\n var key = keys.pop();\n delete data[key];\n }\n};\n\n},{}],53:[function(_dereq_,module,exports){\nfunction Utils(){}\n\nmodule.exports = Utils;\n\n/**\n * Extend an options object with default values.\n * @static\n * @method defaults\n * @param {object} options The options object. May be falsy: in this case, a new object is created and returned.\n * @param {object} defaults An object containing default values.\n * @return {object} The modified options object.\n */\nUtils.defaults = function(options, defaults){\n options = options || {};\n\n for(var key in defaults){\n if(!(key in options)){\n options[key] = defaults[key];\n }\n }\n\n return options;\n};\n\n},{}],54:[function(_dereq_,module,exports){\nmodule.exports = Vec3Pool;\n\nvar Vec3 = _dereq_('../math/Vec3');\nvar Pool = _dereq_('./Pool');\n\n/**\n * @class Vec3Pool\n * @constructor\n * @extends Pool\n */\nfunction Vec3Pool(){\n Pool.call(this);\n this.type = Vec3;\n}\nVec3Pool.prototype = new Pool();\n\n/**\n * Construct a vector\n * @method constructObject\n * @return {Vec3}\n */\nVec3Pool.prototype.constructObject = function(){\n return new Vec3();\n};\n\n},{\"../math/Vec3\":30,\"./Pool\":51}],55:[function(_dereq_,module,exports){\nmodule.exports = Narrowphase;\n\nvar AABB = _dereq_('../collision/AABB');\nvar Shape = _dereq_('../shapes/Shape');\nvar Ray = _dereq_('../collision/Ray');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Transform = _dereq_('../math/Transform');\nvar ConvexPolyhedron = _dereq_('../shapes/ConvexPolyhedron');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar Solver = _dereq_('../solver/Solver');\nvar Vec3Pool = _dereq_('../utils/Vec3Pool');\nvar ContactEquation = _dereq_('../equations/ContactEquation');\nvar FrictionEquation = _dereq_('../equations/FrictionEquation');\n\n/**\n * Helper class for the World. Generates ContactEquations.\n * @class Narrowphase\n * @constructor\n * @todo Sphere-ConvexPolyhedron contacts\n * @todo Contact reduction\n * @todo should move methods to prototype\n */\nfunction Narrowphase(world){\n\n /**\n * Internal storage of pooled contact points.\n * @property {Array} contactPointPool\n */\n this.contactPointPool = [];\n\n this.frictionEquationPool = [];\n\n this.result = [];\n this.frictionResult = [];\n\n /**\n * Pooled vectors.\n * @property {Vec3Pool} v3pool\n */\n this.v3pool = new Vec3Pool();\n\n this.world = world;\n this.currentContactMaterial = null;\n\n /**\n * @property {Boolean} enableFrictionReduction\n */\n this.enableFrictionReduction = false;\n}\n\n/**\n * Make a contact object, by using the internal pool or creating a new one.\n * @method createContactEquation\n * @return {ContactEquation}\n */\nNarrowphase.prototype.createContactEquation = function(bi, bj, si, sj, rsi, rsj){\n var c;\n if(this.contactPointPool.length){\n c = this.contactPointPool.pop();\n c.bi = bi;\n c.bj = bj;\n } else {\n c = new ContactEquation(bi, bj);\n }\n\n c.enabled = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse;\n\n var cm = this.currentContactMaterial;\n\n c.restitution = cm.restitution;\n\n c.setSpookParams(\n cm.contactEquationStiffness,\n cm.contactEquationRelaxation,\n this.world.dt\n );\n\n var matA = si.material || bi.material;\n var matB = sj.material || bj.material;\n if(matA && matB && matA.restitution >= 0 && matB.restitution >= 0){\n c.restitution = matA.restitution * matB.restitution;\n }\n\n c.si = rsi || si;\n c.sj = rsj || sj;\n\n return c;\n};\n\nNarrowphase.prototype.createFrictionEquationsFromContact = function(contactEquation, outArray){\n var bodyA = contactEquation.bi;\n var bodyB = contactEquation.bj;\n var shapeA = contactEquation.si;\n var shapeB = contactEquation.sj;\n\n var world = this.world;\n var cm = this.currentContactMaterial;\n\n // If friction or restitution were specified in the material, use them\n var friction = cm.friction;\n var matA = shapeA.material || bodyA.material;\n var matB = shapeB.material || bodyB.material;\n if(matA && matB && matA.friction >= 0 && matB.friction >= 0){\n friction = matA.friction * matB.friction;\n }\n\n if(friction > 0){\n\n // Create 2 tangent equations\n var mug = friction * world.gravity.length();\n var reducedMass = (bodyA.invMass + bodyB.invMass);\n if(reducedMass > 0){\n reducedMass = 1/reducedMass;\n }\n var pool = this.frictionEquationPool;\n var c1 = pool.length ? pool.pop() : new FrictionEquation(bodyA,bodyB,mug*reducedMass);\n var c2 = pool.length ? pool.pop() : new FrictionEquation(bodyA,bodyB,mug*reducedMass);\n\n c1.bi = c2.bi = bodyA;\n c1.bj = c2.bj = bodyB;\n c1.minForce = c2.minForce = -mug*reducedMass;\n c1.maxForce = c2.maxForce = mug*reducedMass;\n\n // Copy over the relative vectors\n c1.ri.copy(contactEquation.ri);\n c1.rj.copy(contactEquation.rj);\n c2.ri.copy(contactEquation.ri);\n c2.rj.copy(contactEquation.rj);\n\n // Construct tangents\n contactEquation.ni.tangents(c1.t, c2.t);\n\n // Set spook params\n c1.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, world.dt);\n c2.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, world.dt);\n\n c1.enabled = c2.enabled = contactEquation.enabled;\n\n outArray.push(c1, c2);\n\n return true;\n }\n\n return false;\n};\n\nvar averageNormal = new Vec3();\nvar averageContactPointA = new Vec3();\nvar averageContactPointB = new Vec3();\n\n// Take the average N latest contact point on the plane.\nNarrowphase.prototype.createFrictionFromAverage = function(numContacts){\n // The last contactEquation\n var c = this.result[this.result.length - 1];\n\n // Create the result: two \"average\" friction equations\n if (!this.createFrictionEquationsFromContact(c, this.frictionResult) || numContacts === 1) {\n return;\n }\n\n var f1 = this.frictionResult[this.frictionResult.length - 2];\n var f2 = this.frictionResult[this.frictionResult.length - 1];\n\n averageNormal.setZero();\n averageContactPointA.setZero();\n averageContactPointB.setZero();\n\n var bodyA = c.bi;\n var bodyB = c.bj;\n for(var i=0; i!==numContacts; i++){\n c = this.result[this.result.length - 1 - i];\n if(c.bodyA !== bodyA){\n averageNormal.vadd(c.ni, averageNormal); // vec2.add(eq.t, eq.t, c.normalA);\n averageContactPointA.vadd(c.ri, averageContactPointA); // vec2.add(eq.contactPointA, eq.contactPointA, c.contactPointA);\n averageContactPointB.vadd(c.rj, averageContactPointB);\n } else {\n averageNormal.vsub(c.ni, averageNormal); // vec2.sub(eq.t, eq.t, c.normalA);\n averageContactPointA.vadd(c.rj, averageContactPointA); // vec2.add(eq.contactPointA, eq.contactPointA, c.contactPointA);\n averageContactPointB.vadd(c.ri, averageContactPointB);\n }\n }\n\n var invNumContacts = 1 / numContacts;\n averageContactPointA.scale(invNumContacts, f1.ri); // vec2.scale(eq.contactPointA, eq.contactPointA, invNumContacts);\n averageContactPointB.scale(invNumContacts, f1.rj); // vec2.scale(eq.contactPointB, eq.contactPointB, invNumContacts);\n f2.ri.copy(f1.ri); // Should be the same\n f2.rj.copy(f1.rj);\n averageNormal.normalize();\n averageNormal.tangents(f1.t, f2.t);\n // return eq;\n};\n\n\nvar tmpVec1 = new Vec3();\nvar tmpVec2 = new Vec3();\nvar tmpQuat1 = new Quaternion();\nvar tmpQuat2 = new Quaternion();\n\n/**\n * Generate all contacts between a list of body pairs\n * @method getContacts\n * @param {array} p1 Array of body indices\n * @param {array} p2 Array of body indices\n * @param {World} world\n * @param {array} result Array to store generated contacts\n * @param {array} oldcontacts Optional. Array of reusable contact objects\n */\nNarrowphase.prototype.getContacts = function(p1, p2, world, result, oldcontacts, frictionResult, frictionPool){\n // Save old contact objects\n this.contactPointPool = oldcontacts;\n this.frictionEquationPool = frictionPool;\n this.result = result;\n this.frictionResult = frictionResult;\n\n var qi = tmpQuat1;\n var qj = tmpQuat2;\n var xi = tmpVec1;\n var xj = tmpVec2;\n\n for(var k=0, N=p1.length; k!==N; k++){\n\n // Get current collision bodies\n var bi = p1[k],\n bj = p2[k];\n\n // Get contact material\n var bodyContactMaterial = null;\n if(bi.material && bj.material){\n bodyContactMaterial = world.getContactMaterial(bi.material,bj.material) || null;\n }\n\n for (var i = 0; i < bi.shapes.length; i++) {\n bi.quaternion.mult(bi.shapeOrientations[i], qi);\n bi.quaternion.vmult(bi.shapeOffsets[i], xi);\n xi.vadd(bi.position, xi);\n var si = bi.shapes[i];\n\n for (var j = 0; j < bj.shapes.length; j++) {\n\n // Compute world transform of shapes\n bj.quaternion.mult(bj.shapeOrientations[j], qj);\n bj.quaternion.vmult(bj.shapeOffsets[j], xj);\n xj.vadd(bj.position, xj);\n var sj = bj.shapes[j];\n\n if(xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius){\n continue;\n }\n\n // Get collision material\n var shapeContactMaterial = null;\n if(si.material && sj.material){\n shapeContactMaterial = world.getContactMaterial(si.material,sj.material) || null;\n }\n\n this.currentContactMaterial = shapeContactMaterial || bodyContactMaterial || world.defaultContactMaterial;\n\n // Get contacts\n var resolver = this[si.type | sj.type];\n if(resolver){\n if (si.type < sj.type) {\n resolver.call(this, si, sj, xi, xj, qi, qj, bi, bj, si, sj);\n } else {\n resolver.call(this, sj, si, xj, xi, qj, qi, bj, bi, si, sj);\n }\n }\n }\n }\n }\n};\n\nvar numWarnings = 0;\nvar maxWarnings = 10;\n\nfunction warn(msg){\n if(numWarnings > maxWarnings){\n return;\n }\n\n numWarnings++;\n\n console.warn(msg);\n}\n\nNarrowphase.prototype[Shape.types.BOX | Shape.types.BOX] =\nNarrowphase.prototype.boxBox = function(si,sj,xi,xj,qi,qj,bi,bj){\n si.convexPolyhedronRepresentation.material = si.material;\n sj.convexPolyhedronRepresentation.material = sj.material;\n si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse;\n sj.convexPolyhedronRepresentation.collisionResponse = sj.collisionResponse;\n this.convexConvex(si.convexPolyhedronRepresentation,sj.convexPolyhedronRepresentation,xi,xj,qi,qj,bi,bj,si,sj);\n};\n\nNarrowphase.prototype[Shape.types.BOX | Shape.types.CONVEXPOLYHEDRON] =\nNarrowphase.prototype.boxConvex = function(si,sj,xi,xj,qi,qj,bi,bj){\n si.convexPolyhedronRepresentation.material = si.material;\n si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse;\n this.convexConvex(si.convexPolyhedronRepresentation,sj,xi,xj,qi,qj,bi,bj,si,sj);\n};\n\nNarrowphase.prototype[Shape.types.BOX | Shape.types.PARTICLE] =\nNarrowphase.prototype.boxParticle = function(si,sj,xi,xj,qi,qj,bi,bj){\n si.convexPolyhedronRepresentation.material = si.material;\n si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse;\n this.convexParticle(si.convexPolyhedronRepresentation,sj,xi,xj,qi,qj,bi,bj,si,sj);\n};\n\n/**\n * @method sphereSphere\n * @param {Shape} si\n * @param {Shape} sj\n * @param {Vec3} xi\n * @param {Vec3} xj\n * @param {Quaternion} qi\n * @param {Quaternion} qj\n * @param {Body} bi\n * @param {Body} bj\n */\nNarrowphase.prototype[Shape.types.SPHERE] =\nNarrowphase.prototype.sphereSphere = function(si,sj,xi,xj,qi,qj,bi,bj){\n // We will have only one contact in this case\n var r = this.createContactEquation(bi,bj,si,sj);\n\n // Contact normal\n xj.vsub(xi, r.ni);\n r.ni.normalize();\n\n // Contact point locations\n r.ri.copy(r.ni);\n r.rj.copy(r.ni);\n r.ri.mult(si.radius, r.ri);\n r.rj.mult(-sj.radius, r.rj);\n\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n\n this.result.push(r);\n\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n};\n\n/**\n * @method planeTrimesh\n * @param {Shape} si\n * @param {Shape} sj\n * @param {Vec3} xi\n * @param {Vec3} xj\n * @param {Quaternion} qi\n * @param {Quaternion} qj\n * @param {Body} bi\n * @param {Body} bj\n */\nvar planeTrimesh_normal = new Vec3();\nvar planeTrimesh_relpos = new Vec3();\nvar planeTrimesh_projected = new Vec3();\nNarrowphase.prototype[Shape.types.PLANE | Shape.types.TRIMESH] =\nNarrowphase.prototype.planeTrimesh = function(\n planeShape,\n trimeshShape,\n planePos,\n trimeshPos,\n planeQuat,\n trimeshQuat,\n planeBody,\n trimeshBody\n){\n // Make contacts!\n var v = new Vec3();\n\n var normal = planeTrimesh_normal;\n normal.set(0,0,1);\n planeQuat.vmult(normal,normal); // Turn normal according to plane\n\n for(var i=0; i 0 && positionAlongEdgeB < 0){\n\n // Now check the orthogonal distance from edge to sphere center\n localSpherePos.vsub(edgeVertexA, tmp);\n\n edgeVectorUnit.copy(edgeVector);\n edgeVectorUnit.normalize();\n positionAlongEdgeA = tmp.dot(edgeVectorUnit);\n\n edgeVectorUnit.scale(positionAlongEdgeA, tmp);\n tmp.vadd(edgeVertexA, tmp);\n\n // tmp is now the sphere center position projected to the edge, defined locally in the trimesh frame\n var dist = tmp.distanceTo(localSpherePos);\n if(dist < sphereShape.radius){\n var r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape);\n\n tmp.vsub(localSpherePos, r.ni);\n r.ni.normalize();\n r.ni.scale(sphereShape.radius, r.ri);\n\n Transform.pointToWorldFrame(trimeshPos, trimeshQuat, tmp, tmp);\n tmp.vsub(trimeshBody.position, r.rj);\n\n Transform.vectorToWorldFrame(trimeshQuat, r.ni, r.ni);\n Transform.vectorToWorldFrame(trimeshQuat, r.ri, r.ri);\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n }\n }\n\n // Triangle faces\n var va = sphereTrimesh_va;\n var vb = sphereTrimesh_vb;\n var vc = sphereTrimesh_vc;\n var normal = sphereTrimesh_normal;\n for(var i=0, N = triangles.length; i !== N; i++){\n trimeshShape.getTriangleVertices(triangles[i], va, vb, vc);\n trimeshShape.getNormal(triangles[i], normal);\n localSpherePos.vsub(va, tmp);\n var dist = tmp.dot(normal);\n normal.scale(dist, tmp);\n localSpherePos.vsub(tmp, tmp);\n\n // tmp is now the sphere position projected to the triangle plane\n dist = tmp.distanceTo(localSpherePos);\n if(Ray.pointInTriangle(tmp, va, vb, vc) && dist < sphereShape.radius){\n var r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape);\n\n tmp.vsub(localSpherePos, r.ni);\n r.ni.normalize();\n r.ni.scale(sphereShape.radius, r.ri);\n\n Transform.pointToWorldFrame(trimeshPos, trimeshQuat, tmp, tmp);\n tmp.vsub(trimeshBody.position, r.rj);\n\n Transform.vectorToWorldFrame(trimeshQuat, r.ni, r.ni);\n Transform.vectorToWorldFrame(trimeshQuat, r.ri, r.ri);\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n\n triangles.length = 0;\n};\n\nvar point_on_plane_to_sphere = new Vec3();\nvar plane_to_sphere_ortho = new Vec3();\n\n/**\n * @method spherePlane\n * @param {Shape} si\n * @param {Shape} sj\n * @param {Vec3} xi\n * @param {Vec3} xj\n * @param {Quaternion} qi\n * @param {Quaternion} qj\n * @param {Body} bi\n * @param {Body} bj\n */\nNarrowphase.prototype[Shape.types.SPHERE | Shape.types.PLANE] =\nNarrowphase.prototype.spherePlane = function(si,sj,xi,xj,qi,qj,bi,bj){\n // We will have one contact in this case\n var r = this.createContactEquation(bi,bj,si,sj);\n\n // Contact normal\n r.ni.set(0,0,1);\n qj.vmult(r.ni, r.ni);\n r.ni.negate(r.ni); // body i is the sphere, flip normal\n r.ni.normalize(); // Needed?\n\n // Vector from sphere center to contact point\n r.ni.mult(si.radius, r.ri);\n\n // Project down sphere on plane\n xi.vsub(xj, point_on_plane_to_sphere);\n r.ni.mult(r.ni.dot(point_on_plane_to_sphere), plane_to_sphere_ortho);\n point_on_plane_to_sphere.vsub(plane_to_sphere_ortho,r.rj); // The sphere position projected to plane\n\n if(-point_on_plane_to_sphere.dot(r.ni) <= si.radius){\n\n // Make it relative to the body\n var ri = r.ri;\n var rj = r.rj;\n ri.vadd(xi, ri);\n ri.vsub(bi.position, ri);\n rj.vadd(xj, rj);\n rj.vsub(bj.position, rj);\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n};\n\n// See http://bulletphysics.com/Bullet/BulletFull/SphereTriangleDetector_8cpp_source.html\nvar pointInPolygon_edge = new Vec3();\nvar pointInPolygon_edge_x_normal = new Vec3();\nvar pointInPolygon_vtp = new Vec3();\nfunction pointInPolygon(verts, normal, p){\n var positiveResult = null;\n var N = verts.length;\n for(var i=0; i!==N; i++){\n var v = verts[i];\n\n // Get edge to the next vertex\n var edge = pointInPolygon_edge;\n verts[(i+1) % (N)].vsub(v,edge);\n\n // Get cross product between polygon normal and the edge\n var edge_x_normal = pointInPolygon_edge_x_normal;\n //var edge_x_normal = new Vec3();\n edge.cross(normal,edge_x_normal);\n\n // Get vector between point and current vertex\n var vertex_to_p = pointInPolygon_vtp;\n p.vsub(v,vertex_to_p);\n\n // This dot product determines which side of the edge the point is\n var r = edge_x_normal.dot(vertex_to_p);\n\n // If all such dot products have same sign, we are inside the polygon.\n if(positiveResult===null || (r>0 && positiveResult===true) || (r<=0 && positiveResult===false)){\n if(positiveResult===null){\n positiveResult = r>0;\n }\n continue;\n } else {\n return false; // Encountered some other sign. Exit.\n }\n }\n\n // If we got here, all dot products were of the same sign.\n return true;\n}\n\nvar box_to_sphere = new Vec3();\nvar sphereBox_ns = new Vec3();\nvar sphereBox_ns1 = new Vec3();\nvar sphereBox_ns2 = new Vec3();\nvar sphereBox_sides = [new Vec3(),new Vec3(),new Vec3(),new Vec3(),new Vec3(),new Vec3()];\nvar sphereBox_sphere_to_corner = new Vec3();\nvar sphereBox_side_ns = new Vec3();\nvar sphereBox_side_ns1 = new Vec3();\nvar sphereBox_side_ns2 = new Vec3();\n\n/**\n * @method sphereBox\n * @param {Shape} si\n * @param {Shape} sj\n * @param {Vec3} xi\n * @param {Vec3} xj\n * @param {Quaternion} qi\n * @param {Quaternion} qj\n * @param {Body} bi\n * @param {Body} bj\n */\nNarrowphase.prototype[Shape.types.SPHERE | Shape.types.BOX] =\nNarrowphase.prototype.sphereBox = function(si,sj,xi,xj,qi,qj,bi,bj){\n var v3pool = this.v3pool;\n\n // we refer to the box as body j\n var sides = sphereBox_sides;\n xi.vsub(xj,box_to_sphere);\n sj.getSideNormals(sides,qj);\n var R = si.radius;\n var penetrating_sides = [];\n\n // Check side (plane) intersections\n var found = false;\n\n // Store the resulting side penetration info\n var side_ns = sphereBox_side_ns;\n var side_ns1 = sphereBox_side_ns1;\n var side_ns2 = sphereBox_side_ns2;\n var side_h = null;\n var side_penetrations = 0;\n var side_dot1 = 0;\n var side_dot2 = 0;\n var side_distance = null;\n for(var idx=0,nsides=sides.length; idx!==nsides && found===false; idx++){\n // Get the plane side normal (ns)\n var ns = sphereBox_ns;\n ns.copy(sides[idx]);\n\n var h = ns.norm();\n ns.normalize();\n\n // The normal/distance dot product tells which side of the plane we are\n var dot = box_to_sphere.dot(ns);\n\n if(dot0){\n // Intersects plane. Now check the other two dimensions\n var ns1 = sphereBox_ns1;\n var ns2 = sphereBox_ns2;\n ns1.copy(sides[(idx+1)%3]);\n ns2.copy(sides[(idx+2)%3]);\n var h1 = ns1.norm();\n var h2 = ns2.norm();\n ns1.normalize();\n ns2.normalize();\n var dot1 = box_to_sphere.dot(ns1);\n var dot2 = box_to_sphere.dot(ns2);\n if(dot1

-h1 && dot2

-h2){\n var dist = Math.abs(dot-h-R);\n if(side_distance===null || dist < side_distance){\n side_distance = dist;\n side_dot1 = dot1;\n side_dot2 = dot2;\n side_h = h;\n side_ns.copy(ns);\n side_ns1.copy(ns1);\n side_ns2.copy(ns2);\n side_penetrations++;\n }\n }\n }\n }\n if(side_penetrations){\n found = true;\n var r = this.createContactEquation(bi,bj,si,sj);\n side_ns.mult(-R,r.ri); // Sphere r\n r.ni.copy(side_ns);\n r.ni.negate(r.ni); // Normal should be out of sphere\n side_ns.mult(side_h,side_ns);\n side_ns1.mult(side_dot1,side_ns1);\n side_ns.vadd(side_ns1,side_ns);\n side_ns2.mult(side_dot2,side_ns2);\n side_ns.vadd(side_ns2,r.rj);\n\n // Make relative to bodies\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n\n // Check corners\n var rj = v3pool.get();\n var sphere_to_corner = sphereBox_sphere_to_corner;\n for(var j=0; j!==2 && !found; j++){\n for(var k=0; k!==2 && !found; k++){\n for(var l=0; l!==2 && !found; l++){\n rj.set(0,0,0);\n if(j){\n rj.vadd(sides[0],rj);\n } else {\n rj.vsub(sides[0],rj);\n }\n if(k){\n rj.vadd(sides[1],rj);\n } else {\n rj.vsub(sides[1],rj);\n }\n if(l){\n rj.vadd(sides[2],rj);\n } else {\n rj.vsub(sides[2],rj);\n }\n\n // World position of corner\n xj.vadd(rj,sphere_to_corner);\n sphere_to_corner.vsub(xi,sphere_to_corner);\n\n if(sphere_to_corner.norm2() < R*R){\n found = true;\n var r = this.createContactEquation(bi,bj,si,sj);\n r.ri.copy(sphere_to_corner);\n r.ri.normalize();\n r.ni.copy(r.ri);\n r.ri.mult(R,r.ri);\n r.rj.copy(rj);\n\n // Make relative to bodies\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n }\n }\n v3pool.release(rj);\n rj = null;\n\n // Check edges\n var edgeTangent = v3pool.get();\n var edgeCenter = v3pool.get();\n var r = v3pool.get(); // r = edge center to sphere center\n var orthogonal = v3pool.get();\n var dist = v3pool.get();\n var Nsides = sides.length;\n for(var j=0; j!==Nsides && !found; j++){\n for(var k=0; k!==Nsides && !found; k++){\n if(j%3 !== k%3){\n // Get edge tangent\n sides[k].cross(sides[j],edgeTangent);\n edgeTangent.normalize();\n sides[j].vadd(sides[k], edgeCenter);\n r.copy(xi);\n r.vsub(edgeCenter,r);\n r.vsub(xj,r);\n var orthonorm = r.dot(edgeTangent); // distance from edge center to sphere center in the tangent direction\n edgeTangent.mult(orthonorm,orthogonal); // Vector from edge center to sphere center in the tangent direction\n\n // Find the third side orthogonal to this one\n var l = 0;\n while(l===j%3 || l===k%3){\n l++;\n }\n\n // vec from edge center to sphere projected to the plane orthogonal to the edge tangent\n dist.copy(xi);\n dist.vsub(orthogonal,dist);\n dist.vsub(edgeCenter,dist);\n dist.vsub(xj,dist);\n\n // Distances in tangent direction and distance in the plane orthogonal to it\n var tdist = Math.abs(orthonorm);\n var ndist = dist.norm();\n\n if(tdist < sides[l].norm() && ndist si.boundingSphereRadius + sj.boundingSphereRadius){\n // return;\n // }\n\n // Check corners\n for(var i=0; i!==verts.length; i++){\n var v = verts[i];\n\n // World position of corner\n var worldCorner = sphereConvex_worldCorner;\n qj.vmult(v,worldCorner);\n xj.vadd(worldCorner,worldCorner);\n var sphere_to_corner = sphereConvex_sphereToCorner;\n worldCorner.vsub(xi, sphere_to_corner);\n if(sphere_to_corner.norm2() < R * R){\n found = true;\n var r = this.createContactEquation(bi,bj,si,sj);\n r.ri.copy(sphere_to_corner);\n r.ri.normalize();\n r.ni.copy(r.ri);\n r.ri.mult(R,r.ri);\n worldCorner.vsub(xj,r.rj);\n\n // Should be relative to the body.\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n\n // Should be relative to the body.\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n return;\n }\n }\n\n // Check side (plane) intersections\n var found = false;\n for(var i=0, nfaces=faces.length; i!==nfaces && found===false; i++){\n var normal = normals[i];\n var face = faces[i];\n\n // Get world-transformed normal of the face\n var worldNormal = sphereConvex_worldNormal;\n qj.vmult(normal,worldNormal);\n\n // Get a world vertex from the face\n var worldPoint = sphereConvex_worldPoint;\n qj.vmult(verts[face[0]],worldPoint);\n worldPoint.vadd(xj,worldPoint);\n\n // Get a point on the sphere, closest to the face normal\n var worldSpherePointClosestToPlane = sphereConvex_worldSpherePointClosestToPlane;\n worldNormal.mult(-R, worldSpherePointClosestToPlane);\n xi.vadd(worldSpherePointClosestToPlane, worldSpherePointClosestToPlane);\n\n // Vector from a face point to the closest point on the sphere\n var penetrationVec = sphereConvex_penetrationVec;\n worldSpherePointClosestToPlane.vsub(worldPoint,penetrationVec);\n\n // The penetration. Negative value means overlap.\n var penetration = penetrationVec.dot(worldNormal);\n\n var worldPointToSphere = sphereConvex_sphereToWorldPoint;\n xi.vsub(worldPoint, worldPointToSphere);\n\n if(penetration < 0 && worldPointToSphere.dot(worldNormal)>0){\n // Intersects plane. Now check if the sphere is inside the face polygon\n var faceVerts = []; // Face vertices, in world coords\n for(var j=0, Nverts=face.length; j!==Nverts; j++){\n var worldVertex = v3pool.get();\n qj.vmult(verts[face[j]], worldVertex);\n xj.vadd(worldVertex,worldVertex);\n faceVerts.push(worldVertex);\n }\n\n if(pointInPolygon(faceVerts,worldNormal,xi)){ // Is the sphere center in the face polygon?\n found = true;\n var r = this.createContactEquation(bi,bj,si,sj);\n\n worldNormal.mult(-R, r.ri); // Contact offset, from sphere center to contact\n worldNormal.negate(r.ni); // Normal pointing out of sphere\n\n var penetrationVec2 = v3pool.get();\n worldNormal.mult(-penetration, penetrationVec2);\n var penetrationSpherePoint = v3pool.get();\n worldNormal.mult(-R, penetrationSpherePoint);\n\n //xi.vsub(xj).vadd(penetrationSpherePoint).vadd(penetrationVec2 , r.rj);\n xi.vsub(xj,r.rj);\n r.rj.vadd(penetrationSpherePoint,r.rj);\n r.rj.vadd(penetrationVec2 , r.rj);\n\n // Should be relative to the body.\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n\n // Should be relative to the body.\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n\n v3pool.release(penetrationVec2);\n v3pool.release(penetrationSpherePoint);\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n\n // Release world vertices\n for(var j=0, Nfaceverts=faceVerts.length; j!==Nfaceverts; j++){\n v3pool.release(faceVerts[j]);\n }\n\n return; // We only expect *one* face contact\n } else {\n // Edge?\n for(var j=0; j!==face.length; j++){\n\n // Get two world transformed vertices\n var v1 = v3pool.get();\n var v2 = v3pool.get();\n qj.vmult(verts[face[(j+1)%face.length]], v1);\n qj.vmult(verts[face[(j+2)%face.length]], v2);\n xj.vadd(v1, v1);\n xj.vadd(v2, v2);\n\n // Construct edge vector\n var edge = sphereConvex_edge;\n v2.vsub(v1,edge);\n\n // Construct the same vector, but normalized\n var edgeUnit = sphereConvex_edgeUnit;\n edge.unit(edgeUnit);\n\n // p is xi projected onto the edge\n var p = v3pool.get();\n var v1_to_xi = v3pool.get();\n xi.vsub(v1, v1_to_xi);\n var dot = v1_to_xi.dot(edgeUnit);\n edgeUnit.mult(dot, p);\n p.vadd(v1, p);\n\n // Compute a vector from p to the center of the sphere\n var xi_to_p = v3pool.get();\n p.vsub(xi, xi_to_p);\n\n // Collision if the edge-sphere distance is less than the radius\n // AND if p is in between v1 and v2\n if(dot > 0 && dot*dot si.boundingSphereRadius + sj.boundingSphereRadius){\n return;\n }\n\n if(si.findSeparatingAxis(sj,xi,qi,xj,qj,sepAxis,faceListA,faceListB)){\n var res = [];\n var q = convexConvex_q;\n si.clipAgainstHull(xi,qi,sj,xj,qj,sepAxis,-100,100,res);\n var numContacts = 0;\n for(var j = 0; j !== res.length; j++){\n var r = this.createContactEquation(bi,bj,si,sj,rsi,rsj),\n ri = r.ri,\n rj = r.rj;\n sepAxis.negate(r.ni);\n res[j].normal.negate(q);\n q.mult(res[j].depth, q);\n res[j].point.vadd(q, ri);\n rj.copy(res[j].point);\n\n // Contact points are in world coordinates. Transform back to relative\n ri.vsub(xi,ri);\n rj.vsub(xj,rj);\n\n // Make relative to bodies\n ri.vadd(xi, ri);\n ri.vsub(bi.position, ri);\n rj.vadd(xj, rj);\n rj.vsub(bj.position, rj);\n\n this.result.push(r);\n numContacts++;\n if(!this.enableFrictionReduction){\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n if(this.enableFrictionReduction && numContacts){\n this.createFrictionFromAverage(numContacts);\n }\n }\n};\n\n\n/**\n * @method convexTrimesh\n * @param {Array} result\n * @param {Shape} si\n * @param {Shape} sj\n * @param {Vec3} xi\n * @param {Vec3} xj\n * @param {Quaternion} qi\n * @param {Quaternion} qj\n * @param {Body} bi\n * @param {Body} bj\n */\n// Narrowphase.prototype[Shape.types.CONVEXPOLYHEDRON | Shape.types.TRIMESH] =\n// Narrowphase.prototype.convexTrimesh = function(si,sj,xi,xj,qi,qj,bi,bj,rsi,rsj,faceListA,faceListB){\n// var sepAxis = convexConvex_sepAxis;\n\n// if(xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius){\n// return;\n// }\n\n// // Construct a temp hull for each triangle\n// var hullB = new ConvexPolyhedron();\n\n// hullB.faces = [[0,1,2]];\n// var va = new Vec3();\n// var vb = new Vec3();\n// var vc = new Vec3();\n// hullB.vertices = [\n// va,\n// vb,\n// vc\n// ];\n\n// for (var i = 0; i < sj.indices.length / 3; i++) {\n\n// var triangleNormal = new Vec3();\n// sj.getNormal(i, triangleNormal);\n// hullB.faceNormals = [triangleNormal];\n\n// sj.getTriangleVertices(i, va, vb, vc);\n\n// var d = si.testSepAxis(triangleNormal, hullB, xi, qi, xj, qj);\n// if(!d){\n// triangleNormal.scale(-1, triangleNormal);\n// d = si.testSepAxis(triangleNormal, hullB, xi, qi, xj, qj);\n\n// if(!d){\n// continue;\n// }\n// }\n\n// var res = [];\n// var q = convexConvex_q;\n// si.clipAgainstHull(xi,qi,hullB,xj,qj,triangleNormal,-100,100,res);\n// for(var j = 0; j !== res.length; j++){\n// var r = this.createContactEquation(bi,bj,si,sj,rsi,rsj),\n// ri = r.ri,\n// rj = r.rj;\n// r.ni.copy(triangleNormal);\n// r.ni.negate(r.ni);\n// res[j].normal.negate(q);\n// q.mult(res[j].depth, q);\n// res[j].point.vadd(q, ri);\n// rj.copy(res[j].point);\n\n// // Contact points are in world coordinates. Transform back to relative\n// ri.vsub(xi,ri);\n// rj.vsub(xj,rj);\n\n// // Make relative to bodies\n// ri.vadd(xi, ri);\n// ri.vsub(bi.position, ri);\n// rj.vadd(xj, rj);\n// rj.vsub(bj.position, rj);\n\n// result.push(r);\n// }\n// }\n// };\n\nvar particlePlane_normal = new Vec3();\nvar particlePlane_relpos = new Vec3();\nvar particlePlane_projected = new Vec3();\n\n/**\n * @method particlePlane\n * @param {Array} result\n * @param {Shape} si\n * @param {Shape} sj\n * @param {Vec3} xi\n * @param {Vec3} xj\n * @param {Quaternion} qi\n * @param {Quaternion} qj\n * @param {Body} bi\n * @param {Body} bj\n */\nNarrowphase.prototype[Shape.types.PLANE | Shape.types.PARTICLE] =\nNarrowphase.prototype.planeParticle = function(sj,si,xj,xi,qj,qi,bj,bi){\n var normal = particlePlane_normal;\n normal.set(0,0,1);\n bj.quaternion.vmult(normal,normal); // Turn normal according to plane orientation\n var relpos = particlePlane_relpos;\n xi.vsub(bj.position,relpos);\n var dot = normal.dot(relpos);\n if(dot <= 0.0){\n var r = this.createContactEquation(bi,bj,si,sj);\n r.ni.copy(normal); // Contact normal is the plane normal\n r.ni.negate(r.ni);\n r.ri.set(0,0,0); // Center of particle\n\n // Get particle position projected on plane\n var projected = particlePlane_projected;\n normal.mult(normal.dot(xi),projected);\n xi.vsub(projected,projected);\n //projected.vadd(bj.position,projected);\n\n // rj is now the projected world position minus plane position\n r.rj.copy(projected);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n};\n\nvar particleSphere_normal = new Vec3();\n\n/**\n * @method particleSphere\n * @param {Array} result\n * @param {Shape} si\n * @param {Shape} sj\n * @param {Vec3} xi\n * @param {Vec3} xj\n * @param {Quaternion} qi\n * @param {Quaternion} qj\n * @param {Body} bi\n * @param {Body} bj\n */\nNarrowphase.prototype[Shape.types.PARTICLE | Shape.types.SPHERE] =\nNarrowphase.prototype.sphereParticle = function(sj,si,xj,xi,qj,qi,bj,bi){\n // The normal is the unit vector from sphere center to particle center\n var normal = particleSphere_normal;\n normal.set(0,0,1);\n xi.vsub(xj,normal);\n var lengthSquared = normal.norm2();\n\n if(lengthSquared <= sj.radius * sj.radius){\n var r = this.createContactEquation(bi,bj,si,sj);\n normal.normalize();\n r.rj.copy(normal);\n r.rj.mult(sj.radius,r.rj);\n r.ni.copy(normal); // Contact normal\n r.ni.negate(r.ni);\n r.ri.set(0,0,0); // Center of particle\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n};\n\n// WIP\nvar cqj = new Quaternion();\nvar convexParticle_local = new Vec3();\nvar convexParticle_normal = new Vec3();\nvar convexParticle_penetratedFaceNormal = new Vec3();\nvar convexParticle_vertexToParticle = new Vec3();\nvar convexParticle_worldPenetrationVec = new Vec3();\n\n/**\n * @method convexParticle\n * @param {Array} result\n * @param {Shape} si\n * @param {Shape} sj\n * @param {Vec3} xi\n * @param {Vec3} xj\n * @param {Quaternion} qi\n * @param {Quaternion} qj\n * @param {Body} bi\n * @param {Body} bj\n */\nNarrowphase.prototype[Shape.types.PARTICLE | Shape.types.CONVEXPOLYHEDRON] =\nNarrowphase.prototype.convexParticle = function(sj,si,xj,xi,qj,qi,bj,bi){\n var penetratedFaceIndex = -1;\n var penetratedFaceNormal = convexParticle_penetratedFaceNormal;\n var worldPenetrationVec = convexParticle_worldPenetrationVec;\n var minPenetration = null;\n var numDetectedFaces = 0;\n\n // Convert particle position xi to local coords in the convex\n var local = convexParticle_local;\n local.copy(xi);\n local.vsub(xj,local); // Convert position to relative the convex origin\n qj.conjugate(cqj);\n cqj.vmult(local,local);\n\n if(sj.pointIsInside(local)){\n\n if(sj.worldVerticesNeedsUpdate){\n sj.computeWorldVertices(xj,qj);\n }\n if(sj.worldFaceNormalsNeedsUpdate){\n sj.computeWorldFaceNormals(qj);\n }\n\n // For each world polygon in the polyhedra\n for(var i=0,nfaces=sj.faces.length; i!==nfaces; i++){\n\n // Construct world face vertices\n var verts = [ sj.worldVertices[ sj.faces[i][0] ] ];\n var normal = sj.worldFaceNormals[i];\n\n // Check how much the particle penetrates the polygon plane.\n xi.vsub(verts[0],convexParticle_vertexToParticle);\n var penetration = -normal.dot(convexParticle_vertexToParticle);\n if(minPenetration===null || Math.abs(penetration) data.length || iMinY > data[0].length){\n return;\n }\n\n // Clamp index to edges\n if(iMinX < 0){ iMinX = 0; }\n if(iMaxX < 0){ iMaxX = 0; }\n if(iMinY < 0){ iMinY = 0; }\n if(iMaxY < 0){ iMaxY = 0; }\n if(iMinX >= data.length){ iMinX = data.length - 1; }\n if(iMaxX >= data.length){ iMaxX = data.length - 1; }\n if(iMaxY >= data[0].length){ iMaxY = data[0].length - 1; }\n if(iMinY >= data[0].length){ iMinY = data[0].length - 1; }\n\n var minMax = [];\n hfShape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax);\n var min = minMax[0];\n var max = minMax[1];\n\n // Bail out if we're cant touch the bounding height box\n if(localConvexPos.z - radius > max || localConvexPos.z + radius < min){\n return;\n }\n\n for(var i = iMinX; i < iMaxX; i++){\n for(var j = iMinY; j < iMaxY; j++){\n\n // Lower triangle\n hfShape.getConvexTrianglePillar(i, j, false);\n Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset);\n if (convexPos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + convexShape.boundingSphereRadius) {\n this.convexConvex(convexShape, hfShape.pillarConvex, convexPos, worldPillarOffset, convexQuat, hfQuat, convexBody, hfBody, null, null, faceList, null);\n }\n\n // Upper triangle\n hfShape.getConvexTrianglePillar(i, j, true);\n Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset);\n if (convexPos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + convexShape.boundingSphereRadius) {\n this.convexConvex(convexShape, hfShape.pillarConvex, convexPos, worldPillarOffset, convexQuat, hfQuat, convexBody, hfBody, null, null, faceList, null);\n }\n }\n }\n};\n\nvar sphereHeightfield_tmp1 = new Vec3();\nvar sphereHeightfield_tmp2 = new Vec3();\n\n/**\n * @method sphereHeightfield\n */\nNarrowphase.prototype[Shape.types.SPHERE | Shape.types.HEIGHTFIELD] =\nNarrowphase.prototype.sphereHeightfield = function (\n sphereShape,\n hfShape,\n spherePos,\n hfPos,\n sphereQuat,\n hfQuat,\n sphereBody,\n hfBody\n){\n var data = hfShape.data,\n radius = sphereShape.radius,\n w = hfShape.elementSize,\n worldPillarOffset = sphereHeightfield_tmp2;\n\n // Get sphere position to heightfield local!\n var localSpherePos = sphereHeightfield_tmp1;\n Transform.pointToLocalFrame(hfPos, hfQuat, spherePos, localSpherePos);\n\n // Get the index of the data points to test against\n var iMinX = Math.floor((localSpherePos.x - radius) / w) - 1,\n iMaxX = Math.ceil((localSpherePos.x + radius) / w) + 1,\n iMinY = Math.floor((localSpherePos.y - radius) / w) - 1,\n iMaxY = Math.ceil((localSpherePos.y + radius) / w) + 1;\n\n // Bail out if we are out of the terrain\n if(iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMaxY > data[0].length){\n return;\n }\n\n // Clamp index to edges\n if(iMinX < 0){ iMinX = 0; }\n if(iMaxX < 0){ iMaxX = 0; }\n if(iMinY < 0){ iMinY = 0; }\n if(iMaxY < 0){ iMaxY = 0; }\n if(iMinX >= data.length){ iMinX = data.length - 1; }\n if(iMaxX >= data.length){ iMaxX = data.length - 1; }\n if(iMaxY >= data[0].length){ iMaxY = data[0].length - 1; }\n if(iMinY >= data[0].length){ iMinY = data[0].length - 1; }\n\n var minMax = [];\n hfShape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax);\n var min = minMax[0];\n var max = minMax[1];\n\n // Bail out if we're cant touch the bounding height box\n if(localSpherePos.z - radius > max || localSpherePos.z + radius < min){\n return;\n }\n\n var result = this.result;\n for(var i = iMinX; i < iMaxX; i++){\n for(var j = iMinY; j < iMaxY; j++){\n\n var numContactsBefore = result.length;\n\n // Lower triangle\n hfShape.getConvexTrianglePillar(i, j, false);\n Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset);\n if (spherePos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + sphereShape.boundingSphereRadius) {\n this.sphereConvex(sphereShape, hfShape.pillarConvex, spherePos, worldPillarOffset, sphereQuat, hfQuat, sphereBody, hfBody);\n }\n\n // Upper triangle\n hfShape.getConvexTrianglePillar(i, j, true);\n Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset);\n if (spherePos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + sphereShape.boundingSphereRadius) {\n this.sphereConvex(sphereShape, hfShape.pillarConvex, spherePos, worldPillarOffset, sphereQuat, hfQuat, sphereBody, hfBody);\n }\n\n var numContacts = result.length - numContactsBefore;\n\n if(numContacts > 2){\n return;\n }\n /*\n // Skip all but 1\n for (var k = 0; k < numContacts - 1; k++) {\n result.pop();\n }\n */\n }\n }\n};\n\n},{\"../collision/AABB\":3,\"../collision/Ray\":9,\"../equations/ContactEquation\":19,\"../equations/FrictionEquation\":21,\"../math/Quaternion\":28,\"../math/Transform\":29,\"../math/Vec3\":30,\"../shapes/ConvexPolyhedron\":38,\"../shapes/Shape\":43,\"../solver/Solver\":47,\"../utils/Vec3Pool\":54}],56:[function(_dereq_,module,exports){\n/* global performance */\n\nmodule.exports = World;\n\nvar Shape = _dereq_('../shapes/Shape');\nvar Vec3 = _dereq_('../math/Vec3');\nvar Quaternion = _dereq_('../math/Quaternion');\nvar GSSolver = _dereq_('../solver/GSSolver');\nvar Vec3Pool = _dereq_('../utils/Vec3Pool');\nvar ContactEquation = _dereq_('../equations/ContactEquation');\nvar FrictionEquation = _dereq_('../equations/FrictionEquation');\nvar Narrowphase = _dereq_('./Narrowphase');\nvar EventTarget = _dereq_('../utils/EventTarget');\nvar ArrayCollisionMatrix = _dereq_('../collision/ArrayCollisionMatrix');\nvar Material = _dereq_('../material/Material');\nvar ContactMaterial = _dereq_('../material/ContactMaterial');\nvar Body = _dereq_('../objects/Body');\nvar TupleDictionary = _dereq_('../utils/TupleDictionary');\nvar RaycastResult = _dereq_('../collision/RaycastResult');\nvar AABB = _dereq_('../collision/AABB');\nvar Ray = _dereq_('../collision/Ray');\nvar NaiveBroadphase = _dereq_('../collision/NaiveBroadphase');\n\n/**\n * The physics world\n * @class World\n * @constructor\n * @extends EventTarget\n */\nfunction World(){\n EventTarget.apply(this);\n\n /**\n * Currently / last used timestep. Is set to -1 if not available. This value is updated before each internal step, which means that it is \"fresh\" inside event callbacks.\n * @property {Number} dt\n */\n this.dt = -1;\n\n /**\n * Makes bodies go to sleep when they've been inactive\n * @property allowSleep\n * @type {Boolean}\n */\n this.allowSleep = false;\n\n /**\n * All the current contacts (instances of ContactEquation) in the world.\n * @property contacts\n * @type {Array}\n */\n this.contacts = [];\n this.frictionEquations = [];\n\n /**\n * How often to normalize quaternions. Set to 0 for every step, 1 for every second etc.. A larger value increases performance. If bodies tend to explode, set to a smaller value (zero to be sure nothing can go wrong).\n * @property quatNormalizeSkip\n * @type {Number}\n */\n this.quatNormalizeSkip = 0;\n\n /**\n * Set to true to use fast quaternion normalization. It is often enough accurate to use. If bodies tend to explode, set to false.\n * @property quatNormalizeFast\n * @type {Boolean}\n * @see Quaternion.normalizeFast\n * @see Quaternion.normalize\n */\n this.quatNormalizeFast = false;\n\n /**\n * The wall-clock time since simulation start\n * @property time\n * @type {Number}\n */\n this.time = 0.0;\n\n /**\n * Number of timesteps taken since start\n * @property stepnumber\n * @type {Number}\n */\n this.stepnumber = 0;\n\n /// Default and last timestep sizes\n this.default_dt = 1/60;\n\n this.nextId = 0;\n /**\n * @property gravity\n * @type {Vec3}\n */\n this.gravity = new Vec3();\n\n /**\n * @property broadphase\n * @type {Broadphase}\n */\n this.broadphase = new NaiveBroadphase();\n\n /**\n * @property bodies\n * @type {Array}\n */\n this.bodies = [];\n\n /**\n * @property solver\n * @type {Solver}\n */\n this.solver = new GSSolver();\n\n /**\n * @property constraints\n * @type {Array}\n */\n this.constraints = [];\n\n /**\n * @property narrowphase\n * @type {Narrowphase}\n */\n this.narrowphase = new Narrowphase(this);\n\n /**\n * @property {ArrayCollisionMatrix} collisionMatrix\n\t * @type {ArrayCollisionMatrix}\n\t */\n\tthis.collisionMatrix = new ArrayCollisionMatrix();\n\n /**\n * CollisionMatrix from the previous step.\n * @property {ArrayCollisionMatrix} collisionMatrixPrevious\n\t * @type {ArrayCollisionMatrix}\n\t */\n\tthis.collisionMatrixPrevious = new ArrayCollisionMatrix();\n\n /**\n * All added materials\n * @property materials\n * @type {Array}\n */\n this.materials = [];\n\n /**\n * @property contactmaterials\n * @type {Array}\n */\n this.contactmaterials = [];\n\n /**\n * Used to look up a ContactMaterial given two instances of Material.\n * @property {TupleDictionary} contactMaterialTable\n */\n this.contactMaterialTable = new TupleDictionary();\n\n this.defaultMaterial = new Material(\"default\");\n\n /**\n * This contact material is used if no suitable contactmaterial is found for a contact.\n * @property defaultContactMaterial\n * @type {ContactMaterial}\n */\n this.defaultContactMaterial = new ContactMaterial(this.defaultMaterial, this.defaultMaterial, { friction: 0.3, restitution: 0.0 });\n\n /**\n * @property doProfiling\n * @type {Boolean}\n */\n this.doProfiling = false;\n\n /**\n * @property profile\n * @type {Object}\n */\n this.profile = {\n solve:0,\n makeContactConstraints:0,\n broadphase:0,\n integrate:0,\n narrowphase:0,\n };\n\n /**\n * @property subsystems\n * @type {Array}\n */\n this.subsystems = [];\n\n this.addBodyEvent = {\n type:\"addBody\",\n body : null,\n };\n\n this.removeBodyEvent = {\n type:\"removeBody\",\n body : null,\n };\n}\nWorld.prototype = new EventTarget();\n\n// Temp stuff\nvar tmpAABB1 = new AABB();\nvar tmpArray1 = [];\nvar tmpRay = new Ray();\n\n/**\n * Get the contact material between materials m1 and m2\n * @method getContactMaterial\n * @param {Material} m1\n * @param {Material} m2\n * @return {ContactMaterial} The contact material if it was found.\n */\nWorld.prototype.getContactMaterial = function(m1,m2){\n return this.contactMaterialTable.get(m1.id,m2.id); //this.contactmaterials[this.mats2cmat[i+j*this.materials.length]];\n};\n\n/**\n * Get number of objects in the world.\n * @method numObjects\n * @return {Number}\n * @deprecated\n */\nWorld.prototype.numObjects = function(){\n return this.bodies.length;\n};\n\n/**\n * Store old collision state info\n * @method collisionMatrixTick\n */\nWorld.prototype.collisionMatrixTick = function(){\n\tvar temp = this.collisionMatrixPrevious;\n\tthis.collisionMatrixPrevious = this.collisionMatrix;\n\tthis.collisionMatrix = temp;\n\tthis.collisionMatrix.reset();\n};\n\n/**\n * Add a rigid body to the simulation.\n * @method add\n * @param {Body} body\n * @todo If the simulation has not yet started, why recrete and copy arrays for each body? Accumulate in dynamic arrays in this case.\n * @todo Adding an array of bodies should be possible. This would save some loops too\n * @deprecated Use .addBody instead\n */\nWorld.prototype.add = World.prototype.addBody = function(body){\n if(this.bodies.indexOf(body) !== -1){\n return;\n }\n body.index = this.bodies.length;\n this.bodies.push(body);\n body.world = this;\n body.initPosition.copy(body.position);\n body.initVelocity.copy(body.velocity);\n body.timeLastSleepy = this.time;\n if(body instanceof Body){\n body.initAngularVelocity.copy(body.angularVelocity);\n body.initQuaternion.copy(body.quaternion);\n }\n\tthis.collisionMatrix.setNumObjects(this.bodies.length);\n this.addBodyEvent.body = body;\n this.dispatchEvent(this.addBodyEvent);\n};\n\n/**\n * Add a constraint to the simulation.\n * @method addConstraint\n * @param {Constraint} c\n */\nWorld.prototype.addConstraint = function(c){\n this.constraints.push(c);\n};\n\n/**\n * Removes a constraint\n * @method removeConstraint\n * @param {Constraint} c\n */\nWorld.prototype.removeConstraint = function(c){\n var idx = this.constraints.indexOf(c);\n if(idx!==-1){\n this.constraints.splice(idx,1);\n }\n};\n\n/**\n * Raycast test\n * @method rayTest\n * @param {Vec3} from\n * @param {Vec3} to\n * @param {Function|RaycastResult} result\n * @deprecated Use .raycastAll, .raycastClosest or .raycastAny instead.\n */\nWorld.prototype.rayTest = function(from, to, result){\n if(result instanceof RaycastResult){\n // Do raycastclosest\n this.raycastClosest(from, to, {\n skipBackfaces: true\n }, result);\n } else {\n // Do raycastAll\n this.raycastAll(from, to, {\n skipBackfaces: true\n }, result);\n }\n};\n\n/**\n * Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument.\n * @method raycastAll\n * @param {Vec3} from\n * @param {Vec3} to\n * @param {Object} options\n * @param {number} [options.collisionFilterMask=-1]\n * @param {number} [options.collisionFilterGroup=-1]\n * @param {boolean} [options.skipBackfaces=false]\n * @param {boolean} [options.checkCollisionResponse=true]\n * @param {Function} callback\n * @return {boolean} True if any body was hit.\n */\nWorld.prototype.raycastAll = function(from, to, options, callback){\n options.mode = Ray.ALL;\n options.from = from;\n options.to = to;\n options.callback = callback;\n return tmpRay.intersectWorld(this, options);\n};\n\n/**\n * Ray cast, and stop at the first result. Note that the order is random - but the method is fast.\n * @method raycastAny\n * @param {Vec3} from\n * @param {Vec3} to\n * @param {Object} options\n * @param {number} [options.collisionFilterMask=-1]\n * @param {number} [options.collisionFilterGroup=-1]\n * @param {boolean} [options.skipBackfaces=false]\n * @param {boolean} [options.checkCollisionResponse=true]\n * @param {RaycastResult} result\n * @return {boolean} True if any body was hit.\n */\nWorld.prototype.raycastAny = function(from, to, options, result){\n options.mode = Ray.ANY;\n options.from = from;\n options.to = to;\n options.result = result;\n return tmpRay.intersectWorld(this, options);\n};\n\n/**\n * Ray cast, and return information of the closest hit.\n * @method raycastClosest\n * @param {Vec3} from\n * @param {Vec3} to\n * @param {Object} options\n * @param {number} [options.collisionFilterMask=-1]\n * @param {number} [options.collisionFilterGroup=-1]\n * @param {boolean} [options.skipBackfaces=false]\n * @param {boolean} [options.checkCollisionResponse=true]\n * @param {RaycastResult} result\n * @return {boolean} True if any body was hit.\n */\nWorld.prototype.raycastClosest = function(from, to, options, result){\n options.mode = Ray.CLOSEST;\n options.from = from;\n options.to = to;\n options.result = result;\n return tmpRay.intersectWorld(this, options);\n};\n\n/**\n * Remove a rigid body from the simulation.\n * @method remove\n * @param {Body} body\n * @deprecated Use .removeBody instead\n */\nWorld.prototype.remove = function(body){\n body.world = null;\n var n = this.bodies.length-1,\n bodies = this.bodies,\n idx = bodies.indexOf(body);\n if(idx !== -1){\n bodies.splice(idx, 1); // Todo: should use a garbage free method\n\n // Recompute index\n for(var i=0; i!==bodies.length; i++){\n bodies[i].index = i;\n }\n\n this.collisionMatrix.setNumObjects(n);\n this.removeBodyEvent.body = body;\n this.dispatchEvent(this.removeBodyEvent);\n }\n};\n\n/**\n * Remove a rigid body from the simulation.\n * @method removeBody\n * @param {Body} body\n */\nWorld.prototype.removeBody = World.prototype.remove;\n\n/**\n * Adds a material to the World.\n * @method addMaterial\n * @param {Material} m\n * @todo Necessary?\n */\nWorld.prototype.addMaterial = function(m){\n this.materials.push(m);\n};\n\n/**\n * Adds a contact material to the World\n * @method addContactMaterial\n * @param {ContactMaterial} cmat\n */\nWorld.prototype.addContactMaterial = function(cmat) {\n\n // Add contact material\n this.contactmaterials.push(cmat);\n\n // Add current contact material to the material table\n this.contactMaterialTable.set(cmat.materials[0].id,cmat.materials[1].id,cmat);\n};\n\n// performance.now()\nif(typeof performance === 'undefined'){\n performance = {};\n}\nif(!performance.now){\n var nowOffset = Date.now();\n if (performance.timing && performance.timing.navigationStart){\n nowOffset = performance.timing.navigationStart;\n }\n performance.now = function(){\n return Date.now() - nowOffset;\n };\n}\n\nvar step_tmp1 = new Vec3();\n\n/**\n * Step the physics world forward in time.\n *\n * There are two modes. The simple mode is fixed timestepping without interpolation. In this case you only use the first argument. The second case uses interpolation. In that you also provide the time since the function was last used, as well as the maximum fixed timesteps to take.\n *\n * @method step\n * @param {Number} dt The fixed time step size to use.\n * @param {Number} [timeSinceLastCalled] The time elapsed since the function was last called.\n * @param {Number} [maxSubSteps=10] Maximum number of fixed steps to take per function call.\n *\n * @example\n * // fixed timestepping without interpolation\n * world.step(1/60);\n *\n * @see http://bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World\n */\nWorld.prototype.step = function(dt, timeSinceLastCalled, maxSubSteps){\n maxSubSteps = maxSubSteps || 10;\n timeSinceLastCalled = timeSinceLastCalled || 0;\n\n if(timeSinceLastCalled === 0){ // Fixed, simple stepping\n\n this.internalStep(dt);\n\n // Increment time\n this.time += dt;\n\n } else {\n\n // Compute the number of fixed steps we should have taken since the last step\n var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);\n internalSteps = Math.min(internalSteps,maxSubSteps);\n\n // Do some fixed steps to catch up\n var t0 = performance.now();\n for(var i=0; i!==internalSteps; i++){\n this.internalStep(dt);\n if(performance.now() - t0 > dt * 1000){\n // We are slower than real-time. Better bail out.\n break;\n }\n }\n\n // Increment internal clock\n this.time += timeSinceLastCalled;\n\n // Compute \"Left over\" time step\n var h = this.time % dt;\n var h_div_dt = h / dt;\n var interpvelo = step_tmp1;\n var bodies = this.bodies;\n\n for(var j=0; j !== bodies.length; j++){\n var b = bodies[j];\n if(b.type !== Body.STATIC && b.sleepState !== Body.SLEEPING){\n\n // Interpolate\n b.position.vsub(b.previousPosition, interpvelo);\n interpvelo.scale(h_div_dt, interpvelo);\n b.position.vadd(interpvelo, b.interpolatedPosition);\n\n // TODO: interpolate quaternion\n // b.interpolatedAngle = b.angle + (b.angle - b.previousAngle) * h_div_dt;\n\n } else {\n\n // For static bodies, just copy. Who else will do it?\n b.interpolatedPosition.copy(b.position);\n b.interpolatedQuaternion.copy(b.quaternion);\n }\n }\n }\n};\n\n/**\n * Step the simulation\n * @method step\n * @param {Number} dt\n */\nvar World_step_postStepEvent = {type:\"postStep\"}, // Reusable event objects to save memory\n World_step_preStepEvent = {type:\"preStep\"},\n World_step_collideEvent = {type:\"collide\", body:null, contact:null },\n World_step_oldContacts = [], // Pools for unused objects\n World_step_frictionEquationPool = [],\n World_step_p1 = [], // Reusable arrays for collision pairs\n World_step_p2 = [],\n World_step_gvec = new Vec3(), // Temporary vectors and quats\n World_step_vi = new Vec3(),\n World_step_vj = new Vec3(),\n World_step_wi = new Vec3(),\n World_step_wj = new Vec3(),\n World_step_t1 = new Vec3(),\n World_step_t2 = new Vec3(),\n World_step_rixn = new Vec3(),\n World_step_rjxn = new Vec3(),\n World_step_step_q = new Quaternion(),\n World_step_step_w = new Quaternion(),\n World_step_step_wq = new Quaternion(),\n invI_tau_dt = new Vec3();\nWorld.prototype.internalStep = function(dt){\n this.dt = dt;\n\n var world = this,\n that = this,\n contacts = this.contacts,\n p1 = World_step_p1,\n p2 = World_step_p2,\n N = this.numObjects(),\n bodies = this.bodies,\n solver = this.solver,\n gravity = this.gravity,\n doProfiling = this.doProfiling,\n profile = this.profile,\n DYNAMIC = Body.DYNAMIC,\n profilingStart,\n constraints = this.constraints,\n frictionEquationPool = World_step_frictionEquationPool,\n gnorm = gravity.norm(),\n gx = gravity.x,\n gy = gravity.y,\n gz = gravity.z,\n i=0;\n\n if(doProfiling){\n profilingStart = performance.now();\n }\n\n // Add gravity to all objects\n for(i=0; i!==N; i++){\n var bi = bodies[i];\n if(bi.type & DYNAMIC){ // Only for dynamic bodies\n var f = bi.force, m = bi.mass;\n f.x += m*gx;\n f.y += m*gy;\n f.z += m*gz;\n }\n }\n\n // Update subsystems\n for(var i=0, Nsubsystems=this.subsystems.length; i!==Nsubsystems; i++){\n this.subsystems[i].update();\n }\n\n // Collision detection\n if(doProfiling){ profilingStart = performance.now(); }\n p1.length = 0; // Clean up pair arrays from last step\n p2.length = 0;\n this.broadphase.collisionPairs(this,p1,p2);\n if(doProfiling){ profile.broadphase = performance.now() - profilingStart; }\n\n // Remove constrained pairs with collideConnected == false\n var Nconstraints = constraints.length;\n for(i=0; i!==Nconstraints; i++){\n var c = constraints[i];\n if(!c.collideConnected){\n for(var j = p1.length-1; j>=0; j-=1){\n if( (c.bodyA === p1[j] && c.bodyB === p2[j]) ||\n (c.bodyB === p1[j] && c.bodyA === p2[j])){\n p1.splice(j, 1);\n p2.splice(j, 1);\n }\n }\n }\n }\n\n this.collisionMatrixTick();\n\n // Generate contacts\n if(doProfiling){ profilingStart = performance.now(); }\n var oldcontacts = World_step_oldContacts;\n var NoldContacts = contacts.length;\n\n for(i=0; i!==NoldContacts; i++){\n oldcontacts.push(contacts[i]);\n }\n contacts.length = 0;\n\n // Transfer FrictionEquation from current list to the pool for reuse\n var NoldFrictionEquations = this.frictionEquations.length;\n for(i=0; i!==NoldFrictionEquations; i++){\n frictionEquationPool.push(this.frictionEquations[i]);\n }\n this.frictionEquations.length = 0;\n\n this.narrowphase.getContacts(\n p1,\n p2,\n this,\n contacts,\n oldcontacts, // To be reused\n this.frictionEquations,\n frictionEquationPool\n );\n\n if(doProfiling){\n profile.narrowphase = performance.now() - profilingStart;\n }\n\n // Loop over all collisions\n if(doProfiling){\n profilingStart = performance.now();\n }\n\n // Add all friction eqs\n for (var i = 0; i < this.frictionEquations.length; i++) {\n solver.addEquation(this.frictionEquations[i]);\n }\n\n var ncontacts = contacts.length;\n for(var k=0; k!==ncontacts; k++){\n\n // Current contact\n var c = contacts[k];\n\n // Get current collision indeces\n var bi = c.bi,\n bj = c.bj,\n si = c.si,\n sj = c.sj;\n\n // Get collision properties\n var cm;\n if(bi.material && bj.material){\n cm = this.getContactMaterial(bi.material,bj.material) || this.defaultContactMaterial;\n } else {\n cm = this.defaultContactMaterial;\n }\n\n // c.enabled = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse;\n\n var mu = cm.friction;\n // c.restitution = cm.restitution;\n\n // If friction or restitution were specified in the material, use them\n if(bi.material && bj.material){\n if(bi.material.friction >= 0 && bj.material.friction >= 0){\n mu = bi.material.friction * bj.material.friction;\n }\n\n if(bi.material.restitution >= 0 && bj.material.restitution >= 0){\n c.restitution = bi.material.restitution * bj.material.restitution;\n }\n }\n\n\t\t// c.setSpookParams(\n // cm.contactEquationStiffness,\n // cm.contactEquationRelaxation,\n // dt\n // );\n\n\t\tsolver.addEquation(c);\n\n\t\t// // Add friction constraint equation\n\t\t// if(mu > 0){\n\n\t\t// \t// Create 2 tangent equations\n\t\t// \tvar mug = mu * gnorm;\n\t\t// \tvar reducedMass = (bi.invMass + bj.invMass);\n\t\t// \tif(reducedMass > 0){\n\t\t// \t\treducedMass = 1/reducedMass;\n\t\t// \t}\n\t\t// \tvar pool = frictionEquationPool;\n\t\t// \tvar c1 = pool.length ? pool.pop() : new FrictionEquation(bi,bj,mug*reducedMass);\n\t\t// \tvar c2 = pool.length ? pool.pop() : new FrictionEquation(bi,bj,mug*reducedMass);\n\t\t// \tthis.frictionEquations.push(c1, c2);\n\n\t\t// \tc1.bi = c2.bi = bi;\n\t\t// \tc1.bj = c2.bj = bj;\n\t\t// \tc1.minForce = c2.minForce = -mug*reducedMass;\n\t\t// \tc1.maxForce = c2.maxForce = mug*reducedMass;\n\n\t\t// \t// Copy over the relative vectors\n\t\t// \tc1.ri.copy(c.ri);\n\t\t// \tc1.rj.copy(c.rj);\n\t\t// \tc2.ri.copy(c.ri);\n\t\t// \tc2.rj.copy(c.rj);\n\n\t\t// \t// Construct tangents\n\t\t// \tc.ni.tangents(c1.t, c2.t);\n\n // // Set spook params\n // c1.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, dt);\n // c2.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, dt);\n\n // c1.enabled = c2.enabled = c.enabled;\n\n\t\t// \t// Add equations to solver\n\t\t// \tsolver.addEquation(c1);\n\t\t// \tsolver.addEquation(c2);\n\t\t// }\n\n if( bi.allowSleep &&\n bi.type === Body.DYNAMIC &&\n bi.sleepState === Body.SLEEPING &&\n bj.sleepState === Body.AWAKE &&\n bj.type !== Body.STATIC\n ){\n var speedSquaredB = bj.velocity.norm2() + bj.angularVelocity.norm2();\n var speedLimitSquaredB = Math.pow(bj.sleepSpeedLimit,2);\n if(speedSquaredB >= speedLimitSquaredB*2){\n bi._wakeUpAfterNarrowphase = true;\n }\n }\n\n if( bj.allowSleep &&\n bj.type === Body.DYNAMIC &&\n bj.sleepState === Body.SLEEPING &&\n bi.sleepState === Body.AWAKE &&\n bi.type !== Body.STATIC\n ){\n var speedSquaredA = bi.velocity.norm2() + bi.angularVelocity.norm2();\n var speedLimitSquaredA = Math.pow(bi.sleepSpeedLimit,2);\n if(speedSquaredA >= speedLimitSquaredA*2){\n bj._wakeUpAfterNarrowphase = true;\n }\n }\n\n // Now we know that i and j are in contact. Set collision matrix state\n\t\tthis.collisionMatrix.set(bi, bj, true);\n\n if (!this.collisionMatrixPrevious.get(bi, bj)) {\n // First contact!\n // We reuse the collideEvent object, otherwise we will end up creating new objects for each new contact, even if there's no event listener attached.\n World_step_collideEvent.body = bj;\n World_step_collideEvent.contact = c;\n bi.dispatchEvent(World_step_collideEvent);\n\n World_step_collideEvent.body = bi;\n bj.dispatchEvent(World_step_collideEvent);\n }\n }\n if(doProfiling){\n profile.makeContactConstraints = performance.now() - profilingStart;\n profilingStart = performance.now();\n }\n\n // Wake up bodies\n for(i=0; i!==N; i++){\n var bi = bodies[i];\n if(bi._wakeUpAfterNarrowphase){\n bi.wakeUp();\n bi._wakeUpAfterNarrowphase = false;\n }\n }\n\n // Add user-added constraints\n var Nconstraints = constraints.length;\n for(i=0; i!==Nconstraints; i++){\n var c = constraints[i];\n c.update();\n for(var j=0, Neq=c.equations.length; j!==Neq; j++){\n var eq = c.equations[j];\n solver.addEquation(eq);\n }\n }\n\n // Solve the constrained system\n solver.solve(dt,this);\n\n if(doProfiling){\n profile.solve = performance.now() - profilingStart;\n }\n\n // Remove all contacts from solver\n solver.removeAllEquations();\n\n // Apply damping, see http://code.google.com/p/bullet/issues/detail?id=74 for details\n var pow = Math.pow;\n for(i=0; i!==N; i++){\n var bi = bodies[i];\n if(bi.type & DYNAMIC){ // Only for dynamic bodies\n var ld = pow(1.0 - bi.linearDamping,dt);\n var v = bi.velocity;\n v.mult(ld,v);\n var av = bi.angularVelocity;\n if(av){\n var ad = pow(1.0 - bi.angularDamping,dt);\n av.mult(ad,av);\n }\n }\n }\n\n this.dispatchEvent(World_step_preStepEvent);\n\n // Invoke pre-step callbacks\n for(i=0; i!==N; i++){\n var bi = bodies[i];\n if(bi.preStep){\n bi.preStep.call(bi);\n }\n }\n\n // Leap frog\n // vnew = v + h*f/m\n // xnew = x + h*vnew\n if(doProfiling){\n profilingStart = performance.now();\n }\n var q = World_step_step_q;\n var w = World_step_step_w;\n var wq = World_step_step_wq;\n var stepnumber = this.stepnumber;\n var DYNAMIC_OR_KINEMATIC = Body.DYNAMIC | Body.KINEMATIC;\n var quatNormalize = stepnumber % (this.quatNormalizeSkip+1) === 0;\n var quatNormalizeFast = this.quatNormalizeFast;\n var half_dt = dt * 0.5;\n var PLANE = Shape.types.PLANE,\n CONVEX = Shape.types.CONVEXPOLYHEDRON;\n\n for(i=0; i!==N; i++){\n var b = bodies[i],\n force = b.force,\n tau = b.torque;\n if((b.type & DYNAMIC_OR_KINEMATIC) && b.sleepState !== Body.SLEEPING){ // Only for dynamic\n var velo = b.velocity,\n angularVelo = b.angularVelocity,\n pos = b.position,\n quat = b.quaternion,\n invMass = b.invMass,\n invInertia = b.invInertiaWorld;\n\n velo.x += force.x * invMass * dt;\n velo.y += force.y * invMass * dt;\n velo.z += force.z * invMass * dt;\n\n if(b.angularVelocity){\n invInertia.vmult(tau,invI_tau_dt);\n invI_tau_dt.mult(dt,invI_tau_dt);\n invI_tau_dt.vadd(angularVelo,angularVelo);\n }\n\n // Use new velocity - leap frog\n pos.x += velo.x * dt;\n pos.y += velo.y * dt;\n pos.z += velo.z * dt;\n\n if(b.angularVelocity){\n w.set(angularVelo.x, angularVelo.y, angularVelo.z, 0);\n w.mult(quat,wq);\n quat.x += half_dt * wq.x;\n quat.y += half_dt * wq.y;\n quat.z += half_dt * wq.z;\n quat.w += half_dt * wq.w;\n if(quatNormalize){\n if(quatNormalizeFast){\n quat.normalizeFast();\n } else {\n quat.normalize();\n }\n }\n }\n\n if(b.aabb){\n b.aabbNeedsUpdate = true;\n }\n\n // Update world inertia\n if(b.updateInertiaWorld){\n b.updateInertiaWorld();\n }\n }\n }\n this.clearForces();\n\n this.broadphase.dirty = true;\n\n if(doProfiling){\n profile.integrate = performance.now() - profilingStart;\n }\n\n // Update world time\n this.time += dt;\n this.stepnumber += 1;\n\n this.dispatchEvent(World_step_postStepEvent);\n\n // Invoke post-step callbacks\n for(i=0; i!==N; i++){\n var bi = bodies[i];\n var postStep = bi.postStep;\n if(postStep){\n postStep.call(bi);\n }\n }\n\n // Sleeping update\n if(this.allowSleep){\n for(i=0; i!==N; i++){\n bodies[i].sleepTick(this.time);\n }\n }\n};\n\n/**\n * Sets all body forces in the world to zero.\n * @method clearForces\n */\nWorld.prototype.clearForces = function(){\n var bodies = this.bodies;\n var N = bodies.length;\n for(var i=0; i !== N; i++){\n var b = bodies[i],\n force = b.force,\n tau = b.torque;\n\n b.force.set(0,0,0);\n b.torque.set(0,0,0);\n }\n};\n\n},{\"../collision/AABB\":3,\"../collision/ArrayCollisionMatrix\":4,\"../collision/NaiveBroadphase\":7,\"../collision/Ray\":9,\"../collision/RaycastResult\":10,\"../equations/ContactEquation\":19,\"../equations/FrictionEquation\":21,\"../material/ContactMaterial\":24,\"../material/Material\":25,\"../math/Quaternion\":28,\"../math/Vec3\":30,\"../objects/Body\":31,\"../shapes/Shape\":43,\"../solver/GSSolver\":46,\"../utils/EventTarget\":49,\"../utils/TupleDictionary\":52,\"../utils/Vec3Pool\":54,\"./Narrowphase\":55}]},{},[2])\n(2)\n});","// Imports\nimport ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \"../node_modules/css-loader/dist/runtime/noSourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `html, body, canvas {\n margin: 0;\n padding: 0;\n width: 100%;\n height: 100%;\n font-size: 12;\n overflow: hidden;\n}\n\n\n\n/* Solid border */\nhr.solid {\n border-top: 1px solid #bbb;\n margin-top: 15px;\n margin-bottom: 15px;\n}\n\n #l_ui{\n padding: 20PX;\n border-style: solid;\n border-color: gray;\n border-radius: 5px;\n position: absolute;\n top : 20px;\n left : 20px;\n color: black;\n background-color: wheat;\n }\n \n #r_ui{\n padding: 30PX;\n border-style: solid;\n border-color: gray;\n border-radius: 5px;\n position: absolute;\n /* top : 20px; */\n right : 60px;\n color: black;\n background-color: #e4e4e4;\n}\n\n .btn {\n border: 2px solid black;\n background-color: white;\n color: black;\n padding: 10px 25px;\n font-size: 16px;\n cursor: pointer;\n margin-left: 37px; \n }\n \n /* Blue */\n .info {\n border-color: #2196F3;\n color: dodgerblue;\n text-align: center;\n }\n \n .info:hover {\n background: #2196F3;\n color: white;\n }\n\n /* Red */\n .danger {\n border-color: #f44336;\n color: red;\n margin-top: 8px;\n text-align: center;\n width: 116px;\n }\n .danger:hover {\n background: #f44336;\n color: white;\n }\n\n #leftEngineInput, #rightEngineInput{\n width: 60px;\n\n }\n #leftEngineInput{\n margin-left: 8px;\n\n }\n\n .switch {\n position: relative;\n display: inline-block;\n width: 50px;\n height: 25px;\n margin-left: 50px;\n }\n \n .switch input { \n opacity: 0;\n width: 0;\n height: 0;\n }\n \n .slider {\n position: absolute;\n cursor: pointer;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #ccc;\n -webkit-transition: .4s;\n transition: .4s;\n overflow: hidden;\n \n }\n \n .slider:before {\n position: absolute;\n content: \"\";\n height: 16px;\n width: 16px;\n left: 4px;\n bottom: 4px;\n background-color: white;\n -webkit-transition: .4s;\n transition: .4s;\n }\n \n input:checked + .slider {\n background-color: #2196F3;\n }\n \n input:focus + .slider {\n box-shadow: 0 0 1px #2196F3;\n }\n \n input:checked + .slider:before {\n -webkit-transform: translateX(26px);\n -ms-transform: translateX(26px);\n transform: translateX(26px);\n }\n \n /* Rounded sliders */\n .slider.round {\n border-radius: 34px;\n }\n \n .slider.round:before {\n border-radius: 50%;\n }\n .btn-primary\n {\n position: absolute;\n left: 50%;\n top: 50%;\n align-self: center;\n transform: translate(-50%, -50%);\n }\n #myvideo{\n position: absolute;\n width: 480px;\n height: 320px;\n left: 0%;\n top: 0%;\n border: #f44336;\n display: none;\n }\n #fps {\n position: absolute;\n background-color: black;\n border: 2px solid red;\n text-align: center;\n font-size: 16px;\n color: white;\n top: 15px;\n right: 10px;\n width: 60px;\n height: 20px;\n}\n\n.loader {\n position: absolute;\n border: 8px solid #f3f3f3; /* Light grey */\n border-top: 8px solid #3498db; /* Blue */\n border-radius: 50%;\n width: 64px;\n height: 64px;\n animation: spin 2s linear infinite;\n left: 50%;\n top: 50%;\n margin-top: -32px;\n transform: translate(-50%, -50%);\n display: none;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}`, \"\"]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n","\"use strict\";\n\n/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra\n*/\nmodule.exports = function (cssWithMappingToString) {\n var list = [];\n\n // return the list of modules as css string\n list.toString = function toString() {\n return this.map(function (item) {\n var content = \"\";\n var needLayer = typeof item[5] !== \"undefined\";\n if (item[4]) {\n content += \"@supports (\".concat(item[4], \") {\");\n }\n if (item[2]) {\n content += \"@media \".concat(item[2], \" {\");\n }\n if (needLayer) {\n content += \"@layer\".concat(item[5].length > 0 ? \" \".concat(item[5]) : \"\", \" {\");\n }\n content += cssWithMappingToString(item);\n if (needLayer) {\n content += \"}\";\n }\n if (item[2]) {\n content += \"}\";\n }\n if (item[4]) {\n content += \"}\";\n }\n return content;\n }).join(\"\");\n };\n\n // import a list of modules into the list\n list.i = function i(modules, media, dedupe, supports, layer) {\n if (typeof modules === \"string\") {\n modules = [[null, modules, undefined]];\n }\n var alreadyImportedModules = {};\n if (dedupe) {\n for (var k = 0; k < this.length; k++) {\n var id = this[k][0];\n if (id != null) {\n alreadyImportedModules[id] = true;\n }\n }\n }\n for (var _k = 0; _k < modules.length; _k++) {\n var item = [].concat(modules[_k]);\n if (dedupe && alreadyImportedModules[item[0]]) {\n continue;\n }\n if (typeof layer !== \"undefined\") {\n if (typeof item[5] === \"undefined\") {\n item[5] = layer;\n } else {\n item[1] = \"@layer\".concat(item[5].length > 0 ? \" \".concat(item[5]) : \"\", \" {\").concat(item[1], \"}\");\n item[5] = layer;\n }\n }\n if (media) {\n if (!item[2]) {\n item[2] = media;\n } else {\n item[1] = \"@media \".concat(item[2], \" {\").concat(item[1], \"}\");\n item[2] = media;\n }\n }\n if (supports) {\n if (!item[4]) {\n item[4] = \"\".concat(supports);\n } else {\n item[1] = \"@supports (\".concat(item[4], \") {\").concat(item[1], \"}\");\n item[4] = supports;\n }\n }\n list.push(item);\n }\n };\n return list;\n};","\"use strict\";\n\nmodule.exports = function (i) {\n return i[1];\n};","\n import API from \"!../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../node_modules/css-loader/dist/cjs.js!./index.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\n\n options.insert = insertFn.bind(null, \"head\");\n \noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../node_modules/css-loader/dist/cjs.js!./index.css\";\n export default content && content.locals ? content.locals : undefined;\n","\"use strict\";\n\nvar stylesInDOM = [];\nfunction getIndexByIdentifier(identifier) {\n var result = -1;\n for (var i = 0; i < stylesInDOM.length; i++) {\n if (stylesInDOM[i].identifier === identifier) {\n result = i;\n break;\n }\n }\n return result;\n}\nfunction modulesToDom(list, options) {\n var idCountMap = {};\n var identifiers = [];\n for (var i = 0; i < list.length; i++) {\n var item = list[i];\n var id = options.base ? item[0] + options.base : item[0];\n var count = idCountMap[id] || 0;\n var identifier = \"\".concat(id, \" \").concat(count);\n idCountMap[id] = count + 1;\n var indexByIdentifier = getIndexByIdentifier(identifier);\n var obj = {\n css: item[1],\n media: item[2],\n sourceMap: item[3],\n supports: item[4],\n layer: item[5]\n };\n if (indexByIdentifier !== -1) {\n stylesInDOM[indexByIdentifier].references++;\n stylesInDOM[indexByIdentifier].updater(obj);\n } else {\n var updater = addElementStyle(obj, options);\n options.byIndex = i;\n stylesInDOM.splice(i, 0, {\n identifier: identifier,\n updater: updater,\n references: 1\n });\n }\n identifiers.push(identifier);\n }\n return identifiers;\n}\nfunction addElementStyle(obj, options) {\n var api = options.domAPI(options);\n api.update(obj);\n var updater = function updater(newObj) {\n if (newObj) {\n if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {\n return;\n }\n api.update(obj = newObj);\n } else {\n api.remove();\n }\n };\n return updater;\n}\nmodule.exports = function (list, options) {\n options = options || {};\n list = list || [];\n var lastIdentifiers = modulesToDom(list, options);\n return function update(newList) {\n newList = newList || [];\n for (var i = 0; i < lastIdentifiers.length; i++) {\n var identifier = lastIdentifiers[i];\n var index = getIndexByIdentifier(identifier);\n stylesInDOM[index].references--;\n }\n var newLastIdentifiers = modulesToDom(newList, options);\n for (var _i = 0; _i < lastIdentifiers.length; _i++) {\n var _identifier = lastIdentifiers[_i];\n var _index = getIndexByIdentifier(_identifier);\n if (stylesInDOM[_index].references === 0) {\n stylesInDOM[_index].updater();\n stylesInDOM.splice(_index, 1);\n }\n }\n lastIdentifiers = newLastIdentifiers;\n };\n};","\"use strict\";\n\nvar memo = {};\n\n/* istanbul ignore next */\nfunction getTarget(target) {\n if (typeof memo[target] === \"undefined\") {\n var styleTarget = document.querySelector(target);\n\n // Special case to return head of iframe instead of iframe itself\n if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {\n try {\n // This will throw an exception if access to iframe is blocked\n // due to cross-origin restrictions\n styleTarget = styleTarget.contentDocument.head;\n } catch (e) {\n // istanbul ignore next\n styleTarget = null;\n }\n }\n memo[target] = styleTarget;\n }\n return memo[target];\n}\n\n/* istanbul ignore next */\nfunction insertBySelector(insert, style) {\n var target = getTarget(insert);\n if (!target) {\n throw new Error(\"Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.\");\n }\n target.appendChild(style);\n}\nmodule.exports = insertBySelector;","\"use strict\";\n\n/* istanbul ignore next */\nfunction insertStyleElement(options) {\n var element = document.createElement(\"style\");\n options.setAttributes(element, options.attributes);\n options.insert(element, options.options);\n return element;\n}\nmodule.exports = insertStyleElement;","\"use strict\";\n\n/* istanbul ignore next */\nfunction setAttributesWithoutAttributes(styleElement) {\n var nonce = typeof __webpack_nonce__ !== \"undefined\" ? __webpack_nonce__ : null;\n if (nonce) {\n styleElement.setAttribute(\"nonce\", nonce);\n }\n}\nmodule.exports = setAttributesWithoutAttributes;","\"use strict\";\n\n/* istanbul ignore next */\nfunction apply(styleElement, options, obj) {\n var css = \"\";\n if (obj.supports) {\n css += \"@supports (\".concat(obj.supports, \") {\");\n }\n if (obj.media) {\n css += \"@media \".concat(obj.media, \" {\");\n }\n var needLayer = typeof obj.layer !== \"undefined\";\n if (needLayer) {\n css += \"@layer\".concat(obj.layer.length > 0 ? \" \".concat(obj.layer) : \"\", \" {\");\n }\n css += obj.css;\n if (needLayer) {\n css += \"}\";\n }\n if (obj.media) {\n css += \"}\";\n }\n if (obj.supports) {\n css += \"}\";\n }\n var sourceMap = obj.sourceMap;\n if (sourceMap && typeof btoa !== \"undefined\") {\n css += \"\\n/*# sourceMappingURL=data:application/json;base64,\".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), \" */\");\n }\n\n // For old IE\n /* istanbul ignore if */\n options.styleTagTransform(css, styleElement, options.options);\n}\nfunction removeStyleElement(styleElement) {\n // istanbul ignore if\n if (styleElement.parentNode === null) {\n return false;\n }\n styleElement.parentNode.removeChild(styleElement);\n}\n\n/* istanbul ignore next */\nfunction domAPI(options) {\n if (typeof document === \"undefined\") {\n return {\n update: function update() {},\n remove: function remove() {}\n };\n }\n var styleElement = options.insertStyleElement(options);\n return {\n update: function update(obj) {\n apply(styleElement, options, obj);\n },\n remove: function remove() {\n removeStyleElement(styleElement);\n }\n };\n}\nmodule.exports = domAPI;","\"use strict\";\n\n/* istanbul ignore next */\nfunction styleTagTransform(css, styleElement) {\n if (styleElement.styleSheet) {\n styleElement.styleSheet.cssText = css;\n } else {\n while (styleElement.firstChild) {\n styleElement.removeChild(styleElement.firstChild);\n }\n styleElement.appendChild(document.createTextNode(css));\n }\n}\nmodule.exports = styleTagTransform;","export default class BallonAnim{\r\n\r\n constructor(scene) {\r\n this.scene = scene;\r\n this.ballonObj = undefined;\r\n this.frameRate=30;\r\n }\r\n setBallonObj(_obj)\r\n {\r\n this.ballonObj = _obj;\r\n this.ballonObj.setEnabled(false);\r\n }\r\n setBallonPos(pos)\r\n {\r\n this.ballonObj.setEnabled(true);\r\n console.log(pos);\r\n this.ballonObj.position = new BABYLON.Vector3(pos.x, 1, pos.z);\r\n this.ballonObj.rotation = new BABYLON.Vector3(0, 0, 0);\r\n this.ballonAnim(); \r\n \r\n }\r\n ballonAnim()\r\n {\r\n let animation = new BABYLON.Animation(\"ballonanimation\", \"position\",this.frameRate ,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);\r\n let keys = [];\r\n keys.push({\r\n frame: 0,\r\n value: this.ballonObj.position\r\n });\r\n keys.push({\r\n frame: 120,\r\n value: new BABYLON.Vector3(this.ballonObj.position.x,this.ballonObj.position.y+10,this.ballonObj.position.z)\r\n });\r\n animation.setKeys(keys);\r\n this.ballonObj.animations.push(animation);\r\n\r\n \r\n\r\n let rotanimation = new BABYLON.Animation(\"ballonanimation\", \"rotation.x\",this.frameRate ,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);\r\n let rotkeys = [];\r\n rotkeys.push({\r\n frame: 0,\r\n value: 0\r\n });\r\n rotkeys.push({\r\n frame: 40,\r\n value: Math.PI\r\n });\r\n rotkeys.push({\r\n frame: 80,\r\n value: 0\r\n });\r\n rotkeys.push({\r\n frame: 120,\r\n value:-Math.PI\r\n });\r\n rotanimation.setKeys(rotkeys);\r\n this.ballonObj.animations.push(rotanimation);\r\n \r\n \r\n let tout = setTimeout(async () => {\r\n clearTimeout(tout);\r\n let anim = this.scene.beginAnimation(this.ballonObj,0,120,false);\r\n await anim.waitAsync();\r\n this.ballonObj.setEnabled(false);\r\n console.log(\"end\");\r\n });\r\n\r\n }\r\n\r\n}","// http://www.stat.phys.kyushu-u.ac.jp/~nakanisi/ThreeJS/CannonDemo/double-pendulum.html\r\n// https://bruno-simon.com/\r\n// https://grabcad.com/library/gripper-servo-motor-1\r\nlet angle =0;\r\nimport * as BABYLON from \"babylonjs\";\r\nimport * as CANNON from \"cannon\";\r\nimport * as Utils from \"./utils.js\";\r\nimport DistanceSensorGenerator from \"./Helper/DistanceSensorGenerator.js\";\r\nimport DistanceSensorGenerator2 from \"./Helper/DistanceSensorGenerator2.js\";\r\nimport FlameSensorGenerator from \"./Helper/FlameSensorGenerator.js\";\r\nimport ColorSensorGenerator from \"./Helper/ColorSensorGenerator.js\";\r\nimport FanSensor from \"./Helper/FanSensor.js\";\r\nimport FanComponentGenerator from \"./Components/FanComponentGenerator.js\";\r\nimport { LightComponent } from \"./Components/LightComponent.js\";\r\nimport MyJoints from \"./Helper/MyJoints.js\";\r\nimport {MOTORSPEED} from './Helper/MyJoints.js';\r\nlet SX=0,SY=0,SZ=0;\r\nlet jointLeftMarker,jointRightMarker;\r\nexport default class CarManager {\r\n constructor(sceneManager, carposition,spotlight) {\r\n this.game = sceneManager.game;\r\n this.arcCam = sceneManager.arcCam;\r\n this.world = sceneManager.worldManager.world;\r\n this.boxes = sceneManager.worldManager.boxes;\r\n this.scene = sceneManager.scene;\r\n this.loaderManager = sceneManager.loaderManager;\r\n this.carposition = carposition;\r\n\r\n this.inputs = sceneManager.Inputs;\r\n this.worldManager = sceneManager.worldManager;\r\n this.alphaMaterial = sceneManager.alphaMaterial;\r\n\r\n //Model Names\r\n this.wheel1 = \"Wheel\";\r\n this.carModel = \"Car\";\r\n this.lights = \"Mesh8_Group8_Model\";\r\n this.steeringModel = \"steering\";\r\n\r\n this.chassisShape;\r\n this.vehicle=null;\r\n this.text = {forceOn: 0,brakeOn: 0,};\r\n\r\n this.babylonWheelBodies = [];\r\n this.wheelBodies = [];\r\n this.chassisBody;\r\n this.cannonCar;\r\n //CarVal's\r\n this.brakeForce = Utils.maxBrakeForce;\r\n this.maxSteerVal = .5;\r\n this.maxForce = Utils.maxForce;\r\n // this.gravityY = Utils.GRAVITY;\r\n this.options = {\r\n radius: 0.3,\r\n directionLocal: new CANNON.Vec3(0,0,-1),\r\n suspensionStiffness: 40,\r\n suspensionRestLength: 0.4,\r\n frictionSlip: 5,\r\n dampingRelaxation: 2.3,\r\n dampingCompression: 4.5,\r\n maxSuspensionForce: 100000,\r\n rollInfluence: 0.01,\r\n axleLocal: new CANNON.Vec3(0,1, 0),\r\n chassisConnectionPointLocal: new CANNON.Vec3(1, 1, 0),\r\n maxSuspensionTravel: 0.4,\r\n customSlidingRotationalSpeed: -40,\r\n useCustomSlidingRotationalSpeed: true,\r\n };\r\n this.doorMat = new BABYLON.StandardMaterial(\"door_Mat\", this.scene);\r\n this.doorMat.diffuseColor = BABYLON.Color3.Red();\r\n\r\n this.robotBody = null;\r\n this.babylonCarBox,this.robotRoot,this.robotBox;\r\n\r\n this.leftEnginePower = 0;\r\n this.rightEnginePower = 0;\r\n\r\n this.spotLight = spotlight;\r\n this.hemiLight = sceneManager.sceneCommon.hemiLight;\r\n \r\n \r\n this.damping=.1;\r\n this.maxDamping=1;\r\n\r\n this.tmpleftPower=0;\r\n this.tmpRightPower=0;\r\n this.sameDirection=0;\r\n this.fwdDirection=0;\r\n this.revDirection=0;\r\n this.changetout=0; \r\n\r\n this.robotIndicator=[];\r\n // window[\"callloop\"] = this.callloop.bind(this);\r\n this.loadCarModel(sceneManager);\r\n window[\"trackCamera\"] = this.trackCamera.bind(this); \r\n window[\"setjointPickUp\"] = this.setjointPickUp.bind(this); \r\n window[\"setGrabjoint\"] = this.setGrabjoint.bind(this); \r\n }\r\n \r\n loadCarModel(sceneManager) {\r\n //Set Up The Model\r\n this.robotBody = this.scene.getTransformNodeByName(this.carModel);\r\n \r\n let bodyMat = this.scene.getMaterialByName(\"silver.001\");\r\n bodyMat.albedoColor = new BABYLON.Color3.White();\r\n bodyMat.metallic = 0.3;\r\n bodyMat.roughness = 1;\r\n\r\n let middlePartMat = this.scene.getMaterialByName(\"darkwhite.001\");\r\n middlePartMat.metallic = 1;\r\n middlePartMat.roughness = 0.45;\r\n\r\n let gonotMat = this.scene.getMaterialByName(\"silver\");\r\n gonotMat.albedoColor = new BABYLON.Color3.White();\r\n gonotMat.metallic = 0.7;\r\n gonotMat.roughness = 0.65;\r\n\r\n //Review\r\n // this.robotBody.getChildMeshes(false)[0].isPickable = false;\r\n // let robotMat = this.robotBody.getChildMeshes(false)[0].material;\r\n // robotMat.metallic = 0.55;\r\n // robotMat.roughness = 0.4;\r\n\r\n this.robotBody.position = new BABYLON.Vector3(0,0,-0.8);\r\n this.robotBody.rotation = new BABYLON.Vector3(-Math.PI * 1,Math.PI * 0.5,Math.PI * 0.5);\r\n this.robotBody.scaling = new BABYLON.Vector3(20,20,-20);\r\n this.cannonCar = this.createCannonVehicle();\r\n try{\r\n this.initRoboSensor(sceneManager); \r\n } catch(error){}\r\n // console.log(\"Robot Created !!\");\r\n }\r\n createRobotJoint(robot_rotation){\r\n const position = {x:this.chassisBody.position.x,y:this.chassisBody.position.y,z:this.chassisBody.position.z};\r\n const force =1e9;\r\n this.pickLeft = new MyJoints(\"pick_left\",this,{x:.7,y:.2,z:.1},position,2,{r:255,g:0,b:0});\r\n this.pickLeft.createJoint(this.chassisBody,new CANNON.Vec3(.65,-.35,0),new CANNON.Vec3(0,1,0),new CANNON.Vec3(-.35,0,0),new CANNON.Vec3(0,0,1),force,robot_rotation);\r\n this.pickLeft.grabBody.mass=0;\r\n // this.pickLeft.grabBody.collisionFilterGroup =0;\r\n // this.pickLeft.grabBody.collisionFilterMask =0;\r\n\r\n this.grabLeft = new MyJoints(\"grab_left\",this,{x:.5,y:.2,z:.05},position,.5,{r:255,g:255,b:0});\r\n const size={x:.02,y:.02,z:.1};\r\n let shape = new CANNON.Box(new CANNON.Vec3(size.x,size.y,size.z));\r\n const boxL1 = BABYLON.MeshBuilder.CreateBox(\"handbox\",{ width:size.x*2,height:size.y*2,size:size.z*2},this.scene); \r\n const mat = new BABYLON.StandardMaterial(\"hand_mat\");\r\n mat.diffuseColor = new BABYLON.Color3.FromInts(0,0,255);\r\n boxL1.material = mat;\r\n const posL1 = {x:0,y:-.1,z:-size.z};\r\n boxL1.position = new BABYLON.Vector3(posL1.x,posL1.y,posL1.z);\r\n boxL1.parent = this.grabLeft.grabJointMesh;\r\n this.grabLeft.grabBody.addShape(shape,new CANNON.Vec3(posL1.x,posL1.y,posL1.z));\r\n\r\n const boxL2 = boxL1.clone(); \r\n const posL2 = {x:0,y:.1,z:-size.z};\r\n boxL2.position = new BABYLON.Vector3(posL2.x,posL2.y,posL2.z);\r\n boxL2.parent = this.grabLeft.grabJointMesh;\r\n this.grabLeft.grabBody.addShape(shape,new CANNON.Vec3(posL2.x,posL2.y,posL2.z));\r\n \r\n const boxL3 = boxL1.clone(); \r\n const posL3 = {x:.25,y:-.1,z:-size.z};\r\n boxL3.position = new BABYLON.Vector3(posL3.x,posL3.y,posL3.z);\r\n boxL3.parent = this.grabLeft.grabJointMesh;\r\n this.grabLeft.grabBody.addShape(shape,new CANNON.Vec3(posL3.x,posL3.y,posL3.z));\r\n\r\n const boxL4 = boxL1.clone(); \r\n const posL4 = {x:.25,y:.1,z:-size.z};\r\n boxL4.position = new BABYLON.Vector3(posL4.x,posL4.y,posL4.z);\r\n boxL4.parent = this.grabLeft.grabJointMesh;\r\n this.grabLeft.grabBody.addShape(shape,new CANNON.Vec3(posL4.x,posL4.y,posL4.z));\r\n this.grabLeft.createJoint(this.pickLeft.grabBody,new CANNON.Vec3(.35,0,0),new CANNON.Vec3(0,1,0),new CANNON.Vec3(-.25,0,0),new CANNON.Vec3(0,1,0),force,robot_rotation);\r\n this.grabLeft.grabBody.mass=0;\r\n \r\n this.pickRight = new MyJoints(\"pick_right\",this,{x:.7,y:.2,z:.1},position,2,{r:255,g:0,b:0});\r\n this.pickRight.createJoint(this.chassisBody,new CANNON.Vec3(.65,.35,0),new CANNON.Vec3(0,1,0),new CANNON.Vec3(-.35,0,0),new CANNON.Vec3(0,0,1),force,robot_rotation);\r\n this.pickRight.grabBody.mass=0;\r\n // this.pickRight.grabBody.collisionFilterGroup = 0;\r\n // this.pickRight.grabBody.collisionFilterMask = 0;\r\n\r\n this.grabRight = new MyJoints(\"grab_right\",this,{x:.5,y:.2,z:.05},position,.5,{r:255,g:255,b:0});\r\n const boxR1 = boxL1.clone(); \r\n const posR1 = {x:0,y:-.1,z:size.z}\r\n boxR1.position = new BABYLON.Vector3(posR1.x,posR1.y,posR1.z);\r\n boxR1.parent = this.grabRight.grabJointMesh;\r\n this.grabRight.grabBody.addShape(shape,new CANNON.Vec3(posR1.x,posR1.y,posR1.z));\r\n\r\n const boxR2 = boxL1.clone(); \r\n const posR2 = {x:0,y:.1,z:size.z}\r\n boxR2.position = new BABYLON.Vector3(posR2.x,posR2.y,posR2.z);\r\n boxR2.parent = this.grabRight.grabJointMesh;\r\n this.grabRight.grabBody.addShape(shape,new CANNON.Vec3(posR2.x,posR2.y,posR2.z));\r\n\r\n const boxR3 = boxL1.clone(); \r\n const posR3 = {x:.25,y:-.1,z:size.z}\r\n boxR3.position = new BABYLON.Vector3(posR3.x,posR3.y,posR3.z);\r\n boxR3.parent = this.grabRight.grabJointMesh;\r\n this.grabRight.grabBody.addShape(shape,new CANNON.Vec3(posR3.x,posR3.y,posR3.z));\r\n\r\n const boxR4 = boxL1.clone(); \r\n const posR4 = {x:.25,y:.1,z:size.z}\r\n boxR4.position = new BABYLON.Vector3(posR4.x,posR4.y,posR4.z);\r\n boxR4.parent = this.grabRight.grabJointMesh;\r\n this.grabRight.grabBody.addShape(shape,new CANNON.Vec3(posR4.x,posR4.y,posR4.z));\r\n this.grabRight.createJoint(this.pickRight.grabBody,new CANNON.Vec3(.35,0,0),new CANNON.Vec3(0,1,0),new CANNON.Vec3(-.25,0,0),new CANNON.Vec3(0,1,0),force,robot_rotation);\r\n this.grabRight.grabBody.mass=0;\r\n \r\n this.chassisBody.velocity.set(0, 0, 0);\r\n this.chassisBody.angularVelocity.set(0, 0, 0);\r\n this.chassisBody.linearDamping = this.maxDamping;\r\n this.chassisBody.angularDamping = this.maxDamping;\r\n\r\n this.pickcenter = new MyJoints(\"pick_center\",this,{x:.7,y:.2,z:.1},position,1,{r:255,g:128,b:255});\r\n this.pickcenter.createJoint(this.chassisBody,new CANNON.Vec3(.65,0,0),new CANNON.Vec3(0,1,0),new CANNON.Vec3(-.35,0,0),new CANNON.Vec3(0,0,1),force,robot_rotation);\r\n this.pickcenter.grabBody.mass=0;\r\n this.pickcenter.grabJointMesh.visibility=0;\r\n this.pickcenter.grabBody.collisionFilterGroup=0;\r\n this.pickcenter.grabBody.collisionFilterMask =0;\r\n\r\n this.jointCeter = new MyJoints(\"joint_center\",this,{x:.1,y:.1,z:.1},position,.5,{r:255,g:0,b:255});\r\n this.jointCeter.createJoint(this.pickcenter.grabBody,new CANNON.Vec3(.68,.05,0),new CANNON.Vec3(0,1,0),new CANNON.Vec3(0,0,0),new CANNON.Vec3(0,1,0),force,robot_rotation);\r\n this.jointCeter.grabJointMesh.visibility=0;\r\n this.jointCeter.grabBody.mass=0;\r\n this.jointCeter.grabBody.collisionFilterGroup = 0;\r\n this.jointCeter.grabBody.collisionFilterMask = 0;\r\n\r\n\r\n jointLeftMarker = BABYLON.MeshBuilder.CreateSphere(\"joint_center\",{diameter:.1});\r\n const mat1 = new BABYLON.StandardMaterial(\"mat\");\r\n mat1.diffuseColor = new BABYLON.Color3(0,0,0);\r\n jointLeftMarker.material = mat1;\r\n jointLeftMarker.position.x=.25;\r\n jointLeftMarker.visibility=0;\r\n \r\n jointRightMarker = jointLeftMarker.clone(\"joint_clone2\");\r\n jointLeftMarker.parent = this.grabLeft.grabJointMesh;\r\n jointRightMarker.parent = this.grabRight.grabJointMesh;\r\n // console.log(\" ^^^^^ createJoint%%%% \");\r\n }\r\n createCannonVehicle(){\r\n const sizeXYZ = new BABYLON.Vector3(1.7,1.5,0.6);\r\n this.robotBox = BABYLON.MeshBuilder.CreateBox(\"rootbox\",{ width:sizeXYZ.x,height:sizeXYZ.y,size:sizeXYZ.z},this.scene);\r\n this.robotBox.position.set(this.carposition.x,this.carposition.y+1,this.carposition.z);\r\n this.robotBox.rotation.x= Math.PI/2;\r\n this.robotBox.isPickable=false;\r\n this.robotBox.visibility=0;\r\n this.chassisShape = new CANNON.Box(new CANNON.Vec3(sizeXYZ.x*.5,sizeXYZ.y*.5,sizeXYZ.z*.5));\r\n this.chassisShape.position = new CANNON.Vec3(0,0,0);\r\n this.chassisShape.quaternion = new CANNON.Quaternion();\r\n this.chassisBody = new CANNON.Body({ mass: Utils.robtotBodyMass});\r\n this.chassisBody.name = \"robotbody\"\r\n this.chassisBody.addShape(this.chassisShape,this.chassisShape.position,this.chassisShape.quaternion);\r\n this.chassisBody.position.set(this.carposition.x,this.carposition.y+1,this.carposition.z);\r\n this.chassisBody.quaternion.setFromAxisAngle(new CANNON.Vec3(-1,0,0),Math.PI / 2);\r\n this.chassisBody.velocity.set(0, 0, 0);\r\n this.chassisBody.angularVelocity.set(0, 0, 0);\r\n this.chassisBody.linearDamping = this.damping;\r\n this.chassisBody.angularDamping = this.damping;\r\n this.babylonCarBox = this.createBabylonChassisBody(this.chassisBody);\r\n this.babylonCarBox.scaling = new BABYLON.Vector3(Utils.scaleFactor,Utils.scaleFactor,Utils.scaleFactor);\r\n this.vehicle = new CANNON.RaycastVehicle({chassisBody: this.chassisBody});\r\n this.options.chassisConnectionPointLocal.set(.69, .76, 0.16);\r\n this.vehicle.addWheel(this.options);\r\n this.options.chassisConnectionPointLocal.set(.69,-.76, 0.16);\r\n this.vehicle.addWheel(this.options);\r\n this.options.chassisConnectionPointLocal.set(-.69, .76, 0.16);\r\n this.vehicle.addWheel(this.options);\r\n this.options.chassisConnectionPointLocal.set(-.69, -.76, 0.16);\r\n this.vehicle.addWheel(this.options);\r\n this.vehicle.addToWorld(this.world);\r\n this.worldManager.boxes.push({pCube:this.chassisBody,vCube:this.robotBox});\r\n this.worldManager.boxes.push({pCube:this.chassisBody,vCube:this.babylonCarBox});\r\n // setTimeout(() => {\r\n this.setRobotRotation(0);\r\n // }, 3000);\r\n // let wheelBodies = [];\r\n\r\n for (var i = 0; i < this.vehicle.wheelInfos.length; i++) {\r\n const wheel = this.vehicle.wheelInfos[i];\r\n const cylinderShape = new CANNON.Cylinder(wheel.radius,wheel.radius,wheel.radius,20);\r\n const wheelBody = new CANNON.Body({mass: Utils.weheelBodyMass,});\r\n wheelBody.type = CANNON.Body.KINEMATIC;\r\n\r\n wheelBody.collisionFilterGroup = 0; // turn off collisions\r\n const q = new CANNON.Quaternion();\r\n q.setFromAxisAngle(new CANNON.Vec3(1, 0, 0), Math.PI / 2);\r\n wheelBody.addShape(cylinderShape, new CANNON.Vec3(), q);\r\n this.createBabylonWheelBodies(wheelBody);\r\n this.world.add(wheelBody);\r\n this.wheelBodies.push(wheelBody);\r\n }\r\n\r\n let wheelMesh = this.scene.getTransformNodeByName(this.wheel1);\r\n wheelMesh.scaling = new BABYLON.Vector3(13,13,13);\r\n // wheelbody.getChildMeshes(\r\n // false\r\n // )[0].material.albedoColor = new BABYLON.Color3.Red();\r\n\r\n const w1 = wheelMesh.clone();\r\n w1.isVisible = false;\r\n w1.setEnabled(true);\r\n w1.name = \"w1_1\";\r\n w1.rotation = new BABYLON.Vector3(0, 0, Math.PI / 2);\r\n\r\n const w2 = wheelMesh.clone();\r\n w2.isVisible = false;\r\n w2.setEnabled(true);\r\n w2.name = \"w2_1\";\r\n w2.rotation = new BABYLON.Vector3(0, 0, Math.PI / 2);\r\n w2.scaling.x *= -1;\r\n\r\n const w3 = wheelMesh.clone();\r\n w3.isVisible = false;\r\n w3.setEnabled(true);\r\n w3.name = \"w3_1\";\r\n w3.rotation = new BABYLON.Vector3(0, 0, Math.PI / 2);\r\n\r\n const w4 = wheelMesh.clone();\r\n w4.isVisible = false;\r\n w4.setEnabled(true);\r\n w4.name = \"w4_1\";\r\n w4.rotation = new BABYLON.Vector3(0, 0, Math.PI / 2);\r\n w4.scaling.x *= -1;\r\n\r\n wheelMesh.setEnabled(false);\r\n w1.parent = this.babylonWheelBodies[0];\r\n w2.parent = this.babylonWheelBodies[1];\r\n w3.parent = this.babylonWheelBodies[2];\r\n w4.parent = this.babylonWheelBodies[3];\r\n // this.world.addEventListener(\"postStep\", () => {\r\n // this.scene.getTransformNodeByName(this.wheel1).rotation.y = 3;\r\n // for (let i = 0; i < this.vehicle.wheelInfos.length; i++) {\r\n // this.vehicle.updateWheelTransform(i);\r\n // let t = this.vehicle.wheelInfos[i].worldTransform;\r\n // let wheelBody = this.wheelBodies[i];\r\n // wheelBody.position.copy(t.position);\r\n // wheelBody.quaternion.copy(t.quaternion);\r\n // if (this.babylonWheelBodies[i]) {\r\n // this.babylonWheelBodies[i].position = new BABYLON.Vector3(wheelBody.position.x,wheelBody.position.y,wheelBody.position.z);\r\n // this.babylonWheelBodies[i].rotationQuaternion = new BABYLON.Quaternion(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w);\r\n // }\r\n // }\r\n // });\r\n\r\n this.scene.registerBeforeRender(() => {//runRenderLoop\r\n if(this.world){\r\n // for (let i = 0; i < this.worldManager.boxes.length; i++) {\r\n // this.worldManager.boxes[i].vCube.position = new BABYLON.Vector3(this.worldManager.boxes[i].pCube.position.x,this.worldManager.boxes[i].pCube.position.y,this.worldManager.boxes[i].pCube.position.z);\r\n // this.worldManager.boxes[i].vCube.rotationQuaternion =new BABYLON.Quaternion(\r\n // this.worldManager.boxes[i].pCube.quaternion.x,\r\n // this.worldManager.boxes[i].pCube.quaternion.y,\r\n // this.worldManager.boxes[i].pCube.quaternion.z,\r\n // this.worldManager.boxes[i].pCube.quaternion.w\r\n // );\r\n // }\r\n }\r\n if (this.babylonCarBox){\r\n // this.babylonCarBox.position = new BABYLON.Vector3(this.chassisBody.position.x,this.chassisBody.position.y,this.chassisBody.position.z);\r\n // this.babylonCarBox.rotationQuaternion = new BABYLON.Quaternion(this.chassisBody.quaternion.x,this.chassisBody.quaternion.y,this.chassisBody.quaternion.z,this.chassisBody.quaternion.w);\r\n if(this.grabLeft){\r\n this.checkGrabJointMovement(); \r\n // const aa = this.pickLeft.grabJointMesh.rotationQuaternion.toEulerAngles();\r\n // console.log(BABYLON.Angle.FromRadians(aa.z).degrees());\r\n }\r\n if(this.getRobotVelocity()>0){\r\n this.robotIndicator[0].lightMesh.material = this.robotIndicator[0].enableMat;\r\n }\r\n else{\r\n if(this.changetout<20)\r\n this.robotIndicator[0].lightMesh.material = this.robotIndicator[0].disableMat;\r\n else if(this.changetout>=20 && this.changetout<40)\r\n this.robotIndicator[0].lightMesh.material = this.robotIndicator[0].enableMat;\r\n this.changetout %=40;\r\n this.changetout++;\r\n }\r\n }\r\n if(this.inputs){\r\n this.inputs.xInput.value = this.babylonCarBox.position.x.toFixed(2);\r\n this.inputs.yInput.value = this.babylonCarBox.position.y.toFixed(2);\r\n this.inputs.zInput.value = this.babylonCarBox.position.z.toFixed(2);\r\n this.inputs.vInput.value = this.getRobotVelocity().toFixed(2);\r\n }\r\n });\r\n // this.carCtrl();\r\n return this.vehicle;\r\n }\r\n updatewheel(){\r\n for (let i = 0; i < this.vehicle.wheelInfos.length; i++) {\r\n this.vehicle.updateWheelTransform(i);\r\n let t = this.vehicle.wheelInfos[i].worldTransform;\r\n let wheelBody = this.wheelBodies[i];\r\n wheelBody.position.copy(t.position);\r\n wheelBody.quaternion.copy(t.quaternion);\r\n if (this.babylonWheelBodies[i]) {\r\n this.babylonWheelBodies[i].position = new BABYLON.Vector3(wheelBody.position.x,wheelBody.position.y,wheelBody.position.z);\r\n this.babylonWheelBodies[i].rotationQuaternion = new BABYLON.Quaternion(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w);\r\n }\r\n }\r\n }\r\n \r\n createBabylonWheelBodies(body) {\r\n let shape = body.shapes[0];\r\n let size = shape.boundingSphereRadius;\r\n // let wheel = BABYLON.MeshBuilder.CreateCylinder(\"wheel\",{diameterTop:size*2,diameterBottom:size*2,height:size,subdivisions:20},this.scene);\r\n let wheel = new BABYLON.TransformNode(\"wheel\",this.scene);\r\n wheel.scaling.set(size * 2,size * 2,size * 2);\r\n // wheel.rotationQuaternion = new BABYLON.Quaternion();\r\n wheel.receiveShadows = false;\r\n wheel.isVisible = true;\r\n //shadowGenerator.getShadowMap().renderList.push(wheel);\r\n this.babylonWheelBodies.push(wheel);\r\n }\r\n createBabylonChassisBody(body) {\r\n // for (let i = 0; i < body.shapes.length; i++) {\r\n // let shape = body.shapes[i];\r\n // let size = shape.halfExtents;\r\n this.robotRoot = new BABYLON.TransformNode(\"robotroot\",this.scene);\r\n // this.robotRoot = BABYLON.MeshBuilder.CreateBox(\"robotcollidebox\",{ height:size.y*2,width: size.x *2, depth: size.z*2},this.scene);\r\n this.robotRoot.visibility=0; \r\n this.robotRoot.isPickable=false;\r\n // }\r\n const plane = BABYLON.MeshBuilder.CreatePlane(\"plane\", {height:.52,width:2.08,sideOrientation: BABYLON.Mesh.DOUBLESIDE},this.scene);\r\n plane.rotation = new BABYLON.Vector3(0,Math.PI,0);\r\n plane.position.z+=.15;\r\n plane.position.x-=.15;\r\n plane.isPickable=false;\r\n this.spotLight.excludedMeshes.push(plane); \r\n this.hemiLight.excludedMeshes.push(plane); \r\n let planemat = new BABYLON.StandardMaterial(\"namematerial\", this.scene);\r\n planemat.diffuseTexture = new BABYLON.Texture(\"/textures/RoboSenseiNewLogo.png\",this.scene);\r\n planemat.emissiveColor = new BABYLON.Color3(1,1,1);\r\n planemat.diffuseTexture.hasAlpha = true;\r\n plane.material = planemat;\r\n plane.parent = this.robotRoot;\r\n \r\n this.robotBody.parent = this.robotRoot;\r\n this.centerBox = BABYLON.MeshBuilder.CreateBox(\"centerBox\",{ size: 1 },this.scene);\r\n this.centerBox.position = new BABYLON.Vector3(0, 0, 0);\r\n this.centerBox.parent = this.robotRoot;\r\n this.centerBox.isVisible = false;\r\n this.spotLight.parent = this.robotRoot;\r\n return this.robotRoot;\r\n }\r\n getDist(pickedPoint,myPoint) {\r\n return Math.abs(BABYLON.Vector3.Distance(pickedPoint, myPoint));\r\n }\r\n getRobotVelocity() {\r\n return Math.round(Math.sqrt(this.chassisBody.velocity.x * this.chassisBody.velocity.x + this.chassisBody.velocity.y * this.chassisBody.velocity.y+\r\n this.chassisBody.velocity.z * this.chassisBody.velocity.z));\r\n }\r\n applyEnginesPowers(leftEnginePowerp, rightEnginePowerp) {\r\n const MAX=100;\r\n let leftEnginePower = Math.round((leftEnginePowerp *this.maxForce) / MAX)*-1;\r\n let rightEnginePower = Math.round((rightEnginePowerp*this.maxForce) / MAX)*-1;\r\n // this.leftEngineSpeed = Math.abs(Math.round((leftEnginePowerp * Utils.maxVelocity) / 100));\r\n // this.rightEngineSpeed = Math.abs(Math.round((rightEnginePowerp * Utils.maxVelocity) / 100));\r\n leftEnginePower = this.clamp(leftEnginePower,-this.maxForce,this.maxForce);\r\n rightEnginePower = this.clamp(rightEnginePower,-this.maxForce,this.maxForce);\r\n this.checkDirection(leftEnginePower,rightEnginePower,Utils.maxBrakeForce);\r\n this.steeringValue = -(leftEnginePower-rightEnginePower)/MAX;\r\n this.steeringValue /= 4;\r\n // console.log(\" !!! steer !!!! \"+this.steeringValue+\" \"+(leftEnginePower - rightEnginePower));\r\n this.steeringValue = this.clamp(this.steeringValue,-this.maxSteerVal,this.maxSteerVal); \r\n let extrapower=1;\r\n if(Math.abs(leftEnginePower) === Math.abs(rightEnginePower) && Math.abs(this.steeringValue)>0){\r\n extrapower =-15; \r\n this.steeringValue = 0;\r\n }\r\n this.leftEnginePower = leftEnginePower * extrapower;\r\n this.rightEnginePower = rightEnginePower * extrapower;\r\n this.fireEvents();\r\n this.applyDrive();\r\n }\r\n applyDrive(){\r\n this.chassisBody.linearDamping = this.damping;\r\n this.chassisBody.angularDamping = this.damping;\r\n\r\n this.cannonCar.setBrake(0, 0);\r\n this.cannonCar.setBrake(0, 1); \r\n this.cannonCar.setBrake(0, 2);\r\n this.cannonCar.setBrake(0, 3);\r\n\r\n this.cannonCar.setSteeringValue(this.steeringValue,0);\r\n this.cannonCar.setSteeringValue(this.steeringValue,1);\r\n\r\n this.cannonCar.applyEngineForce(this.leftEnginePower ,2);\r\n this.cannonCar.applyEngineForce(this.rightEnginePower,3);\r\n \r\n // console.log(\"!!! leftpower!!! \"+this.leftEnginePower+\" !!rightpower!!! \"+this.rightEnginePower+\" \"+extrapower+\" \"+this.steeringValue)\r\n if(this.inputs){\r\n this.inputs.xInput.value = this.babylonCarBox.position.x.toFixed(2);\r\n this.inputs.yInput.value = this.babylonCarBox.position.y.toFixed(2);\r\n this.inputs.zInput.value = this.babylonCarBox.position.z.toFixed(2);\r\n this.inputs.vInput.value = this.getRobotVelocity().toFixed(2);\r\n }\r\n \r\n }\r\n checkDirection(leftpower,rightpower,_brake) {\r\n // console.log(this.tmpleftPower+\" !!! left!!! \"+leftpower+\" !!! right!! \"+this.tmpRightPower+\" !! !! \"+rightpower);\r\n if(Math.abs(leftpower)0) || (leftpower>0 && rightpower<0))){\r\n this.sameDirection =1;\r\n this.fwdDirection =0;\r\n this.revDirection =0;\r\n this.applyBrake();\r\n // console.log( \"!!! checkDirection samedirection!!! \"+this.tmpleftPower+\" \"+this.tmpRightPower); \r\n }\r\n if((this.fwdDirection ===0) && (leftpower<0 && rightpower<0)){\r\n this.sameDirection =0;\r\n this.fwdDirection =1;\r\n this.revDirection =0;\r\n this.applyBrake();\r\n // console.log( \"!!! checkDirection fwdDirection!!! \"+this.tmpleftPower+\" \"+this.tmpRightPower); \r\n }\r\n if((this.revDirection ===0) && (leftpower>0 && rightpower>0)){\r\n this.sameDirection = 0;\r\n this.fwdDirection = 0;\r\n this.revDirection = 1;\r\n this.applyBrake();\r\n // console.log( \"!!! checkDirection revDirection!!! \"+this.tmpleftPower+\" \"+this.tmpRightPower); \r\n } \r\n }\r\n this.tmpleftPower = Math.abs(leftpower);\r\n this.tmpRightPower = Math.abs(rightpower);\r\n }\r\n applyBrake(){\r\n this.chassisBody.linearDamping = this.maxDamping;\r\n this.chassisBody.angularDamping = this.maxDamping;\r\n this.chassisBody.velocity = new CANNON.Vec3(0,0,0);\r\n this.cannonCar.setBrake(Utils.maxBrakeForce,2);\r\n this.cannonCar.setBrake(Utils.maxBrakeForce,3); \r\n }\r\n fireEvents(){\r\n let event = new CustomEvent(Utils.events.changemotor,{detail:{leftmotorpower:this.leftEnginePower,rightmotorpower:this.rightEnginePower}});\r\n document.dispatchEvent(event);\r\n }\r\n stopEngines() {\r\n this.applyBrake();\r\n this.leftEnginePower = 0;\r\n this.rightEnginePower = 0;\r\n this.cannonCar.applyEngineForce(this.leftEnginePower ,2);\r\n this.cannonCar.applyEngineForce(this.rightEnginePower,3);\r\n }\r\n clamp(number, min, max) {\r\n return Math.max(min, Math.min(number, max));\r\n }\r\n setRobotPosition(x,y,z){\r\n y=1.5;\r\n // this.carposition = new BABYLON.Vector3(x,y,z);\r\n this.chassisBody.position = new CANNON.Vec3(x,y,z);\r\n // this.babylonCarBox.position = new BABYLON.Vector3(this.chassisBody.position.x,this.chassisBody.position.y,this.chassisBody.position.z);\r\n }\r\n setRobotRotation(angle){\r\n // this.chassisBody.quaternion.setFromAxisAngle(new CANNON.Vec3(0,-1,0),BABYLON.Angle.FromDegrees(angle).radians());\r\n const quatX = new CANNON.Quaternion();\r\n const quatY = new CANNON.Quaternion();\r\n quatX.setFromAxisAngle(new CANNON.Vec3(-1,0,0),Math.PI/2);\r\n quatY.setFromAxisAngle(new CANNON.Vec3(0,1,0), BABYLON.Angle.FromDegrees(angle).radians());\r\n const quaternion = quatY.mult(quatX);\r\n quaternion.normalize();\r\n this.chassisBody.quaternion = quaternion;\r\n // this.babylonCarBox.rotationQuaternion = new BABYLON.Quaternion(this.chassisBody.quaternion.x,this.chassisBody.quaternion.y,this.chassisBody.quaternion.z,this.chassisBody.quaternion.w);\r\n this.chassisBody.velocity.set(0, 0, 0);\r\n this.chassisBody.angularVelocity.set(0, 0, 0);\r\n // this.createRobotJoint(angle);\r\n }\r\n turnOnRobotLight(){\r\n this.robotIndicator[1].lightMesh.material = this.robotIndicator[1].enableMat;\r\n this.robotIndicator[2].lightMesh.material = this.robotIndicator[2].enableMat;\r\n }\r\n turnOffRobotLight(){\r\n this.robotIndicator[1].lightMesh.material = this.robotIndicator[1].disableMat;\r\n this.robotIndicator[2].lightMesh.material = this.robotIndicator[2].disableMat;\r\n }\r\n releaseRobot(){\r\n this.scene.removeMesh(this.babylonCarBox);\r\n this.babylonCarBox.dispose();\r\n this.world.remove(this.chassisBody);\r\n this.world.remove(this.vehicle);\r\n for(let i=0;i {\r\n const { state, name, direction } = results;\r\n // console.log(\" results ===>\", results)\r\n if(this.inputs){\r\n this.inputs.disState.innerHTML = state;\r\n if (name && direction) {\r\n this.inputs.dis_name.value = name;\r\n this.inputs.dis_dir.value = direction;\r\n }\r\n }\r\n };\r\n //DistanceSensor\r\n this.distanceSensor = new DistanceSensorGenerator2(\r\n \"distanceSensor\",\r\n new BABYLON.Vector3(1.8,0,0.25),//position\r\n new BABYLON.Vector3(1,0,0),\r\n this.babylonCarBox, //car body\r\n 40,\r\n 100,\r\n false,\r\n dis_callback,\r\n this.scene,\r\n );\r\n this.spotLight.excludedMeshes.push(this.distanceSensor.lightIndicator.lightMesh); \r\n this.hemiLight.excludedMeshes.push(this.distanceSensor.lightIndicator.lightMesh); \r\n const flameSensor_callback = (results) => {\r\n const { value, name, direction, power, state } = results;\r\n if(this.inputs){\r\n this.inputs.flameSensorDis.innerHTML = value;\r\n this.inputs.flameSensorName.value = name;\r\n this.inputs.flameSensorValue.value = `${power}%`;\r\n }\r\n };\r\n //FlameSensor\r\n this.flameSensor = new FlameSensorGenerator(\r\n \"FlameSensor One\",\r\n new BABYLON.Vector3(1.3, 0, 1.17),\r\n new BABYLON.Vector3(1, 0, 0),\r\n this.babylonCarBox, //car body\r\n 20,\r\n 500,\r\n false,\r\n flameSensor_callback,\r\n this.scene,\r\n );\r\n this.spotLight.excludedMeshes.push(this.flameSensor.lightIndicator.lightMesh); \r\n this.hemiLight.excludedMeshes.push(this.flameSensor.lightIndicator.lightMesh); \r\n\r\n const leftIR_callback = (results) => {\r\n const { state, colorR, colorG, colorB, color,IR } = results;\r\n if(this.inputs){\r\n this.inputs.l_surState.innerHTML = state;\r\n this.inputs.l_surR.value = colorR;\r\n this.inputs.l_surG.value = colorG;\r\n this.inputs.l_surB.value = colorB;\r\n\r\n this.inputs.left_IR.value = IR;\r\n this.inputs.l_surImg.style.backgroundColor = color;\r\n }\r\n };\r\n this.leftcolorSensor = new ColorSensorGenerator(\r\n \"LeftcolorSensor\",\r\n new BABYLON.Vector3(1.6, -0.2, -0.1),\r\n new BABYLON.Vector3(0, -1, 0),\r\n this.babylonCarBox,\r\n 3,\r\n 50,\r\n false,\r\n leftIR_callback,\r\n this.scene,\r\n );\r\n this.spotLight.excludedMeshes.push(this.leftcolorSensor.lightIndicator.lightMesh); \r\n this.hemiLight.excludedMeshes.push(this.leftcolorSensor.lightIndicator.lightMesh); \r\n const rightIR_callback = (results) => {\r\n const { state, colorR, colorG, colorB, color,IR} = results;\r\n if(this.inputs){\r\n this.inputs.r_surState.innerHTML = state;\r\n this.inputs.r_surR.value = colorR;\r\n this.inputs.r_surG.value = colorG;\r\n this.inputs.r_surB.value = colorB;\r\n this.inputs.right_IR.value = IR;\r\n this.inputs.r_surImg.style.backgroundColor = color;\r\n }\r\n };\r\n\r\n this.rightcolorSensor = new ColorSensorGenerator(\r\n \"RightcolorSensor\",\r\n new BABYLON.Vector3(1.6, 0.2, -0.1),\r\n new BABYLON.Vector3(0, -1, 0),\r\n this.babylonCarBox,\r\n 3,\r\n 50,\r\n false,\r\n rightIR_callback,\r\n this.scene,\r\n \r\n );\r\n this.spotLight.excludedMeshes.push(this.rightcolorSensor.lightIndicator.lightMesh); \r\n this.hemiLight.excludedMeshes.push(this.rightcolorSensor.lightIndicator.lightMesh); \r\n\r\n this.changeCamview = (e) => {\r\n if(e.detail.type.includes(\"robot\")){\r\n this.arcCam.lockedTarget = this.babylonCarBox;\r\n }\r\n else{\r\n this.arcCam.lockedTarget = new BABYLON.Vector3(0,1,0);\r\n }\r\n }\r\n document.addEventListener(\"trackcam_event\",this.changeCamview);\r\n document.addEventListener(\"keydown\",(e)=>{\r\n const key = e.key;\r\n const power =20;\r\n const val=.1;\r\n // console.log(\"!!! key!!! \"+key);\r\n switch(key){\r\n case \"ArrowUp\":\r\n this.applyEnginesPowers(power,power); \r\n SY+=val;\r\n break;\r\n case \"ArrowDown\":\r\n this.applyEnginesPowers(-power,-power); \r\n SY -=val;\r\n break;\r\n case \"ArrowLeft\":\r\n this.applyEnginesPowers(-power,power); \r\n SX-=val;\r\n break;\r\n case \"ArrowRight\":\r\n this.applyEnginesPowers(power,-power); \r\n SX+=val;\r\n break;\r\n case \" \":\r\n this.applyEnginesPowers(0,0); \r\n this.applyBrake();\r\n break; \r\n case \"1\":\r\n SZ+=val;\r\n break;\r\n case \"2\":\r\n SZ-=val;\r\n break;\r\n case \"3\":\r\n // this.grabLeft.updateJointLeft(.2);\r\n // this.grabRight.updateJointRight(-.2);\r\n break;\r\n case \"4\":\r\n // this.grabLeft.updateJointLeft(-.2);\r\n // this.grabRight.updateJointRight(.2);\r\n break;\r\n case \"5\":\r\n // this.pickLeft.updatePickJoint(-.2);\r\n // this.pickRight.updatePickJoint(-.2);\r\n // this.pickcenter.updatePickJoint(-.2);\r\n break ;\r\n case \"6\":\r\n // this.pickLeft.updatePickJoint(.2);\r\n // this.pickRight.updatePickJoint(.2);\r\n // this.pickcenter.updatePickJoint(.2);\r\n break ;\r\n }\r\n // this.jointbodyLeft.angularVelocity = new CANNON.Vec3(0,0,SX);\r\n // this.scene.getMeshByName(\"handbox\").position = new BABYLON.Vector3(SX,SY,SZ);\r\n // console.log(\"!! sx!! \"+SX+\" !!sy!! \"+SY+\"!! sz !! \"+SZ+\" \"); \r\n // const quaternion =this.grabRight.grabJointMesh.rotationQuaternion;\r\n // const euler = quaternion.toEulerAngles();\r\n // console.log(BABYLON.Angle.FromRadians(euler.y).degrees());\r\n })\r\n document.addEventListener(\"keyup\",(e)=>{\r\n const key = e.code;\r\n const power =20;\r\n switch(key){\r\n case \"ArrowUp\":\r\n break;\r\n case \"ArrowDown\":\r\n break;\r\n case \"ArrowLeft\":\r\n this.applyEnginesPowers(0,0); \r\n break;\r\n case \"ArrowRight\":\r\n this.applyEnginesPowers(0,0); \r\n break;\r\n }\r\n // this.grabLeft.updateJointLeft(0);\r\n // this.grabRight.updateJointRight(0);\r\n // this.pickLeft.updatePickJoint(0);\r\n // this.pickRight.updatePickJoint(0);\r\n // this.pickcenter.updatePickJoint(0);\r\n })\r\n }\r\n \r\n trackCamera(_type){\r\n this.cameraEvent = new CustomEvent(\"trackcam_event\",{detail:{type:_type}});\r\n document.dispatchEvent(this.cameraEvent);\r\n }\r\n bodiesAreInContact(bodyA, bodyB){\r\n for(let i=0; i180)\r\n zAngle-=360;\r\n const interVal =setInterval(() => {\r\n const quaternion = this.pickLeft.grabBody.quaternion;\r\n const target = new CANNON.Vec3();\r\n quaternion.toEuler(target);\r\n let zAngle2 = parseInt(BABYLON.Angle.FromRadians(target.z).degrees());\r\n if(zAngle2>180)\r\n zAngle2-=360;\r\n if(Math.abs(zAngle2-zAngle)>=this.pickLeft.jointRotVal){\r\n this.pickLeft.stopJoint();\r\n this.pickRight.stopJoint();\r\n clearInterval(interVal);\r\n }\r\n },1000/frameRate);\r\n }\r\n setGrabjoint(value){\r\n let speed = value>0?MOTORSPEED:-MOTORSPEED;\r\n if(value ===0)\r\n speed=0;\r\n \r\n this.grabLeft.updatePickJoint(speed);\r\n this.grabRight.updatePickJoint(-speed);\r\n this.checkGrabJointMovement();\r\n this.grabLeft.jointRotVal = value;\r\n this.grabRight.jointRotVal = value;\r\n const frameRate = this.scene.getEngine().getFps();\r\n let check = 0;\r\n console.log(\" !!!! \"+check+\" \"+this.grabLeft.jointRotVal);\r\n const interVal =setInterval(() => {\r\n check+=MOTORSPEED;\r\n console.log(\" !!!! \"+check+\" \"+this.grabLeft.jointRotVal);\r\n if(check>= Math.abs(value)){\r\n this.grabLeft.jointRotVal=0;\r\n this.grabLeft.stopJoint();\r\n this.grabRight.jointRotVal=0;\r\n this.grabRight.stopJoint();\r\n clearInterval(interVal);\r\n }\r\n },1000/frameRate);\r\n}\r\ncheckGrabJointMovement(){\r\n const dis = BABYLON.Vector3.Distance(jointLeftMarker.absolutePosition,jointRightMarker.absolutePosition)\r\n if(this.grabLeft.motorVal>0 && dis>1.15){\r\n this.grabLeft.stopJoint();\r\n }\r\n else if(this.grabLeft.motorVal<0 && dis<.4){\r\n this.grabLeft.stopJoint();\r\n }\r\n else if(this.grabRight.motorVal<0 && dis>1.15 ){\r\n this.grabRight.stopJoint();\r\n } \r\n else if(this.grabRight.motorVal>0 && dis<.4 ){\r\n this.grabRight.stopJoint();\r\n } \r\n}\r\ncallloop(){\r\n this.performAcion();\r\n }\r\n async performAcion(){\r\n await sleep(5000);\r\n this.moveFwd();\r\n }\r\n async moveFwd(){\r\n this.applyEnginesPowers(30,30); \r\n await sleep(5000);\r\n this.moveBack();\r\n }\r\n async moveBack(){\r\n this.applyEnginesPowers(-30,-30); \r\n await sleep(5000);\r\n this.moveFwd();\r\n }\r\n \r\n}\r\nfunction sleep (time) {\r\n return new Promise((resolve) => setTimeout(resolve, time));\r\n}\r\nfunction GetAngle(d, e) {\r\n\tif (d == 0)\r\n\t\treturn e >= 0 ? Math.PI / 2 : -Math.PI / 2;\r\n\telse if (d > 0)\r\n\t\treturn Math.atan(e / d);\r\n\telse\r\n\t\treturn Math.atan(e / d) + Math.PI;\r\n\r\n}\r\nexport function getJointDistance(){\r\n const dis = BABYLON.Vector3.Distance(jointLeftMarker.absolutePosition,jointRightMarker.absolutePosition);\r\n return dis;\r\n}","import * as Utils from \"./utils.js\";\r\nexport default class Common{\r\n\r\n constructor(game)\r\n {\r\n\r\n this.game = game;\r\n this.scene = null;\r\n this.arcCam = null; \r\n this.animFrameRate = 60;\r\n \r\n }\r\n createScene(name) {\r\n this.scene = new BABYLON.Scene(this.game.engine);\r\n this.scene.name = name;\r\n // this.scene.imageProcessingConfiguration.exposure = 0.6; //0.6;\r\n // this.scene.imageProcessingConfiguration.contrast = 1.8; //1.6;\r\n // this.scene.imageProcessingConfiguration.toneMappingEnabled = true;\r\n // this.scene.imageProcessingConfiguration.vignetteEnabled = true;\r\n this.scene.clearColor = BABYLON.Color3.FromHexString(Utils.backGroundColor);\r\n \r\n // this.scene.imageProcessingConfiguration.colorCurvesEnabled = true;\r\n // this.scene.imageProcessingConfiguration.colorCurves = new BABYLON.ColorCurves();\r\n // this.scene.imageProcessingConfiguration.colorCurves.globalSaturation = 0;\r\n this.setLight();\r\n return this.scene;\r\n }\r\n createCamera(scene) {\r\n this.arcCam = new BABYLON.ArcRotateCamera(\"ArcCamera\",0,BABYLON.Angle.FromDegrees(45).radians(),18,new BABYLON.Vector3(0, 4, 0),scene);\r\n this.arcCam.maxZ = 1000;\r\n this.arcCam.useBouncingBehavior = false;\r\n this.arcCam.useAutoRotationBehavior = false;\r\n this.arcCam.inputs.clear();\r\n \r\n this.setView();\r\n \r\n return this.arcCam;\r\n }\r\n setLight() {\r\n this.hemiLight = new BABYLON.HemisphericLight(\"HemiLight\",new BABYLON.Vector3(0,20,0),this.scene);\r\n this.hemiLight.intensity = 1;\r\n this.hemiLight.diffuse = new BABYLON.Color3(1, 1, 1);\r\n this.hemiLight.specular = new BABYLON.Color3(1, 1, 1);\r\n this.hemiLight.groundColor = new BABYLON.Color3(1, 1, 1);\r\n\r\n this.spotlight = new BABYLON.SpotLight(\"spotLight\", new BABYLON.Vector3(0,0,1.5), new BABYLON.Vector3(0,0,-1), BABYLON.Angle.FromDegrees(360).radians(),1, this.scene);\r\n this.spotlight.diffuse = new BABYLON.Color3(1, 1, 0);\r\n this.spotlight.intensity = 20;\r\n this.spotlight.range = 2;\r\n \r\n // this.spotlight.renderPriority = 150; \r\n this.spotlight.falloffType = BABYLON.Light.FALLOFF_STANDARD;\r\n \r\n // let dirLight = new BABYLON.DirectionalLight(\"DirectionalLight\",new BABYLON.Vector3(10,10,10),this.scene);\r\n // dirLight.position = new BABYLON.Vector3(3, 9, 3);\r\n // dirLight.intensity=2;\r\n }\r\n\r\n setView(){\r\n this.arcCam.lockedTarget = new BABYLON.Vector3(0,1,0);\r\n this.arcCam.lowerRadiusLimit = 3;\r\n this.arcCam.upperRadiusLimit = 40;\r\n this.arcCam.radius = this.arcCam.lowerRadiusLimit;\r\n this.arcCam.alpha = BABYLON.Angle.FromDegrees(90).radians();\r\n this.arcCam.beta = BABYLON.Angle.FromDegrees(0).radians();\r\n this.arcCam.lowerbetaLimit = BABYLON.Angle.FromDegrees(45).radians();\r\n this.arcCam.upperBetaLimit = BABYLON.Angle.FromDegrees(70).radians();\r\n this.arcCam.inputs.addPointers(); \r\n this.arcCam.inputs.addMouseWheel(); \r\n this.arcCam.wheelPrecision = 15;\r\n this.arcCam.attachControl(this.game.canvas, true); \r\n \r\n let tout = setTimeout(() => {\r\n clearTimeout(tout);\r\n this.zoomCamAnim();\r\n }, 2000);\r\n \r\n } \r\n initCamBetaAnim(){\r\n let animationBox = new BABYLON.Animation(\"betanimation\", \"beta\",this.animFrameRate ,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);\r\n let keys = [];\r\n keys.push({\r\n frame: 0,\r\n value: 0\r\n });\r\n keys.push({\r\n frame: 80,\r\n value: BABYLON.Angle.FromDegrees(60).radians()\r\n });\r\n keys.push({\r\n frame: 120,\r\n value: BABYLON.Angle.FromDegrees(60).radians()\r\n });\r\n animationBox.setKeys(keys);\r\n this.arcCam.animations.push(animationBox);\r\n let tout =setTimeout(async () => {\r\n clearTimeout(tout);\r\n let anim = this.scene.beginAnimation(this.arcCam,0,120,false);\r\n // console.log(\"before\");\r\n await anim.waitAsync();\r\n // console.log(\"after\");\r\n });\r\n }\r\n zoomCamAnim(){\r\n\r\n if(this.arcCam){\r\n let animationBox2 = new BABYLON.Animation(\"radiusanimation\", \"radius\",this.animFrameRate ,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);\r\n let keys2 = [];\r\n keys2.push({\r\n frame: 0,\r\n value:this.arcCam.lowerRadiusLimit,\r\n });\r\n keys2.push({\r\n frame: 120,\r\n value: 40\r\n });\r\n animationBox2.setKeys(keys2);\r\n this.arcCam.animations.push(animationBox2);\r\n let tout =setTimeout(async () => {\r\n clearTimeout(tout);\r\n let anim = this.scene.beginAnimation(this.arcCam,0,120,false);\r\n await anim.waitAsync();\r\n if(this.arcCam){\r\n this.arcCam.animations.splice(keys2,1);\r\n this.initCamBetaAnim();\r\n }\r\n });\r\n }\r\n }\r\n release(){\r\n this.scene.stopAllAnimations();\r\n this.arcCam.dispose();\r\n this.spotlight.dispose();\r\n this.hemiLight.dispose();\r\n }\r\n\r\n \r\n\r\n\r\n}","import * as BABYLON from \"babylonjs\";\r\nimport * as Utils from \"../utils.js\";\r\n\r\n/**\r\n * Generate Flame Effect in the scene\r\n * @param name : String defines fanComponent name\r\n * @param position: Vector3 defines the fanComponent position which be related to the parent (robot car)\r\n * @param direction : Vector3 defines fanComponent direction\r\n * @param parent : Mesh defines fanComponent parent (robot car)\r\n * @param coneLength : number cone length\r\n * @param diameterBottom : number clone diameterBottom\r\n * @param defaultState : boolean define fanComponent State\r\n * @param fanSpeed : number define fan rotation speed\r\n * @param scene : scene active scene\r\n */\r\n\r\nexport default class FanComponentGenerator {\r\n constructor(\r\n name,\r\n position,\r\n direction,\r\n parent,\r\n coneLength,\r\n diameterBottom,\r\n defaultState,\r\n fanSpeed,\r\n scene,\r\n ) {\r\n this.name = name;\r\n this.position = position;\r\n this.direction = direction;\r\n this.parent = parent;\r\n this.coneLength = coneLength;\r\n this.diameterBottom = diameterBottom;\r\n this.defaultState = defaultState;\r\n this.fanSpeed = fanSpeed;\r\n this.scene = scene;\r\n this.isFanOn = false;\r\n\r\n \r\n this.init();\r\n }\r\n\r\n init() {\r\n this.fanHolder = BABYLON.MeshBuilder.CreateBox(\r\n `FC_${this.name}`,\r\n { size: 1 },\r\n this.scene\r\n );\r\n this.fanHolder.visibility = 0.0;\r\n this.fanHolder.isPickable = false;\r\n this.fanHolder.scaling = new BABYLON.Vector3(1, 1, 1);\r\n this.fanHolder.position = this.position;\r\n\r\n // this.clone = BABYLON.MeshBuilder.CreateCylinder(\r\n // `FC_${this.name}`,\r\n // {\r\n // diameterTop: 0.2,\r\n // diameterBottom: this.diameterBottom,\r\n // subdivisions: this.coneLength,\r\n // height: this.coneLength,\r\n // },\r\n // this.scene\r\n // );\r\n // this.clone.rotation.z = 1.57;\r\n // this.clone.parent = this.fanHolder;\r\n // this.clone.position.x = this.coneLength / 2;\r\n // this.clone.visibility = 1.0;\r\n \r\n\r\n BABYLON.SceneLoader.ImportMesh(\"\",\"/models/sensors/\",\"Fan.gltf\",this.scene,\r\n (meshes, particleSystems, skeletons) => {\r\n let rootMesh = null;\r\n let bladesMesh = null;\r\n\r\n for (let i = 0; i < meshes.length; i++) {\r\n meshes[i].isPickable = false;\r\n if (meshes[i].name === \"__root__\") rootMesh = meshes[i];\r\n else if (meshes[i].name === \"Fan.001\") bladesMesh = meshes[i];\r\n }\r\n rootMesh.position = new BABYLON.Vector3(1.1, -1.5, -0);\r\n rootMesh.rotation = new BABYLON.Vector3(0, 1.57, 0);\r\n rootMesh.scaling.multiplyInPlace(new BABYLON.Vector3(20, 20, 20));\r\n rootMesh.parent = this.fanHolder;\r\n // do something with the meshes and skeletons\r\n // particleSystems are always null for glTF assets\r\n\r\n bladesMesh.rotation = new BABYLON.Vector3.Zero();\r\n this.bladesMesh = bladesMesh;\r\n this.initAnimation();\r\n }\r\n );\r\n\r\n this.fanHolder.parent = this.parent;\r\n\r\n // var diffX = pickResult.pickedPoint.x - box.position.x;\r\n // var diffY = pickResult.pickedPoint.z - box.position.z;\r\n // box.rotation.y = Math.atan2(diffX,diffY);\r\n\r\n // let box = BABYLON.MeshBuilder.CreateBox(\r\n // \"www\",\r\n // { size: 0.2 },\r\n // this.scene\r\n // );\r\n\r\n // box.position =this.fanHolder.position.add(this.direction.multiplyByFloats(1,1,1));\r\n\r\n // this.fanHolder.lookAt(box.position)\r\n }\r\n initAnimation() {\r\n var blateAnimation = new BABYLON.Animation(\"blateAnimation\",\"rotation.z\",100,BABYLON.Animation.ANIMATIONTYPE_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);\r\n var keyFrames = [];\r\n keyFrames.push({frame: 0,value: 0,});\r\n keyFrames.push({frame: 100,value: 2 * Math.PI,});\r\n blateAnimation.setKeys(keyFrames);\r\n // this.fanSpeed\r\n this.bladesMesh.animations.push(blateAnimation);\r\n // console.log(\"this.initAnimation\");\r\n }\r\n runFanAnimation(state) {\r\n console.log(\"this.bladesMesh.animations\");\r\n this.isFanOn = state;\r\n if (state) {\r\n this.scene.beginAnimation(this.bladesMesh, 0, 100, true, this.fanSpeed);\r\n } else {\r\n this.scene.stopAnimation(this.bladesMesh);\r\n }\r\n }\r\n}\r\n","export class LightComponent{\r\n\r\n constructor(name,size,color,position,parent,scene,hightlightLayer){\r\n this.scene = scene;\r\n if(name.includes(\"distanceSensor\"))\r\n this.lightMesh = BABYLON.MeshBuilder.CreateSphere(name+\"indicator\",{diameter:size.diameter},this.scene);\r\n else \r\n this.lightMesh = BABYLON.MeshBuilder.CreateBox(name+\"indicator\",{width:size.width,height:size.height,depth:size.depth},this.scene);\r\n this.lightMesh.position = position;\r\n this.enableMat = new BABYLON.StandardMaterial(name+\"indicatormat1\", this.scene);\r\n this.enableMat.emissiveColor = color;\r\n\r\n this.disableMat = new BABYLON.StandardMaterial(name+\"indicatormat2\", this.scene);\r\n this.disableMat.emissiveColor = new BABYLON.Color3.FromInts(225,225,225);\r\n \r\n this.lightMesh.material = this.enableMat;\r\n this.lightMesh.parent = parent;\r\n this.lightMesh.isPickable=false;\r\n\r\n // hightlightLayer.addIncludedOnlyMesh(this.lightMesh);\r\n // hightlightLayer.intensity = .2;\r\n\r\n\r\n\r\n // hightlightLayer.addMesh(this.lightMesh, color);\r\n // hightlightLayer.outerGlow = true;\r\n // hightlightLayer.innerGlow = true;\r\n // hightlightLayer.blurHorizontalSize =.1;\r\n // hightlightLayer.blurVerticalSize =.1;\r\n }\r\n\r\n}","import * as BABYLON from \"babylonjs\";\r\nimport * as BABYLONMaterials from \"babylonjs-materials\";\r\nimport * as Utils from \"../utils.js\";\r\nimport * as units from \"../units.js\";\r\nimport * as CANNON from \"cannon\";\r\n\r\n/**\r\n * Generate Flame Effect in the scene\r\n * @param name : string defines flameEffect name\r\n * @param position: vector2 defines the flameEffect position X AND Z\r\n * @param cylinderSize : {height : number, diameter: number } defines clyinder size\r\n * @param cylinderColor : string defines the flameEffect color\r\n * @param flameWrraperSize : number flame Wrraper Size\r\n * @param flameState : boolean flame state\r\n * @param flameSize : number flame Size\r\n * @param worldManager : worldManager\r\n * @param onFire : (results)=>:void callback function run onFire (Future)\r\n * @param withPlate : boolean -- detect if you want to create it with below plate or not -- defualt is false\r\n * @param plateConfig? : {width:number, depth:number, lineColor:string, color: string, thickness:number} -- plate config object\r\n * @param scene : scene active scene\r\n */\r\n\r\nexport default class FlameEffectGenerator {\r\n constructor(\r\n name,\r\n position,\r\n cylinderSize,\r\n cylinderColor,\r\n flameWrraperSize,\r\n flameState,\r\n flameSize,\r\n worldManager,\r\n scene,\r\n robot,\r\n ) {\r\n this.name = name;\r\n this.position = position;\r\n this.cylinderSize = cylinderSize;\r\n this.cylinderColor = cylinderColor;\r\n this.flameWrraperSize = flameWrraperSize;\r\n this.flameState = flameState;\r\n this.flameSize = flameSize;\r\n this.worldManager = worldManager;\r\n this.scene = scene;\r\n this.flamMesh;\r\n this.cylinderBody;\r\n this.circle,\r\n this.robot = robot;\r\n this.candle;\r\n this.isCollide = false;\r\n this.init();\r\n }\r\n\r\n init() {\r\n if(!this.scene)\r\n return;\r\n this.scene.getNodeByID(\"Circle\").setEnabled(true);\r\n this.circle = this.scene.getNodeByID(\"Circle\").clone(\"newCircle\");\r\n this.circle.position = new BABYLON.Vector3(this.position.x,Utils.groundY+.01,this.position.y);\r\n this.circle.scaling = new BABYLON.Vector3(.5,.5,.5);\r\n\r\n this.scene.getNodeByID(\"Circle\").setEnabled(false);\r\n\r\n const cylinderShape = new CANNON.Cylinder(this.cylinderSize.diameter,this.cylinderSize.diameter,this.cylinderSize.height,20);\r\n // const cylinderShape = new CANNON.Box(new CANNON.Vec3(this.cylinderSize.diameter,this.cylinderSize.height,this.cylinderSize.diameter));\r\n this.cylinderBody = new CANNON.Body({mass:.1,shape: cylinderShape,linearDamping:.2,angularDamping:.2});//7.5\r\n this.cylinderBody.name = `flame_${this.name}`;\r\n this.cylinderBody.angularVelocity = new CANNON.Vec3(0,0,0);\r\n // this.cylinderBody.quaternion.set(0,1,0,0);\r\n // this.cylinderBody.material = this.bodyMat;\r\n // this.cylinderBody.inertia = new CANNON.Vec3(0,0,0);\r\n this.bodyMat = new CANNON.Material(\"ground_obj\");\r\n this.cylinderBody.material = this.bodyMat;\r\n this.cylinderBody.material.restitution=0;\r\n this.cylinderBody.material.friction=.5;\r\n\r\n let cylinderMat = new BABYLON.StandardMaterial(\"cylinderMat\", this.scene);\r\n cylinderMat.diffuseColor = BABYLON.Color3.FromHexString(this.cylinderColor);\r\n this.cylinderHolder = BABYLON.MeshBuilder.CreateCylinder( this.cylinderBody.name,{height:this.cylinderSize.height,diameterTop:this.cylinderSize.diameter,diameterBottom:this.cylinderSize.diameter,subdivisions:20});\r\n // this.cylinderHolder = BABYLON.MeshBuilder.CreateBox( this.cylinderBody.name,{height:this.cylinderSize.height*2,width:this.cylinderSize.diameter*2,depth:this.cylinderSize.diameter*2});\r\n this.cylinderHolder.actionManager = new BABYLON.ActionManager(this.scene);\r\n this.cylinderHolder.isPickable = true;\r\n this.cylinderHolder.position = new BABYLON.Vector3(this.position.x,Utils.groundY+.01,this.position.y);\r\n this.cylinderHolder.material = cylinderMat;\r\n this.cylinderHolder.visibility = 0;\r\n\r\n this.scene.getNodeByID(\"Candle\").setEnabled(true);\r\n this.candle = this.scene.getNodeByID(\"Candle\").clone(\"newCandle\");\r\n this.candle.parent = this.cylinderHolder;\r\n this.candle.name = this.cylinderHolder.name;\r\n this.candle.scaling = new BABYLON.Vector3(this.cylinderSize.diameter*10,this.cylinderSize.height*2,this.cylinderSize.diameter*10);\r\n \r\n const yy = this.cylinderHolder.geometry._extend.maximum.y;\r\n console.log(yy);\r\n this.candle.position = new BABYLON.Vector3(0,this.cylinderHolder.absolutePosition.y-yy,0);\r\n \r\n this.candle.isPickable = false;\r\n this.scene.getNodeByID(\"Candle\").setEnabled(false);\r\n \r\n \r\n // var q = new CANNON.Quaternion();\r\n // q.setFromEuler(Math.PI / 2, 0, 0, \"XYZ\");\r\n // this.cylinderBody.addShape(cylinderShape,new CANNON.Vec3(),q);\r\n const quat = new CANNON.Quaternion();\r\n quat.setFromAxisAngle(new CANNON.Vec3(-1,0,0),-Math.PI/2);\r\n const translation = new CANNON.Vec3(0,0,0);\r\n this.cylinderBody.shapes[0].transformAllPoints(translation,quat);\r\n this.cylinderBody.position.set(this.position.x,Utils.groundY,this.position.y);\r\n this.worldManager.world.add(this.cylinderBody);\r\n this.worldManager.boxes.push({pCube: this.cylinderBody,vCube: this.cylinderHolder,});\r\n\r\n this.cylinderBody.addEventListener(\"collide\", (e)=>{\r\n if(e.body.name === \"robotbody\"){\r\n e.body.velocity = new CANNON.Vec3(Math.round(e.body.velocity.x),Math.round(e.body.velocity.y),Math.round(e.body.velocity.z));\r\n // let val = this.cylinderBody.mass*2;\r\n let val = Math.round(Math.sqrt(e.body.velocity.x * e.body.velocity.x + e.body.velocity.y * e.body.velocity.y+e.body.velocity.z * e.body.velocity.z));\r\n let impulse = new CANNON.Vec3(0,val*.05,0);\r\n if(Math.abs(e.body.velocity.x)>0){\r\n impulse.x = e.body.velocity.x>0?val:-val;\r\n impulse.x *=.05;\r\n }\r\n else{ \r\n let flag = parseInt(getRandomNumber(0,2));\r\n impulse.x = val * (flag===0?(-getRandomNumber(1.1,1.3)):(getRandomNumber(1.1,1.3)));\r\n impulse.x *=.05;\r\n }\r\n\r\n if(Math.abs(e.body.velocity.z)>0){\r\n impulse.z = e.body.velocity.z>0?val:-val;\r\n impulse.z *=.05;\r\n }\r\n else{ \r\n let flag = parseInt(getRandomNumber(0,2));\r\n impulse.z = val * (flag===0?(-getRandomNumber(1.1,1.3)):(getRandomNumber(1.1,1.3)));\r\n impulse.z *=.05;\r\n }\r\n this.cylinderBody.applyImpulse(impulse,this.cylinderBody.position);\r\n this.cylinderBody.angularVelocity = impulse.mult(1,impulse);\r\n this.fireCollisionEvent(this.name);\r\n // console.log(impulse);\r\n }\r\n });\r\n //////\r\n this.flameWrrpaer = BABYLON.MeshBuilder.CreateBox(\"flameWrrpaer\",{ size:this.flameWrraperSize},this.scene);\r\n this.flameWrrpaer.name = this.cylinderHolder.name\r\n this.flameWrrpaer.scaling.y *= 1.5;\r\n this.flameWrrpaer.scaling.z *= 1.25;\r\n this.flameWrrpaer.scaling.x *= 1.25;\r\n this.flameWrrpaer.parent = this.cylinderHolder;\r\n console.log(this.candle.position.y);\r\n this.flameWrrpaer.position.y = this.candle.position.y+yy+this.flameWrrpaer.scaling.y/2//this.cylinderHolder.absolutePosition.y+this.flameWrrpaer.scaling.y/2;\r\n // console.log(this.flameWrrpaer.position.y+\" \"+this.flameWrrpaer.scaling.y);\r\n this.flameWrrpaer.isPickable = true;\r\n this.flameWrrpaer.tag = Utils.EffectsTags.flame;\r\n // this.flameWrrpaer.onDetect = this.onDetect;\r\n this.flameWrrpaer.visibility = 0;\r\n\r\n this.flameWrrpaer.actionManager = new BABYLON.ActionManager(this.scene);\r\n\r\n if(this.scene.getMeshByName(\"pickedGround\")!=null){\r\n this.flameWrrpaer.actionManager.registerAction(\r\n new BABYLON.ExecuteCodeAction({\r\n trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger,\r\n parameter: { mesh:this.scene.getMeshByName(\"pickedGround\"),usePreciseIntersection: true}\r\n },\r\n () => {\r\n this.flameWrrpaer.setEnabled(false);\r\n this.flame.setEnabled(false);\r\n let dis = BABYLON.Vector3.Distance(this.cylinderHolder.position,this.robot.position); \r\n let candleCollideEvent = new CustomEvent(Utils.events.candleDown,{detail:{id:this.name,candleFlame:false,distance:Number(units.getValueByUnitType(dis,units.UnitTypes.mm))}});\r\n document.dispatchEvent(candleCollideEvent);\r\n \r\n // this.flame.stop();\r\n }\r\n )\r\n );\r\n }\r\n\r\n //createFlame\r\n this.flamMesh = BABYLON.MeshBuilder.CreateBox(\"flameMesh\",{size:.5},this.scene);\r\n this.flamMesh.visibility = 0.0;\r\n this.flamMesh.parent = this.cylinderHolder;\r\n this.flamMesh.position.y = this.flameWrrpaer.position.y;\r\n this.flamMesh.isPickable = false;\r\n\r\n this.flame = BABYLON.Mesh.CreatePlane(\"fireplane\",1,this.scene);\r\n this.flame.scaling.x = 0.1;\r\n this.flame.scaling.y = 0.7;\r\n this.flame.position = new BABYLON.Vector3(0,0,0);\r\n this.flame.billboardMode = BABYLON.Mesh.BILLBOARDMODE_Y; \r\n \r\n let fire = new BABYLONMaterials.FireMaterial(\"fire\",this.scene);\r\n fire.diffuseTexture = new BABYLON.Texture(\"/textures/flame/fire.png\", this.scene);\r\n fire.distortionTexture = new BABYLON.Texture(\"/textures/flame/distortion.png\",this.scene);\r\n fire.opacityTexture = new BABYLON.Texture(\"/textures/flame/candleopacity.png\",this.scene);\r\n fire.speed = 5.0;\r\n\r\n this.flame.material = fire;\r\n this.flame.parent = this.flamMesh;\r\n this.flameWrrpaer.flame = this.flame;\r\n\r\n // flameData.default.systems[0].maxLifeTime = this.flameSize;\r\n // this.flame = BABYLON.ParticleSystemSet.Parse(\r\n // flameData.default,\r\n // this.scene,\r\n // false\r\n // ).systems[0];\r\n // if (this.flameState) this.flame.start();\r\n // this.flame.emitter = flamMesh;\r\n\r\n //\r\n \r\n\r\n // setTimeout(() => {\r\n // console.log(\"this \",this)\r\n // this.flameWrrpaer.flame.particleEmitterType.directionRandomizer = 1;\r\n // }, 5000);\r\n }\r\n // checkCollisionRobot()\r\n // {\r\n // this.cylinderHolder.actionManager.registerAction(new BABYLON.ExecuteCodeAction({trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger,\r\n // parameter: {mesh:this.scene.getMeshByName(\"robotcollidebox\"),usePreciseIntersection:true}},() => {\r\n // // this.fireCollisionEvent();\r\n // }\r\n // )\r\n // );\r\n // }\r\n fireCollisionEvent(name){\r\n let dis = BABYLON.Vector3.Distance(this.cylinderHolder.position,this.robot.position); \r\n let candleCollideEvent = new CustomEvent(Utils.events.candleRobotCollision,{detail:{id:name,candleFlame:this.flame.isEnabled()?true:false,distance:Number(units.getValueByUnitType(dis,units.UnitTypes.mm))}});\r\n document.dispatchEvent(candleCollideEvent);\r\n }\r\n removeCandlefromScene(){\r\n\r\n this.scene.removeMesh(this.cylinderHolder);\r\n this.cylinderHolder.dispose();\r\n\r\n this.scene.removeMesh(this.candle);\r\n this.candle.dispose();\r\n \r\n\r\n this.scene.removeMesh(this.flameWrrpaer);\r\n this.flameWrrpaer.dispose();\r\n\r\n\r\n this.scene.removeMesh(this.flamMesh);\r\n this.flamMesh.dispose();\r\n\r\n this.scene.removeMesh(this.circle);\r\n this.circle.dispose();\r\n \r\n \r\n if(this.worldManager && this.worldManager.world)\r\n this.worldManager.world.remove(this.cylinderBody);\r\n\r\n\r\n }\r\n}\r\nexport function getRandomNumber(min, max) {\r\n return Math.random() * (max - min) + min;\r\n}","import * as BABYLON from 'babylonjs';\r\nimport FireFightingScene from './scene/FireFightingScene';\r\nimport MazeScene from './scene/MazeScene';\r\nimport { DemoScene } from './scene/demoscene';\r\nimport SceneManager from './SceneManager';\r\nimport { MyRecorder } from './MyRecorder';\r\nlet divFps;\r\nexport class GameManger {\r\n constructor(canvasId,_sceneno) {\r\n this.canvas = document.getElementById(canvasId);\r\n this.engine= new BABYLON.Engine(this.canvas, true);\r\n this.engine.enableOfflineSupport=true;\r\n this.sceneManager = new SceneManager();\r\n this.sceneManager.setSceneState(_sceneno);\r\n // this.sceneManager.setSceneState(this.sceneManager.sceneState.firefighting);\r\n this.worldManager = null;\r\n this.currentScene = null;\r\n switch(this.sceneManager.currentSceneState){\r\n case this.sceneManager.sceneState.firefighting://firefighting;\r\n this.firefightingScene = new FireFightingScene(this);\r\n this.firefightingScene.scene.freezeMaterials();\r\n this.worldManager = this.firefightingScene.worldManager;\r\n this.currentScene = null;\r\n this.currentScene = this.firefightingScene;\r\n break; \r\n case this.sceneManager.sceneState.maze://maze\r\n this.mazescene = new MazeScene(this);\r\n this.currentScene = null;\r\n this.currentScene = this.mazescene;\r\n this.worldManager = this.mazescene.worldManager;\r\n break; \r\n case this.sceneManager.sceneState.demo:\r\n console.log(\"!!demo!\");\r\n this.demoScene = new DemoScene(this);\r\n this.currentScene = null;\r\n this.currentScene = this.demoScene;\r\n this.worldManager = this.demoScene.worldManager;\r\n\r\n break; \r\n }\r\n divFps = document.getElementById(\"fps\");\r\n window.addEventListener(\"resize\", ()=> {\r\n this.resizeBabylonEngine();\r\n },false);\r\n window[\"resizeBabylonEngine\"] = this.resizeBabylonEngine.bind(this);\r\n window[\"startFireFightingScene\"] = this.startFireFightingScene.bind(this);\r\n window[\"restartMazeScene\"] = this.restartMazeScene.bind(this);\r\n window[\"startRenderLoop\"] = this.startRenderLoop.bind(this);\r\n window[\"stopRenderLoop\"] = this.stopRenderLoop.bind(this);\r\n window[\"showFPS\"] = this.showFPS.bind(this);\r\n window[\"getLoadingFinish\"] = this.getLoadingFinish.bind(this);\r\n \r\n this.startRenderLoop();\r\n this.myRecorder = new MyRecorder(this.engine,{fps:24,mimeType:\"video/webm\"});\r\n }\r\n resizeBabylonEngine(){\r\n if(this.engine)\r\n this.engine.resize();\r\n }\r\n startFireFightingScene(){\r\n if(this.firefightingScene && this.firefightingScene.scene){\r\n this.firefightingScene.scene.onDisposeObservable.add(()=>{\r\n console.log(\"onDisposeObservable\");\r\n this.firefightingScene.scene = undefined;\r\n this.firefightingScene.scene = null;\r\n this.firefightingScene = null;\r\n console.log(\"!! remove scene!!!\");\r\n this.sceneManager.setSceneState(this.sceneManager.sceneState.firefighting);\r\n this.firefightingScene = new FireFightingScene(this);\r\n this.worldManager = this.firefightingScene.worldManager;\r\n this.startRenderLoop(); \r\n \r\n });\r\n this.engine.stopRenderLoop();\r\n this.firefightingScene.releaseScene();\r\n this.firefightingScene.scene.dispose();\r\n console.log(\"!!!releaseScene!!!!\");\r\n }\r\n else{\r\n this.sceneManager.setSceneState(this.sceneManager.sceneState.firefighting);\r\n this.worldManager = null;\r\n this.firefightingScene = new FireFightingScene(this);\r\n this.firefightingScene.scene.freezeMaterials();\r\n this.worldManager = this.firefightingScene.worldManager;\r\n }\r\n }\r\n restartMazeScene(){\r\n if(this.mazescene && this.mazescene.scene){\r\n this.mazescene.scene.onDisposeObservable.add(()=>{\r\n console.log(\"onDisposeObservable\");\r\n this.mazescene.scene = undefined;\r\n this.mazescene.scene = null;\r\n this.mazescene = null;\r\n console.log(\"!! remove scene!!!\");\r\n this.sceneManager.setSceneState(this.sceneManager.sceneState.maze);\r\n this.mazescene = new MazeScene(this);\r\n this.worldManager = this.mazescene.worldManager;\r\n this.startRenderLoop(); \r\n });\r\n this.engine.stopRenderLoop();\r\n this.mazescene.releaseScene();\r\n this.mazescene.scene.dispose();\r\n }\r\n else{\r\n this.worldManager = null;\r\n this.sceneManager.setSceneState(this.sceneManager.sceneState.maze);\r\n this.mazescene = new MazeScene(this);\r\n this.worldManager = this.mazescene.worldManager;\r\n }\r\n }\r\n startRenderLoop(){\r\n if(this.currentScene && this.currentScene.scene){\r\n this.currentScene.scene.registerBeforeRender(()=>{\r\n if(this.worldManager !== null){\r\n if(this.currentScene.loaderManager.carManager)\r\n this.currentScene.loaderManager.carManager.updatewheel();\r\n for(let i = 0; i < this.worldManager.boxes.length; i++){\r\n this.worldManager.boxes[i].vCube.position = new BABYLON.Vector3(this.worldManager.boxes[i].pCube.position.x,\r\n this.worldManager.boxes[i].pCube.position.y,this.worldManager.boxes[i].pCube.position.z);\r\n this.worldManager.boxes[i].vCube.rotationQuaternion = new BABYLON.Quaternion(this.worldManager.boxes[i].pCube.quaternion.x,\r\n this.worldManager.boxes[i].pCube.quaternion.y,this.worldManager.boxes[i].pCube.quaternion.z,this.worldManager.boxes[i].pCube.quaternion.w);\r\n }\r\n this.worldManager.updateWorld(this.engine.getFps());\r\n }\r\n })\r\n }\r\n this.engine.runRenderLoop( ()=> {\r\n // switch(this.sceneManager.currentSceneState){\r\n // case this.sceneManager.sceneState.firefighting:\r\n // if( this.firefightingScene && this.firefightingScene.scene && this.firefightingScene.loaderManager.loaded)\r\n // this.firefightingScene.scene.render();\r\n // break;\r\n // case this.sceneManager.sceneState.demo:\r\n // if(this.demoScene && this.demoScene.scene && this.demoScene.loaderManager.loaded)\r\n // this.demoScene.scene.render();\r\n // break;\r\n // case this.sceneManager.sceneState.maze: \r\n // if(this.mazescene.loaderManager.loaded)\r\n // this.mazescene.scene.render();\r\n // break;\r\n // }\r\n if(this.currentScene){\r\n if(this.currentScene.scene && this.currentScene.loaderManager.loaded)\r\n this.currentScene.scene.render();\r\n }\r\n divFps.innerHTML = this.engine.getFps().toFixed() + \" fps\";\r\n });\r\n }\r\n stopRenderLoop(){\r\n this.engine.stopRenderLoop();\r\n }\r\n showFPS(){\r\n return this.engine.getFps().toFixed();\r\n }\r\n releaseWorld(){\r\n if(this.worldManager){\r\n this.worldManager.boxes=[];\r\n for(let i=0;i void\r\n// @scene ---- active scene\r\nlet resultObj = {};\r\nexport default class ColorSensorGenerator {\r\n constructor(\r\n name,\r\n position,\r\n direction,\r\n parent,\r\n rayLength,\r\n samplingRateMs,\r\n isVisibleRay,\r\n onFire,\r\n scene,\r\n \r\n ) {\r\n this.name = name;\r\n this.position = position;\r\n this.direction = direction;\r\n this.parent = parent;\r\n this.rayLength = rayLength;\r\n this.samplingRateMs = samplingRateMs;\r\n this.isVisibleRay = isVisibleRay;\r\n this.onFire = onFire;\r\n this.scene = scene;\r\n\r\n this.textureimage = new Image();\r\n this.mycanvas = document.createElement('canvas');\r\n this.context2d = this.mycanvas.getContext('2d');\r\n // this.filereader = new FileReader();\r\n\r\n this.materialId = undefined;\r\n \r\n this.imageData = null;\r\n this.sensorValue={};\r\n \r\n \r\n this.lightIndicator = new LightComponent(name,{width:.05,height:.07,depth:.12},new BABYLON.Color3(1,0,0),\r\n new BABYLON.Vector3(position.x+.08,position.y+.14,position.z+.07),this.parent,this.scene);\r\n \r\n this.lightIndicator.lightMesh.rotation.y = BABYLON.Angle.FromDegrees(90).radians();\r\n\r\n this.data=[];\r\n\r\n // this.getImageData = (imageURL) => new Promise((resolve, reject) => {\r\n \r\n // let img = new Image();\r\n // img.onload = () => {\r\n // // Create the canvas of the correct dimensions\r\n // let context2D = this.createCanvasContext2D(img.naturalWidth,img.naturalHeight);\r\n // // Draw the image to it.\r\n // context2D.drawImage(img, 0, 0);\r\n // // Resolve the image data\r\n // let imageData = context2D.getImageData(0,0,img.naturalWidth,img.naturalHeight);\r\n // resolve(imageData);\r\n // };\r\n // img.onerror = () => reject(\"getImageData: \" + imageURL + \" could not be loaded!\");\r\n // img.src = imageURL;\r\n // });\r\n // this.getImageData(\"/textures/Ground/Sand_003_COLOR.jpg\").then((imageData) => {\r\n // this.imageData = imageData;\r\n // // console.log(this.imageData);\r\n // });\r\n this.init();\r\n this.scene.registerBeforeRender(()=> {\r\n this.callRayCasting();\r\n });\r\n }\r\n\r\n init() {\r\n this.sensorBox = BABYLON.MeshBuilder.CreateBox(`s_${this.name}`,{ size: 1 },this.scene);\r\n this.sensorBox.visibility = 0.0;\r\n this.sensorBox.isPickable = false;\r\n this.sensorBox.scaling = new BABYLON.Vector3(0.5, 0.5, 0.5);\r\n this.sensorBox.position = this.position;\r\n BABYLON.SceneLoader.ImportMesh(\"\",\"/models/sensors/\",\"IRSensor02.gltf\",this.scene,(meshes, particleSystems, skeletons) => {\r\n let rootMesh = null;\r\n for (let i = 0; i < meshes.length; i++) {\r\n meshes[i].isPickable = false;\r\n if (meshes[i].name === \"__root__\") rootMesh = meshes[i];\r\n }\r\n rootMesh.parent = this.sensorBox;\r\n rootMesh.position.x -= 0.5;\r\n rootMesh.rotation = new BABYLON.Vector3(0, 1.57, 4.71);\r\n rootMesh.scaling.multiplyInPlace(new BABYLON.Vector3(2, 2, 2));\r\n // do something with the meshes and skeletons\r\n // particleSystems are always null for glTF assets\r\n }\r\n );\r\n //assign DistanceRay\r\n let origin = this.sensorBox.getAbsolutePosition();\r\n let forward = this.direction;\r\n forward = this.vecToLocal(forward, this.sensorBox);\r\n let direction = forward.subtract(origin);\r\n direction = BABYLON.Vector3.Normalize(direction);\r\n this.ray = new BABYLON.Ray(origin, direction, this.rayLength);\r\n this.rayLength = 0;\r\n this.rayHelper = BABYLON.RayHelper.CreateAndShow(this.ray,this.scene, new BABYLON.Color3(0,1,1))//new BABYLON.RayHelper(this.ray);\t\t\r\n // this.rayHelper = new BABYLON.RayHelper(this.ray);\r\n // this.rayHelper.show(this.scene);\r\n this.sensorBox.parent = this.parent;\r\n \r\n\r\n }\r\n vecToLocal(vector, mesh) {\r\n var m = mesh.getWorldMatrix();\r\n var v = BABYLON.Vector3.TransformCoordinates(vector, m);\r\n return v;\r\n }\r\n callRayCasting() {\r\n if(this.rayHelper !== null) \r\n {\r\n if(this.isVisibleRay) {\r\n this.rayHelper.hide(); \r\n this.rayHelper.show(this.scene);\r\n }\r\n else\r\n this.rayHelper.hide(); \r\n }\r\n let surfaceHit = this.scene.pickWithRay(this.ray);\r\n \r\n try {\r\n if(surfaceHit.pickedMesh){\r\n if(surfaceHit.pickedMesh.material !== null){\r\n if(surfaceHit.pickedMesh.material.getActiveTextures().length>0){\r\n \r\n // console.log(surfaceHit.pickedMesh.material.albedoTexture._texture._buffer);\r\n let uv = surfaceHit.getTextureCoordinates();\r\n // console.log(uv);\r\n if(surfaceHit.pickedMesh.material.name !== this.materialId){\r\n \r\n this.materialId = surfaceHit.pickedMesh.material.name;\r\n let index = this.getDataIndex(this.materialId);\r\n // console.log(index);\r\n if(index === -1)\r\n this.readTexturePixel(surfaceHit,uv);\r\n else{\r\n this.imageData = this.getDataAtIndex(index);\r\n // console.log(this.imageData);\r\n } \r\n }\r\n else{\r\n this.setTexturepixel(uv);\r\n // console.log(\"in else read pixel\");\r\n } \r\n }\r\n else{\r\n // console.log(surfaceHit.pickedMesh.material); \r\n // if(surfaceHit.pickedMesh.material.diffuseColor !== undefined)\r\n // {\r\n // this.materialId = surfaceHit.pickedMesh.material.name;\r\n // let pixel = surfaceHit.pickedMesh.material.diffuseColor.clone();\r\n // pixel.r *= 255;\r\n // pixel.g *= 255;\r\n // pixel.b *= 255;\r\n // resultObj.colorR = pixel.r;\r\n // resultObj.colorG = pixel.g;\r\n // resultObj.colorB = pixel.b;\r\n // resultObj.color = this.rgbToHex(pixel.r, pixel.g, pixel.b);\r\n // console.log(\" !! diffuse Color!!! \" +resultObj.color+\" \"+surfaceHit.pickedMesh.name);\r\n // this.onFire(resultObj);\r\n // }\r\n // else\r\n if(surfaceHit.pickedMesh.material.albedoColor !== undefined)\r\n {\r\n \r\n this.materialId = surfaceHit.pickedMesh.material.name;\r\n // console.log(surfaceHit.pickedMesh.material.albedoColor);\r\n let pixel = surfaceHit.pickedMesh.material.albedoColor.clone();\r\n pixel.r *= 255;\r\n pixel.g *= 255;\r\n pixel.b *= 255;\r\n resultObj.colorR = parseInt(pixel.r);\r\n resultObj.colorG = parseInt(pixel.g);\r\n resultObj.colorB = parseInt(pixel.b);\r\n resultObj.color = this.rgbToHex(resultObj.colorR, resultObj.colorG,resultObj.colorB);\r\n this.sensorValue.state = resultObj.state = `Activated (${++this.rayLength})`;\r\n this.convertRGBtoIR(resultObj.colorR,resultObj.colorG,resultObj.colorB);\r\n resultObj.IR = Number(this.sensorValue.IR);\r\n // console.log(\" !! albedoColor Color!!! \" +resultObj.color+\" \"+surfaceHit.pickedMesh.name);\r\n this.onFire(resultObj);\r\n }\r\n \r\n }\r\n }\r\n }\r\n } catch (error) {}\r\n \r\n // if (surfaceHit.pickedPoint) {\r\n // resultObj.state = `Activated (${++this.rayLength})`;\r\n // // this.uiInputs.state.innerHTML = `Activated (${++this.rayLength})`;\r\n // let pixel = new BABYLON.Color3(211, 190, 171);\r\n // if(surfaceHit.pickedMesh.tag === \"ground\") {\r\n // let uv = surfaceHit.getTextureCoordinates();\r\n // pixel = this.getImageDataPixelAtUV(this.imageData, uv.x, uv.y);\r\n // } else{\r\n // if(surfaceHit.pickedMesh.material && surfaceHit.pickedMesh.material.diffuseColor){\r\n // pixel = surfaceHit.pickedMesh.material.diffuseColor.clone();\r\n // pixel.r *= 255;\r\n // pixel.g *= 255;\r\n // pixel.b *= 255;\r\n // }\r\n // }\r\n // resultObj.colorR = pixel.r;\r\n // resultObj.colorG = pixel.g;\r\n // resultObj.colorB = pixel.b;\r\n // resultObj.color = this.rgbToHex(pixel.r, pixel.g, pixel.b);\r\n // this.onFire(resultObj);\r\n \r\n // // this.uiInputs.colorR.value = pixel.r;\r\n // // this.uiInputs.colorG.value = pixel.g;\r\n // // this.uiInputs.colorB.value = pixel.b;\r\n // // this.uiInputs.color.style.backgroundColor = this.rgbToHex(\r\n // // pixel.r,\r\n // // pixel.g,\r\n // // pixel.b\r\n // // );\r\n // }\r\n // this.callRayCasting();\r\n // }, this.samplingRateMs);\r\n }\r\n // createCanvasContext2D(width, height) {\r\n // let canvas = document.createElement(\"canvas\");\r\n // canvas.width = width;\r\n // canvas.height = height;\r\n // return canvas.getContext(\"2d\");\r\n // }\r\n // getImageDataPixelAtUV(imageData, u, v) {\r\n // console.log(\"!! x!!! \"+\" \"+imageData.width+\" \"+imageData.height );\r\n // if (u < 0 || u > 1) {\r\n // console.log(\"U is out of bounds! Must be in range [0,1]! u = \" + u);\r\n // } else if (v < 0 || v > 1) {\r\n // console.log(\"V is out of bounds! Must be in range [0,1]! v = \" + v);\r\n // } else {\r\n \r\n // let x = Math.max(Math.round(u * (imageData.width - 1)), 0);\r\n // let y = Math.max(Math.round((1 - v) * (imageData.height - 1)), 0); // using \"1-v\" to switch to XY coordinates with origin in upper left.\r\n // console.log(\"!! x!!! \"+x+\" !! y!!! \"+y+\" \"+imageData.width+\" \"+imageData.height );\r\n // return this.getImageDataPixelAtIndex(imageData, y * imageData.width + x);\r\n // }\r\n // }\r\n getImageDataPixel(imageData, uv) {\r\n // console.log(\"!! x!!! \"+\" \"+imageData.width+\" \"+imageData.height);\r\n try {\r\n let tx = Math.min(this.emod(uv.x, 1) * imageData.width | 0, imageData.width - 1);\r\n let ty = Math.min(this.emod(uv.y, 1) * imageData.height | 0, imageData.height - 1);\r\n // console.log(\"!! 2222x!!! \"+\" \"+tx+\" \"+ty);\r\n return this.getImageDataPixelAtIndex(imageData, ty * imageData.width + tx);\r\n } catch (error) {}\r\n }\r\n \r\n emod(n, m) {\r\n return ((n % m) + m) % m;\r\n }\r\n getImageDataPixelAtIndex(imageData, index) {\r\n let i = index * 4;\r\n let d = imageData.data;\r\n return {\r\n r: d[i],\r\n g: d[i + 1],\r\n b: d[i + 2],\r\n a: d[i + 3],\r\n };\r\n }\r\n rgbToHex(r, g, b) {\r\n return (\r\n \"#\" +this.componentToHex(r) +this.componentToHex(g) +this.componentToHex(b)\r\n );\r\n }\r\n componentToHex(c) {\r\n var hex = c.toString(16);\r\n return hex.length == 1 ? \"0\" + hex : hex;\r\n }\r\n blobToBase64(blob) {\r\n return new Promise((resolve, _) => {\r\n const reader = new FileReader();\r\n reader.onloadend = () => resolve(reader.result);\r\n reader.readAsDataURL(blob);\r\n \r\n });\r\n }\r\n readTexturePixel(surfaceHit,uv)\r\n {\r\n try {\r\n // console.log(surfaceHit.pickedMesh.material.albedoTexture._texture);\r\n // const reader = new FileReader();\r\n if(surfaceHit.pickedMesh.material.albedoTexture !== undefined)\r\n {\r\n // this.filereader.readAsDataURL(surfaceHit.pickedMesh.material.albedoTexture._texture._buffer); \r\n // this.filereader.onloadend = ()=> {\r\n // // result includes identifier 'data:image/png;base64,' plus the base64 data\r\n // mySrc = this.filereader.result; \r\n // // var image = new Image();\r\n // this.textureimage.onload = ()=> {\r\n // // var canvas = document.createElement('canvas');\r\n // this.mycanvas.width = this.textureimage.width;\r\n // this.mycanvas.height = this.textureimage.height;\r\n // this.context2d.drawImage(this.textureimage, 0, 0);\r\n // this.imageData = this.context2d.getImageData(0, 0, this.mycanvas.width, this.mycanvas.height);\r\n // this.setTexturepixel(uv);\r\n // };\r\n // this.textureimage.src = mySrc;\r\n // }\r\n // console.log(surfaceHit.pickedMesh.material.albedoTexture._texture.url);\r\n let mySrc = surfaceHit.pickedMesh.material.albedoTexture._texture.url; //URL.createObjectURL(surfaceHit.pickedMesh.material.diffuseTexture._texture.url);\r\n this.textureimage.onload = ()=> {\r\n // console.log(this.textureimage.width+\" \"+this.textureimage.height)\r\n this.mycanvas.width = this.textureimage.width;\r\n this.mycanvas.height = this.textureimage.height;\r\n this.context2d.drawImage(this.textureimage, 0, 0);\r\n this.imageData = this.context2d.getImageData(0, 0, this.mycanvas.width, this.mycanvas.height);\r\n this.setTexturepixel(uv);\r\n // URL.revokeObjectURL(mySrc);\r\n // this.textureimage = null;\r\n this.data.push({id:this.materialId,data:this.imageData})\r\n };\r\n this.textureimage.src = mySrc;\r\n \r\n }\r\n } catch (error) {\r\n console.log(error);\r\n }\r\n }\r\n setTexturepixel(uv)\r\n {\r\n try{\r\n if(this.imageData !== null)\r\n {\r\n let pixel = this.getImageDataPixel(this.imageData, uv);\r\n // let index = (uv.y*imageData.width + uv.x) * 4;\r\n // let red = imageData.data[index];\r\n // let green = imageData.data[index + 1];\r\n // var blue = imageData.data[index + 2];\r\n // // let alpha = imageData.data[index + 3];\r\n resultObj.colorR = pixel.r;\r\n resultObj.colorG = pixel.g;\r\n resultObj.colorB = pixel.b;\r\n resultObj.color = this.rgbToHex(pixel.r, pixel.g, pixel.b);\r\n this.sensorValue.state = resultObj.state = `Activated (${++this.rayLength})`;\r\n this.convertRGBtoIR(resultObj.colorR,resultObj.colorG,resultObj.colorB);\r\n resultObj.IR = Number(this.sensorValue.IR);\r\n this.onFire(resultObj);\r\n }\r\n } catch (error) {}\r\n }\r\n getDataIndex(id)\r\n {\r\n for(let i=0;i void\r\n// @scene ---- active scene\r\n\r\nexport default class DistanceSensorGenerator {\r\n constructor(\r\n name,\r\n position,\r\n direction,\r\n parent,\r\n rayLength,\r\n samplingRateMs,\r\n isVisibleRay,\r\n onFire,\r\n scene,\r\n ) {\r\n this.name = name;\r\n this.position = position;\r\n this.direction = direction;\r\n this.parent = parent;\r\n this.rayLength = rayLength;\r\n this.samplingRateMs = samplingRateMs;\r\n this.isVisibleRay = isVisibleRay;\r\n this.onFire = onFire;\r\n this.scene = scene;\r\n this.sensorValue={};\r\n \r\n this.lightIndicator = new LightComponent(name,{diameter:.08},new BABYLON.Color3(1,0,0),\r\n new BABYLON.Vector3(position.x-.22,position.y,position.z-.02),this.parent,this.scene);\r\n this.init();\r\n }\r\n\r\n init() {\r\n this.sensorBox = BABYLON.MeshBuilder.CreateBox( `DS_${this.name}`,{ size: 1 },this.scene);\r\n this.sensorBox.visibility = 0.0;\r\n this.sensorBox.isPickable = false;\r\n this.sensorBox.scaling = new BABYLON.Vector3(0.5, 0.5, 0.5);\r\n this.sensorBox.position = this.position;\r\n BABYLON.SceneLoader.ImportMesh(\"\",\"/models/sensors/\",\"Ultrasonic_1.gltf\",this.scene,(meshes, particleSystems, skeletons) => {\r\n let rootMesh = null;\r\n for (let i = 0; i < meshes.length; i++) {\r\n meshes[i].isPickable = false;\r\n if (meshes[i].name === \"__root__\") \r\n rootMesh = meshes[i];\r\n }\r\n rootMesh.parent = this.sensorBox;\r\n rootMesh.position.x -= 0.5;\r\n rootMesh.rotation = new BABYLON.Vector3(0, 1.57, 4.71);\r\n rootMesh.scaling.multiplyInPlace(new BABYLON.Vector3(2, 2, 2));\r\n }\r\n );\r\n this.rayCount = 0;\r\n this.sensorBox.parent = this.parent;\r\n this.scene.registerBeforeRender(()=> {\r\n this.callRayCasting();\r\n });\r\n \r\n }\r\n vecToLocal(vector, mesh) {\r\n var m = mesh.getWorldMatrix();\r\n var v = BABYLON.Vector3.TransformCoordinates(vector, m);\r\n return v;\r\n }\r\n callRayCasting() {\r\n \r\n let origin = this.sensorBox.getAbsolutePosition();\r\n let forward = this.direction;\r\n forward = this.vecToLocal(forward, this.sensorBox);\r\n let direction = forward.subtract(origin);\r\n direction = BABYLON.Vector3.Normalize(direction);\r\n if(this.rayHelper!== undefined && this.isVisibleRay)\r\n this.rayHelper.hide();\r\n\r\n this.ray = new BABYLON.Ray(origin, direction, this.rayLength);\r\n let distanceHit = this.scene.pickWithRay(this.ray);\r\n resultObj.state = `Activated (${++this.rayCount})`;\r\n \r\n if(this.isVisibleRay)\r\n this.rayHelper = BABYLON.RayHelper.CreateAndShow(this.ray,this.scene, new BABYLON.Color3(1,1,0))//new BABYLON.RayHelper(this.ray);\t\t\r\n else\r\n {\r\n if(this.rayHelper !== undefined)\r\n this.rayHelper.hide();\r\n }\r\n if (distanceHit.pickedMesh) {\r\n this.sensorValue.name = resultObj.name = distanceHit.pickedMesh.name;\r\n this.sensorValue.distance = resultObj.direction = Number(units.getValueByUnitType(distanceHit.distance,units.UnitTypes.mm));\r\n this.sensorValue.state = resultObj.state;\r\n \r\n // if (distanceHit.pickedMesh.material)\r\n // distanceHit.pickedMesh.material.diffuseColor = BABYLON.Color3.Red();\r\n }\r\n else\r\n resultObj.direction = Infinity;\r\n this.onFire(resultObj); \r\n console.log(this.sensorValue);\r\n }\r\n}\r\nlet resultObj = {\r\n name : undefined,\r\n state: `Activated (${0})`,\r\n direction:0,\r\n};\r\n","import * as BABYLON from \"babylonjs\";\r\nimport * as units from \"../units.js\";\r\nimport { LightComponent } from \"../Components/LightComponent.js\";\r\n\r\n// @name ---- string\r\n// @position ---- vector3\r\n// @direction ---- vector3\r\n// @parent ---- Mesh\r\n// @rayLength ---- number\r\n// @samplingRateMs ---- number\r\n// @isVisibleRay ---- boolean\r\n// @onFire --- (result:{})=> void\r\n// @scene ---- active scene\r\n\r\nexport default class DistanceSensorGenerator2 {\r\n constructor(\r\n name,\r\n position,\r\n direction,\r\n parent,\r\n rayLength,\r\n samplingRateMs,\r\n isVisibleRay,\r\n onFire,\r\n scene,\r\n ) {\r\n this.name = name;\r\n this.position = position;\r\n this.direction = direction;\r\n this.noRays = 3;\r\n this.parent = parent;\r\n this.rayLength = rayLength;\r\n this.samplingRateMs = samplingRateMs;\r\n this.isVisibleRay = isVisibleRay;\r\n this.onFire = onFire;\r\n this.scene = scene;\r\n this.sensorValue={};\r\n \r\n this.lightIndicator = new LightComponent(name,{diameter:.08},new BABYLON.Color3(1,0,0),\r\n new BABYLON.Vector3(position.x-.22,position.y,position.z-.02),this.parent,this.scene);\r\n const dir = [-.02,0,.02];\r\n this.raydir=[];\r\n this.rayHelper=[];\r\n this.ray=[];\r\n this.sensordata = {data:[]};\r\n\r\n for(let i=0;i {\r\n let rootMesh = null;\r\n for (let i = 0; i < meshes.length; i++) {\r\n meshes[i].isPickable = false;\r\n if (meshes[i].name === \"__root__\") \r\n rootMesh = meshes[i];\r\n }\r\n rootMesh.parent = this.sensorBox;\r\n rootMesh.position.x -= 0.5;\r\n rootMesh.rotation = new BABYLON.Vector3(0,1.57,4.71);\r\n rootMesh.scaling.multiplyInPlace(new BABYLON.Vector3(2, 2, 2));\r\n }\r\n );\r\n this.rayCount = 0;\r\n this.sensorBox.parent = this.parent;\r\n this.scene.registerBeforeRender(()=> {\r\n this.callRayCasting();\r\n });\r\n \r\n }\r\n vecToLocal(vector, mesh) {\r\n var m = mesh.getWorldMatrix();\r\n var v = BABYLON.Vector3.TransformCoordinates(vector, m);\r\n return v;\r\n }\r\n callRayCasting() {\r\n\r\n // for(let i=0;i\r\n a.distance - b.distance\r\n );\r\n this.sensorValue.name = resultObj.name = this.sensordata.data[0].name;\r\n this.sensorValue.distance = resultObj.direction = this.sensordata.data[0].distance;\r\n this.sensorValue.state = resultObj.state;\r\n // console.log(this.sensordata.data);\r\n }\r\n}\r\n\r\nlet resultObj = {\r\n name : undefined,\r\n state: `Activated (${0})`,\r\n direction:0,\r\n};\r\n","import * as Utils from '../utils.js';\r\nimport * as units from \"../units.js\";\r\nexport default class FanSensor{\r\n\r\n constructor(name,position,direction,parent,rayLength,scene,candle,isvisible,root)\r\n {\r\n this.name = name;\r\n this.position = position;\r\n this.direction = direction;\r\n this.parent = parent;\r\n this.rayLength = rayLength;\r\n this.scene = scene;\r\n this.rayHelper = null;\r\n this.ray=null;\r\n this.candle=candle;\r\n this.rayvisible = isvisible;\r\n this.initSensor();\r\n this.root = root;\r\n scene.registerBeforeRender(()=> {\r\n\r\n let fanvalue = false;\r\n if(this.rayHelper !== null && this.rayvisible)\r\n this.rayHelper.hide(); \r\n if(this.root && this.root.fanComponent){\r\n fanvalue = this.root.fanComponent.isFanOn;\r\n // console.log(this.root.fanComponent.isFanOn+\" \"+fanvalue);\r\n if(fanvalue) \r\n this.castRay();\r\n }\r\n else\r\n fanvalue = false;\r\n // if(document.getElementById(\"fanAnim\") !== null)\r\n // fanvalue = document.getElementById(\"fanAnim\").checked;\r\n });\r\n }\r\n\r\n setCandleForSensor(candle)\r\n {\r\n this.candle = candle;\r\n }\r\n vecToLocal(vector, mesh){\r\n var m = mesh.getWorldMatrix();\r\n var v = BABYLON.Vector3.TransformCoordinates(vector, m);\r\n\t\treturn v;\t\t \r\n }\r\n initSensor()\r\n {\r\n this.sensorBox = BABYLON.MeshBuilder.CreateBox(`DS_${this.name}`,{ size: 1 },this.scene);\r\n this.sensorBox.isPickable = false;\r\n this.sensorBox.visibility = 0;\r\n this.sensorBox.scaling = new BABYLON.Vector3(0.5, 0.5, 0.5);\r\n this.sensorBox.position = this.position;\r\n this.sensorBox.parent = this.parent;\r\n }\r\n castRay(){ \r\n let origin = this.sensorBox.getAbsolutePosition();\r\n\t let forward = this.direction// new BABYLON.Vector3(1,0,0);\t\t\r\n\t forward = this.vecToLocal(forward, this.sensorBox);\r\n\t let direction = forward.subtract(origin);\r\n\t direction = BABYLON.Vector3.Normalize(direction);\r\n\t this.ray = new BABYLON.Ray(origin, direction, this.rayLength);\r\n if(this.rayvisible)\r\n this.rayHelper = BABYLON.RayHelper.CreateAndShow(this.ray,this.scene, new BABYLON.Color3(1,.5,1))//new BABYLON.RayHelper(this.ray);\t\t\r\n else\r\n { \r\n if(this.rayHelper !== null) \r\n this.rayHelper.hide(); \r\n }\r\n let hit = this.scene.pickWithRay(this.ray,this.predicate);\r\n if(hit.pickedMesh && this.root.fanComponent.isFanOn){\r\n \r\n if(hit.pickedMesh.name.includes(\"candle\") || hit.pickedMesh.tag === Utils.EffectsTags.flame)\r\n {\r\n for(let i=0;i void\r\n// @scene ---- active scene\r\n\r\nexport default class FlameSensorGenerator {\r\n constructor(\r\n name,\r\n position,\r\n direction,\r\n parent,\r\n rayLength,\r\n samplingRateMs,\r\n isVisibleRay,\r\n onFire,\r\n scene,\r\n ) {\r\n this.name = name;\r\n this.position = position;\r\n this.direction = direction;\r\n this.parent = parent;\r\n this.rayLength = rayLength;\r\n this.samplingRateMs = samplingRateMs;\r\n this.isVisibleRay = isVisibleRay;\r\n this.onFire = onFire;\r\n this.scene = scene;\r\n this.init();\r\n this.sensorValue={};\r\n \r\n this.lightIndicator = new LightComponent(name,{width:.05,height:.07,depth:.12},new BABYLON.Color3(1,0,0),\r\n new BABYLON.Vector3(position.x+.02,position.y+.12,position.z-.06),this.parent,this.scene);\r\n this.lightIndicator.lightMesh.rotation.y = BABYLON.Angle.FromDegrees(90).radians();\r\n \r\n }\r\n\r\n init() {\r\n this.sensorBox = BABYLON.MeshBuilder.CreateBox(`FS_${this.name}`,{ size: 1 },this.scene);\r\n this.sensorBox.visibility = 0.0;\r\n this.sensorBox.isPickable = false;\r\n this.sensorBox.scaling = new BABYLON.Vector3(0.5, 0.5, 0.5);\r\n this.sensorBox.position = this.position;\r\n\r\n BABYLON.SceneLoader.ImportMesh(\"\",\"/models/sensors/\",\"FlameSensor.gltf\",this.scene,(meshes, particleSystems, skeletons) => {\r\n let rootMesh = null;\r\n for (let i = 0; i < meshes.length; i++) {\r\n meshes[i].isPickable = false;\r\n if (meshes[i].name === \"__root__\") \r\n rootMesh = meshes[i];\r\n }\r\n rootMesh.parent = this.sensorBox;\r\n rootMesh.position = new BABYLON.Vector3(-0.5, 0, -.15);\r\n rootMesh.rotation = new BABYLON.Vector3(0, 1.57, 4.71);\r\n rootMesh.scaling.multiplyInPlace(new BABYLON.Vector3( 2, -2, 2));\r\n }\r\n );\r\n this.rayCount = 0;\r\n this.sensorBox.parent = this.parent;\r\n this.scene.registerBeforeRender(()=> {\r\n this.callRayCasting();\r\n });\r\n }\r\n vecToLocal(vector, mesh) {\r\n var m = mesh.getWorldMatrix();\r\n var v = BABYLON.Vector3.TransformCoordinates(vector, m);\r\n return v;\r\n }\r\n callRayCasting() {\r\n let origin = this.sensorBox.getAbsolutePosition();\r\n let forward = this.direction;\r\n forward = this.vecToLocal(forward, this.sensorBox);\r\n let direction = forward.subtract(origin);\r\n direction = BABYLON.Vector3.Normalize(direction);\r\n\r\n if(this.isVisibleRay && this.rayHelper!== undefined)\r\n this.rayHelper.hide();\r\n this.ray = new BABYLON.Ray(origin, direction, this.rayLength);\r\n if(this.isVisibleRay)\r\n this.rayHelper = BABYLON.RayHelper.CreateAndShow(this.ray,this.scene, new BABYLON.Color3(0,0,1))//new BABYLON.RayHelper(this.ray);\t\t\r\n else{\r\n if(this.rayHelper !== undefined)\r\n this.rayHelper.hide();\r\n }\r\n let distanceHit = this.scene.pickWithRay(this.ray);\r\n let sensorPower = 0;\r\n let resultObj = {\r\n value:`Activated (${++this.rayCount})`,\r\n power: sensorPower,\r\n picked: false,\r\n name:\"\",\r\n direction:0,\r\n state:\"NA\"\r\n };\r\n this.sensorValue.power = resultObj.power; \r\n this.sensorValue.name = resultObj.name ; \r\n this.sensorValue.distance = resultObj.direction;\r\n this.sensorValue.state = resultObj.state;\r\n this.sensorValue.value = resultObj.value;\r\n\r\n if (distanceHit.pickedMesh && distanceHit.pickedMesh.tag === Utils.EffectsTags.flame) {\r\n // console.log(\"rayLength\", this.rayLength)\r\n sensorPower = ((this.rayLength - distanceHit.distance)/this.rayLength) * 100;\r\n this.sensorValue.power = resultObj.power = sensorPower >= 95 ? 100 : Math.round(sensorPower);\r\n this.sensorValue.name = resultObj.name = distanceHit.pickedMesh.name;\r\n this.sensorValue.distance = resultObj.direction = distanceHit.distance.toFixed(2);\r\n this.sensorValue.state = resultObj.state = distanceHit.pickedMesh.flame.isEnabled();\r\n resultObj.picked = true;\r\n if (distanceHit.pickedMesh.material)\r\n distanceHit.pickedMesh.material.diffuseColor = BABYLON.Color3.Red();\r\n // console.log(\"distanceHit.distance -->\", distanceHit.distance+\" !!! name!!! \"+resultObj.name);\r\n // console.log(\"!!!IJJJJJJJJJJ Flame!!!\");\r\n }\r\n this.onFire(resultObj);\r\n // this.callRayCasting();\r\n // }, this.samplingRateMs);\r\n }\r\n}\r\n","// https://schteppe.github.io/cannon.js/\r\n// I am having fever & facing back pain because slip on the bike. i was supposed to be will be fine on Monday but unfortunately i am not able to start work.\r\n// that is my situation \r\n// dr suggested me to take rest \r\nimport * as BABYLON from \"babylonjs\";\r\nimport * as CANNON from \"cannon\";\r\nimport { getJointDistance } from \"../CarManager\";\r\nconst minAngularDamping=.2;\r\nconst maxAngularDamping=.999;\r\nexport const MOTORSPEED =.2;\r\nexport default class Myjoints{\r\n constructor(_name,root,size,position,_mass,color){\r\n this.root = root;\r\n this.name = _name\r\n this.angleVal=0;\r\n this.connectedBody;\r\n this.grabJointMesh = BABYLON.MeshBuilder.CreateBox(\"handbox\",{ width:size.x,height:size.y,size:size.z},root.scene); \r\n this.grabJointMesh.position = new BABYLON.Vector3(position.x,position.y,position.z);\r\n const mat = new BABYLON.StandardMaterial(\"joint_mat\");\r\n mat.diffuseColor = new BABYLON.Color3.FromInts(color.r,color.g,color.b);\r\n this.grabJointMesh.material = mat;\r\n const shape = new CANNON.Box(new CANNON.Vec3(size.x*.5,size.y*.5,size.z*.5));\r\n this.grabBody = new CANNON.Body({ mass:_mass});\r\n this.grabBody.addShape(shape);\r\n this.grabBody.position = new CANNON.Vec3(this.grabJointMesh.position.x,this.grabJointMesh.position.y,this.grabJointMesh.position.z);\r\n this.grabBody.velocity.set(0,0,0);\r\n this.grabBody.angularVelocity.set(0,0,0);\r\n this.grabBody.linearDamping = maxAngularDamping;\r\n this.grabBody.angularDamping = maxAngularDamping;\r\n this.contactMat = new CANNON.Material(\"jointbody_mat\");\r\n this.contactMat.restitution=0;\r\n this.contactMat.friction=.5;\r\n this.grabBody.material = this.contactMat;\r\n this.root.worldManager.boxes.push({pCube:this.grabBody,vCube:this.grabJointMesh});\r\n this.grabBody.name = this.name;\r\n this.motorVal=0;\r\n this.jointRotVal=0;\r\n }\r\n createJoint(connectedBody,pivotA,axisA,pivotB,axisB,force,robot_rotation){\r\n this.connectedBody =connectedBody;\r\n this.grabJoint = new CANNON.HingeConstraint(connectedBody,this.grabBody,{\r\n pivotA:pivotA,\r\n axisA: axisA,\r\n pivotB:pivotB,\r\n axisB: axisB,\r\n maxForce:force,\r\n });\r\n this.grabJoint.collideConnected=false;\r\n this.grabJoint.enableMotor();\r\n this.grabJoint.setMotorSpeed(0);\r\n this.grabJoint.motorMaxForce = force;\r\n this.grabJoint.motorMinForce = force;\r\n // console.log(this.grabJoint.motorMaxForce+\" \"+this.grabJoint.motorMinForce)\r\n this.grabJoint.update();\r\n const quatX = new CANNON.Quaternion();\r\n // if(this.name.includes(\"left\"))\r\n // quatX.setFromAxisAngle(new CANNON.Vec3(1,0,0),Math.PI/2);\r\n // else \r\n // quatX.setFromAxisAngle(new CANNON.Vec3(-1,0,0),Math.PI/2);\r\n const quatY = new CANNON.Quaternion();\r\n quatY.setFromAxisAngle(new CANNON.Vec3(0,1,0), BABYLON.Angle.FromDegrees(robot_rotation).radians());\r\n const quaternion = quatY.mult(quatX);\r\n quaternion.normalize();\r\n this.grabBody.quaternion = quaternion;\r\n this.root.worldManager.world.add(this.grabBody);\r\n this.root.worldManager.world.addConstraint(this.grabJoint);\r\n this.jointRotVal=0;\r\n this.motorVal=0;\r\n }\r\n updateJointLeft(motor){\r\n this.motorVal = motor;\r\n if(motor ===0){\r\n this.grabJoint.setMotorSpeed(0); \r\n this.grabBody.angularDamping=.9999;\r\n }\r\n else{\r\n const dis = getJointDistance();\r\n if(motor <0 && dis<.4){ //this.angleVal<=-20\r\n motor =0;\r\n this.motorVal = motor;\r\n this.grabBody.angularDamping=maxAngularDamping;\r\n }\r\n else if( motor >0 && dis>1.14){\r\n motor =0;\r\n this.motorVal = motor;\r\n this.grabBody.angularDamping=maxAngularDamping;\r\n }\r\n else{ \r\n this.angleVal +=motor;\r\n this.grabJoint.update();\r\n this.grabBody.angularDamping=minAngularDamping;\r\n }\r\n this.grabJoint.setMotorSpeed(motor); \r\n }\r\n }\r\n updateJointRight(motor){\r\n this.motorVal = motor;\r\n if(motor===0){\r\n this.grabJoint.setMotorSpeed(motor); \r\n this.grabBody.angularDamping=.9999;\r\n }\r\n else{\r\n const dis = getJointDistance();\r\n if(motor <0 && dis>1.14){\r\n motor=0;\r\n this.motorVal = motor;\r\n this.grabBody.angularDamping=maxAngularDamping;\r\n }\r\n else if(motor >0 && dis<.4){\r\n motor=0;\r\n this.motorVal = motor;\r\n this.grabBody.angularDamping=maxAngularDamping;\r\n }\r\n else{ \r\n this.angleVal +=motor;\r\n this.grabBody.angularDamping=minAngularDamping;\r\n this.grabJoint.update();\r\n }\r\n this.grabJoint.setMotorSpeed(motor); \r\n }\r\n }\r\n stopJoint(){\r\n this.motorVal = 0;\r\n this.grabBody.angularDamping=.9999;\r\n this.grabJoint.setMotorSpeed(0); \r\n this.grabJoint.update();\r\n }\r\n updatePickJoint(motor){\r\n this.motorVal = motor;\r\n if(motor===0){\r\n this.grabJoint.setMotorSpeed(0); \r\n this.grabBody.angularDamping=.9999;\r\n }\r\n else{\r\n const quaternion1 = this.grabBody.quaternion;\r\n const target = new CANNON.Vec3();\r\n quaternion1.toEuler(target);\r\n let zAngle = parseInt(BABYLON.Angle.FromRadians(target.z).degrees());\r\n if(zAngle>180)\r\n zAngle-=360;\r\n if(motor<0 && zAngle>=50){\r\n motor =0;\r\n this.motorVal = motor;\r\n this.grabJoint.setMotorSpeed(0); \r\n this.grabBody.angularDamping=maxAngularDamping;\r\n }\r\n else if(motor>0 && zAngle<=-15 ){\r\n motor =0;\r\n this.motorVal = motor;\r\n this.grabJoint.setMotorSpeed(0); \r\n this.grabBody.angularDamping=maxAngularDamping;\r\n }\r\n else{\r\n this.grabJoint.setMotorSpeed(motor); \r\n this.grabJoint.update(); \r\n this.grabBody.angularDamping=minAngularDamping;\r\n }\r\n } \r\n }\r\n \r\n}\r\n","import * as BABYLON from \"babylonjs\";\r\nimport * as Utils from \"../utils.js\";\r\nimport * as CANNON from \"cannon\";\r\nimport {getRandomNumber} from \"../Effects/FlameEffectGenerator.js\";\r\n\r\n/**\r\n * Generate Flame Effect in the scene\r\n * @param name : string defines Obstacle name\r\n * @param position: vector2 defines the flameEffect position X AND Z\r\n * @param width: number defines Obstacle width\r\n * @param obstacleAngle: number defines Y axis angle in radians\r\n * @param obstacleSrc : string defines image path\r\n * @param worldManager : worldManager\r\n * @param scene : scene active scene\r\n */\r\n\r\nexport default class ObstacleGenerator {\r\n constructor(\r\n name,\r\n position,\r\n // width,\r\n size,\r\n obstacleAngle,\r\n obstacleSrc,\r\n worldManager,\r\n scene,\r\n boardEvent,\r\n bodyMat,\r\n ) {\r\n this.name = name;\r\n this.position = position;\r\n // this.width = width;\r\n this.size = size; \r\n this.obstacleAngle = obstacleAngle;\r\n this.obstacleSrc = obstacleSrc;\r\n this.worldManager = worldManager;\r\n this.scene = scene;\r\n this.boardEvent = boardEvent;\r\n this.adPlane =null;\r\n this.woodPart;\r\n this.cubeBody;\r\n this.bodyMat = bodyMat;\r\n this.isCollide = false;\r\n // console.log(\"INNNNNNNNNN\");\r\n this.init();\r\n \r\n }\r\n\r\n init() {\r\n // let height = this.width*1.6;\r\n // let depth = this.width*.7;\r\n // let woodHeight = this.width*.5;\r\n // let adHeight = height - woodHeight;\r\n // console.log(this.size);\r\n // Step 1 -- Create Physics Cube\r\n let cubeSize = new BABYLON.Vector3(this.size.width, this.size.height,this.size.depth);\r\n let cubeShape = new CANNON.Box(new CANNON.Vec3(cubeSize.x, cubeSize.y, cubeSize.z));\r\n this.cubeBody = new CANNON.Body({ mass:10, shape: cubeShape }); // Step 2 -- Build the body\r\n // this.cubeBody.material = this.bodyMat;\r\n this.cubeBody.linearDamping=.2;\r\n this.cubeBody.angularDamping=.2;\r\n this.cubeBody.angularVelocity.set(0,0,0);//.2\r\n this.cubeBody.addShape(cubeShape);\r\n this.cubeBody.position.set(this.position.x, cubeSize.y, this.position.y);\r\n this.cubeBody.quaternion.setFromEuler(0, this.obstacleAngle, 0, \"XYZ\");\r\n this.worldManager.world.add(this.cubeBody);\r\n this.cubeBody.addEventListener(\"collide\", (e)=>{\r\n if(e.body.name === \"robotbody\"){\r\n // let impulse = new CANNON.Vec3(getRandomNumber(this.cubeBody.mass*1.5,this.cubeBody.mass*1.8),this.cubeBody.mass*1.8,getRandomNumber(this.cubeBody.mass*1.5,this.cubeBody.mass*1.8));\r\n e.body.velocity = new CANNON.Vec3(Math.round(e.body.velocity.x),Math.round(e.body.velocity.y),Math.round(e.body.velocity.z));\r\n // let val = this.cubeBody.mass\r\n let val = Math.round(Math.sqrt(e.body.velocity.x * e.body.velocity.x + e.body.velocity.y * e.body.velocity.y+e.body.velocity.z * e.body.velocity.z));\r\n let impulse = new CANNON.Vec3(0,val*2,0);\r\n if(Math.abs(e.body.velocity.x)>0)\r\n impulse.x = e.body.velocity.x>0?val:-val;\r\n else{ \r\n let flag = parseInt(getRandomNumber(0,2));\r\n impulse.x = val * (flag===0?(-getRandomNumber(1.1,1.3)):(getRandomNumber(1.1,1.3)));\r\n }\r\n\r\n if(Math.abs(e.body.velocity.z)>0)\r\n impulse.z = e.body.velocity.z>0?val:-val;\r\n else{ \r\n let flag = parseInt(getRandomNumber(0,2));\r\n impulse.z = val * (flag===0?(-getRandomNumber(1.1,1.3)):(getRandomNumber(1.1,1.3)));\r\n }\r\n this.cubeBody.applyImpulse(impulse,this.cubeBody.position);\r\n this.cubeBody.angularVelocity = impulse.mult(.3,impulse);\r\n this.fireCollisionEvent();\r\n }\r\n if(e.body.name === \"physicground\"){\r\n if(Math.abs(this.cubeBody.quaternion.x!==0) || Math.abs(this.cubeBody.quaternion.z!==0)){\r\n let boardCollideEvent = new CustomEvent(Utils.events.boardDown,{detail:{name:this.name}});\r\n document.dispatchEvent(boardCollideEvent);\r\n }\r\n }\r\n });\r\n // Step 2 -- Create Virtual Cube\r\n\r\n const meshSize = { width:this.size.width*2, height:this.size.height*2, depth: this.size.depth*2.2};\r\n this.vCube = BABYLON.MeshBuilder.CreateBox(this.name,{ width:meshSize.width, height:meshSize.height, depth: meshSize.depth},this.scene);\r\n \r\n this.vCube.position = this.cubeBody.position;//new BABYLON.Vector3.Zero();\r\n let boxMat = new BABYLON.StandardMaterial(\"boxMat\", this.scene);\r\n this.vCube.material = boxMat;\r\n this.vCube.visibility = 0;\r\n this.worldManager.boxes.push({pCube: this.cubeBody,vCube: this.vCube});\r\n \r\n // //create wood cube\r\n this.woodPart = BABYLON.MeshBuilder.CreateBox(`${this.name}_wood`,{ width:meshSize.width, height:meshSize.height*.2, depth: meshSize.depth},this.scene);\r\n this.woodPart.parent = this.vCube;\r\n this.woodPart.position = new BABYLON.Vector3(0,-meshSize.height*.5,0);\r\n //create woodPart material\r\n let plateBoxMat = new BABYLON.StandardMaterial(`${this.name}woodMat`,this.scene);\r\n plateBoxMat.diffuseTexture = new BABYLON.Texture(\"/textures/wood.jpg\",this.scene); \r\n plateBoxMat.emissiveColor = new BABYLON.Color3.White();\r\n // //assgin material\r\n this.woodPart.material = plateBoxMat;\r\n\r\n\r\n // //create adPlane\r\n this.adPlane = BABYLON.MeshBuilder.CreatePlane(`${this.name}_AD`,{ width:meshSize.width, height:meshSize.height*.8,depth: meshSize.depth,sideOrientation: BABYLON.Mesh.DOUBLESIDE},this.scene);\r\n this.adPlane.parent = this.vCube;\r\n let adPlaneMat = new BABYLON.StandardMaterial(`${this.name}adPlaneMat`,this.scene);\r\n adPlaneMat.diffuseTexture = new BABYLON.Texture(this.obstacleSrc,this.scene); \r\n adPlaneMat.emissiveColor = new BABYLON.Color3.White();\r\n adPlaneMat.backFaceCulling=true;\r\n this.adPlane.material = adPlaneMat;\r\n\r\n\r\n \r\n this.vCube.actionManager = new BABYLON.ActionManager(this.scene);\r\n // let tout = setTimeout(() => {\r\n // this.vCube.actionManager.registerAction(new BABYLON.ExecuteCodeAction(\r\n // {\r\n // trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger,\r\n // parameter: {mesh:this.scene.getMeshByName(\"pickedGround\"),usePreciseIntersection:true}\r\n // },\r\n // () => {\r\n \r\n // // if( this.robotInterFace !== null && this.robotInterFace.boardEvent !== null)\r\n // // document.dispatchEvent(this.robotInterFace.boardEvent);\r\n \r\n // }\r\n // )\r\n // );\r\n // clearTimeout(tout);\r\n // }, 5000);\r\n }\r\n \r\n // checkCollisionRobot()\r\n // {\r\n // this.vCube.actionManager.registerAction(new BABYLON.ExecuteCodeAction({trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger,\r\n // parameter: {mesh:this.scene.getMeshByName(\"robotcollidebox\"),usePreciseIntersection:true}},() => {\r\n // // this.fireCollisionEvent();\r\n // }\r\n // ));\r\n \r\n // }\r\n fireCollisionEvent(){\r\n // let boardrobotEvent = new Event(Utils.events.boardRobotCollision);\r\n let boardrobotEvent = new CustomEvent(Utils.events.boardRobotCollision,{detail:{name:this.name}});\r\n document.dispatchEvent(boardrobotEvent);\r\n }\r\n removeBoardFromScene()\r\n {\r\n this.scene.removeMesh(this.adPlane);\r\n this.adPlane.dispose();\r\n\r\n this.scene.removeMesh(this.woodPart);\r\n this.woodPart.dispose();\r\n\r\n this.scene.removeMesh(this.vCube);\r\n this.vCube.dispose();\r\n\r\n if(this.worldManager && this.worldManager.world)\r\n this.worldManager.world.remove(this.cubeBody);\r\n }\r\n}\r\n","import * as BABYLON from \"babylonjs\";\r\nimport \"babylonjs-loaders\";\r\n\r\nimport CarManager from \"./CarManager.js\";\r\nimport * as Utils from \"./utils.js\";\r\n\r\nexport default class LoaderManager {\r\n constructor(parentScene) {\r\n this.parentScene = parentScene;\r\n this.game = parentScene.game;\r\n this.scene = parentScene.scene;\r\n this.world = parentScene.worldManager.world;\r\n\r\n this.assetsManager = new BABYLON.AssetsManager(this.scene);\r\n this.assetsManager.useDefaultLoadingScreen = true;\r\n this.inputs = parentScene.Inputs;\r\n this.fanComponent;\r\n }\r\n async loadRobot(){\r\n return new Promise(resolve => {\r\n const robotTask = this.assetsManager.addMeshTask(\"Robot_Task\",\"\",\"/models/robot2/\",\"Car_wheel.gltf\");\r\n robotTask.onSuccess = (task) => {\r\n console.log(\" Robot loaded !!! \");\r\n this.carManager = new CarManager(this.parentScene, {x: parseInt(0),y: parseInt(1),z: parseInt(0),},this.parentScene.sceneCommon.spotlight);\r\n document.getElementById(\"fanAnim\").addEventListener(\"change\", (e) => {\r\n this.carManager.fanComponent.runFanAnimation(e.target.checked);\r\n });\r\n resolve('robot load');\r\n };\r\n });\r\n }\r\n async load3dScene(){\r\n return new Promise(resolve =>{\r\n const parentScenetask = this.assetsManager.addMeshTask(\"firefightingtask\",\"\",\"/models/scene/\",\"scene.glb\");\r\n parentScenetask.onSuccess = (task) => {\r\n console.log(\" parentScene loaded !!! \");\r\n const carpet = this.scene.getNodeByID(\"Carpet\");\r\n carpet.position.y = Utils.groundY;\r\n for(let i=0;i{\r\n this.parentScene.generateTile();\r\n })\r\n // this.load3dScene().then(()=>{\r\n let sizeV3 = new BABYLON.Vector3(Utils.groundWidth,Utils.border.height,Utils.border.depth); // Border Size\r\n let leftBorder = this.parentScene.worldManager.createGroundTile(\"Left\",new BABYLON.Vector3(0,Utils.border.height / 2,-(Utils.groundDepth / 2) + -Utils.border.depth / 2),sizeV3,1);\r\n sizeV3 = new BABYLON.Vector3(Utils.groundWidth,Utils.border.height,Utils.border.depth); // Border Size\r\n let rightBorder = this.parentScene.worldManager.createGroundTile(\"Right\",new BABYLON.Vector3(0,Utils.border.height / 2,Utils.groundDepth / 2 + Utils.border.depth / 2),sizeV3,1);\r\n sizeV3 = new BABYLON.Vector3(Utils.border.depth,Utils.border.height,Utils.groundDepth); // Border Size\r\n let forwardBorder = this.parentScene.worldManager.createGroundTile(\"Forward\",new BABYLON.Vector3(Utils.groundWidth / 2 + Utils.border.depth / 2,Utils.border.height / 2,0),sizeV3,1);\r\n sizeV3 = new BABYLON.Vector3(Utils.border.depth,Utils.border.height,Utils.groundDepth); // Border Size\r\n let backBorder = this.parentScene.worldManager.createGroundTile(\"BackWard\",new BABYLON.Vector3(-Utils.groundWidth / 2 + Utils.border.depth / 2,Utils.border.height / 2,0),sizeV3,1);\r\n // });\r\n }\r\n break;\r\n }\r\n // console.log(\"meshes\", meshes)\r\n this.assetsManager.onProgress = (\r\n remainingCount,\r\n totalCount,\r\n lastFinishedTask\r\n ) => {\r\n this.game.engine.loadingUIText = \"We are loading the scene. \" +remainingCount +\" out of \" +totalCount +\" items still need to be loaded.\";};\r\n\r\n this.assetsManager.onFinish = (tasks) => {\r\n //On ALL Done\r\n this.loaded = true;\r\n console.log(\"!!! assetsManager finish!!!\");\r\n switch(this.game.sceneManager.currentSceneState)\r\n {\r\n case this.game.sceneManager.sceneState.firefighting:\r\n this.parentScene.initCandle(this.scene); \r\n break;\r\n case this.game.sceneManager.sceneState.linefollowing:\r\n break;\r\n }\r\n if(document.getElementById(\"loader_spiner\"))\r\n document.getElementById(\"loader_spiner\").style.display = \"none\";\r\n \r\n };\r\n // Start loading\r\n this.assetsManager.load();\r\n }\r\n}","\r\n\r\nexport const MazeMap = {\r\n data:\r\n [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],\r\n [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],\r\n [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],\r\n [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],\r\n ]\r\n\r\n}\r\n\r\n\r\nexport const MazeMap2 = {\r\n data: [\r\n [{ id: 0, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": true, \"n\": true, \"s\": false, start: false, end: false },\r\n { id: 1, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": true, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 2, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": true, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 3, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": true, \"n\": false, \"s\": true, start: false, end: false },\r\n { id: 4, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": true, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 5, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": true, \"n\": false, \"s\": true, start: false, end: false },\r\n { id: 6, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": true, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 7, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": true, \"n\": false, \"s\": true, start: false, end: false }],\r\n [{ id: 8, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": true, \"s\": true, start: false, end: false },\r\n { id: 9, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": true, \"n\": true, \"s\": true, start: false, end: false },\r\n { id: 10, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 11, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 12, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 13, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 14, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": true, \"n\": false, \"s\": true, start: false, end: false },\r\n { id: 15, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": true, start: false, end: false }],\r\n [{ id: 16, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": true, \"s\": true, start: false, end: false },\r\n { id: 17, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": true, \"s\": true, start: false, end: false },\r\n { id: 18, ismilestone: true, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 19, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": true, start: false, end: false },\r\n { id: 20, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 21, ismilestone: true, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": true, \"s\": false, start: false, end: false },\r\n { id: 22, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 23, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": true, start: false, end: false }],\r\n [{ id: 24, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": true, \"s\": true, start: false, end: false },\r\n { id: 25, ismilestone: true, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 26, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": true, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 27, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 28, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 29, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 30, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": true, start: false, end: false },\r\n { id: 31, ismilestone: false, color: \"#C5C5C5\", \"e\": false, \"w\": false, \"n\": false, \"s\": true, start: false, end: false }],\r\n [{ id: 32, ismilestone: false, color: \"#00ff00\", \"e\": true, \"w\": false, \"n\": true, \"s\": true, start: true, end: false },\r\n { id: 33, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 34, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 35, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 36, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 37, ismilestone: true, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": false, start: false, end: false },\r\n { id: 38, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": true, start: false, end: false },\r\n { id: 39, ismilestone: false, color: \"#C5C5C5\", \"e\": true, \"w\": false, \"n\": false, \"s\": true, start: false, end: true }],\r\n ]\r\n}","\r\n\r\nexport class MyRecorder{\r\n\r\n constructor(engine,config)\r\n {\r\n // this.startTime = Date.now();\r\n // this.record={\r\n // data:[]\r\n // };\r\n this.recorder = null;\r\n this.maxTime = 3*60;\r\n this.engine = engine;\r\n this.config = config;\r\n window[\"startRecording\"] = this.startRecording.bind(this);\r\n window[\"stopRecording\"] = this.stopRecording.bind(this);\r\n window[\"setFrameRate\"] = this.setFrameRate.bind(this);\r\n \r\n // window[\"streamScreen\"] = this.streamScreen.bind(this);\r\n // this.canvas = document.querySelector('canvas');\r\n // this.stream = this.canvas.captureStream();\r\n // setTimeout(() => {\r\n // this.streamScreen();\r\n // }, 2000);\r\n }\r\n // trackScene(robot,time)\r\n // {\r\n\r\n // let recordTime = (time-this.startTime)/1000;\r\n // this.record.data.push(\r\n // {\r\n // \"leftEnginePower\" : robot.leftEnginePower,\r\n // \"rightEnginePower\": robot.rightEnginePower,\r\n // \"recordtime\" : recordTime,\r\n // }\r\n // )\r\n // console.log(this.record);\r\n // }\r\n setFrameRate(fps)\r\n {\r\n this.config.fps = fps;\r\n }\r\n startRecording(fps,isBuffer,isDownload)\r\n {\r\n \r\n \r\n if(fps !== undefined)\r\n {\r\n if(fps>30)\r\n fps=30;\r\n if(fps<0)\r\n fps=20;\r\n this.config.fps = fps;\r\n }\r\n\r\n console.log(this.config.fps);\r\n if(!isBuffer)\r\n isDownload = false;\r\n \r\n let name = isDownload? (+ new Date())+\".webm\" :null;\r\n \r\n if(isBuffer)\r\n {\r\n console.log(name);\r\n if (BABYLON.VideoRecorder.IsSupported(this.engine)) {\r\n if(this.recorder === null)\r\n {\r\n this.recorder = new BABYLON.VideoRecorder(this.engine,this.config);\r\n console.log(this.config);\r\n }\r\n // window.startOptimiser();\r\n }\r\n if(this.recorder !== null)\r\n {\r\n this.recorder.startRecording(name,this.maxTime).then((videoBlob) => { \r\n console.log(videoBlob);\r\n insertVideoInDB(videoBlob);\r\n URL.revokeObjectURL(videoBlob);\r\n this.recorder.dispose();\r\n this.recorder = null;\r\n // console.log(this.recorder);\r\n });\r\n }\r\n }\r\n }\r\n stopRecording()\r\n {\r\n if(this.recorder !== null)\r\n {\r\n this.recorder.stopRecording();\r\n }\r\n }\r\n // streamScreen()\r\n // {\r\n // document.getElementById('myvideo').style.display =\"block\";\r\n // document.getElementById('myvideo').srcObject = this.stream;\r\n // document.getElementById('myvideo').play();\r\n // }\r\n // showVideo(videoSrc)\r\n // {\r\n // // let videoSrc = localStorage.getItem(\"scenevideo\");\r\n // videoSrc = window.URL.createObjectURL(videoSrc);\r\n // document.getElementById('myvideo').style.display =\"block\";\r\n // document.getElementById('myvideo').srcObject = videoSrc;\r\n // document.getElementById('myvideo').play();\r\n // document.getElementById('myvideo').addEventListener('ended', (event) => {\r\n // document.getElementById('myvideo').style.display =\"none\";\r\n // }); \r\n // }\r\n}\r\n\r\n\r\n// async function convertBlobToBase64 (blob){ \r\n// return await blobToBase64(blob);\r\n// }\r\n \r\n// const blobToBase64 = blob => new Promise((resolve, reject) => {\r\n// const reader = new FileReader();\r\n// reader.readAsDataURL(blob);\r\n// reader.onload = () => {\r\n// resolve(reader.result);\r\n// };\r\n// reader.onerror = error => {\r\n// reject(error);\r\n// console.log(\"error\");\r\n// };\r\n// });","import { events} from \"./utils\";\r\nexport const NONE = 0;\r\nexport const BOARD_DISTANCE = 2;\r\nexport const candlePositionConfig = {\r\n \"positionmap\":[\r\n // Practice Tracks\r\n [ \r\n [{\"x\":9,\"z\":4.5 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":4.5,\"z\":-6.75,\"boardno\":1,\"direction\":{\"left\":1,\"right\":NONE,\"up\":1,\"down\":NONE}}],\r\n [ {robotposition:{x:4,y:0,z:8,angle:270}}]\r\n ],\r\n [ \r\n [{\"x\":11.25,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":-6.75,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":1}}],\r\n [{robotposition:{x:-4,y:0,z:8,angle:90}}]\r\n ],\r\n [ \r\n [{\"x\":-9,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":0,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":1,\"up\":NONE,\"down\":NONE}}],\r\n [{robotposition:{x:4,y:0,z:-8,angle:135}}]\r\n ],\r\n [ \r\n [{\"x\":-11.25,\"z\":-6.75 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":11.25,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":1,\"up\":1,\"down\":NONE}}],\r\n [{robotposition:{x:-4,y:0,z:-8,angle:65}}]\r\n ],\r\n\r\n // Competition Tracks index 4 through 10\r\n [\r\n [{\"x\":-9,\"z\":4.5 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":9,\"z\":-2.25 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":1,\"down\":NONE}},\r\n {\"x\":4.5,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":1,\"up\":1,\"down\":NONE}},\r\n {\"x\":-11.25,\"z\":-6.75 ,\"boardno\":1,\"direction\":{\"left\":1,\"right\":NONE,\"up\":1,\"down\":1}}],\r\n [{robotposition:{x:0,y:0,z:0,angle:40}}]\r\n ],\r\n [ \r\n [{\"x\":-9,\"z\":4.5 ,\"boardno\":0,\"direction\":{\"left\":1,\"right\":1,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":9,\"z\":-2.25 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":4.5,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":1,\"up\":1,\"down\":1}},\r\n {\"x\":-11.25,\"z\":-6.75 ,\"boardno\":1,\"direction\":{\"left\":1,\"right\":NONE,\"up\":NONE,\"down\":NONE}}],\r\n [{robotposition:{x:0,y:0,z:0,angle:0}}]\r\n ],\r\n [ \r\n [{\"x\":-9,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":9,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":1,\"down\":NONE}},\r\n {\"x\":0,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":1,\"up\":1,\"down\":NONE}},\r\n {\"x\":0,\"z\":-6.75 ,\"boardno\":1,\"direction\":{\"left\":1,\"right\":1,\"up\":1,\"down\":NONE}}],\r\n [{robotposition:{x:0,y:0,z:0,angle:0}}]\r\n ],\r\n [ \r\n [{\"x\":-9,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":1}},\r\n {\"x\":9,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":1,\"up\":1,\"down\":NONE}},\r\n {\"x\":0,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":1,\"up\":1,\"down\":1}},\r\n {\"x\":0,\"z\":-6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}}],\r\n [{robotposition:{x:0,y:0,z:0,angle:0}}]\r\n ],\r\n [ \r\n [{\"x\":-9,\"z\":6.75 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":1,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":9,\"z\":-6.75 ,\"boardno\":0,\"direction\":{\"left\":1,\"right\":NONE,\"up\":1,\"down\":NONE}},\r\n {\"x\":9,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":1,\"right\":1,\"up\":1,\"down\":NONE}},\r\n {\"x\":-9,\"z\":-6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}}],\r\n [{robotposition:{x:0,y:0,z:0,angle:0}}]\r\n ],\r\n [ \r\n [{\"x\":-9,\"z\":6.75 ,\"boardno\":0,\"direction\":{\"left\":1,\"right\":1,\"up\":NONE,\"down\":1}},\r\n {\"x\":9,\"z\":-6.75 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":1,\"up\":1,\"down\":NONE}},\r\n {\"x\":9,\"z\":6.75 ,\"boardno\":1,\"direction\":{\"left\":1,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":-9,\"z\":-6.75 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}}],\r\n [{robotposition:{x:0,y:0,z:0,angle:0}}]\r\n ],\r\n [ \r\n [{\"x\":-4.5,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":1,\"down\":1}},\r\n {\"x\":-11.25,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":11.25,\"z\":4.5 ,\"boardno\":1,\"direction\":{\"left\":1,\"right\":1,\"up\":1,\"down\":NONE}},\r\n {\"x\":11.25,\"z\":-4.5 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":1}}],\r\n [{robotposition:{x:0,y:0,z:0,angle:0}}]\r\n ],\r\n [ \r\n [{\"x\":-4.5,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":1}},\r\n {\"x\":-11.25,\"z\":0 ,\"boardno\":0,\"direction\":{\"left\":NONE,\"right\":1,\"up\":NONE,\"down\":1}},\r\n {\"x\":11.25,\"z\":4.5 ,\"boardno\":1,\"direction\":{\"left\":NONE,\"right\":NONE,\"up\":NONE,\"down\":NONE}},\r\n {\"x\":11.25,\"z\":-4.5 ,\"boardno\":1,\"direction\":{\"left\":1,\"right\":1,\"up\":NONE,\"down\":1}}],\r\n [{robotposition:{x:0,y:0,z:0,angle:0}}]\r\n ] \r\n ] \r\n};\r\nexport default class SceneConfig{\r\n\r\n constructor(){\r\n this.candleno = 0;\r\n this.boardno = 0;\r\n this.mapno = 0;\r\n window[\"setCandle\"] = this.setCandle.bind(this);\r\n window[\"setRobotPosition\"] = this.setRobotPosition.bind(this);\r\n window[\"setRobotRotation\"] = this.setRobotRotation.bind(this);\r\n // this.setcandleEvent = new Event(events.setcandle_eve, {bubbles:true, cancelable:true});\r\n }\r\n setCandle(_candleno,_mapno){\r\n // console.log(\"!! api set!! \"+_candleno+\" \"+_mapno+\" \"+candlePositionConfig.positionmap[0].length);\r\n _mapno %=candlePositionConfig.positionmap.length;\r\n this.candleno = _candleno;\r\n if(this.candleno>candlePositionConfig.positionmap[_mapno][0].length)\r\n this.candleno =candlePositionConfig.positionmap[_mapno][0].length;\r\n this.mapno = _mapno;\r\n this.setcandleEvent = new CustomEvent(events.setcandle_eve,{detail:{candleno:this.candleno,mapno:this.mapno}});\r\n document.dispatchEvent(this.setcandleEvent);\r\n }\r\n setRobotPosition(posx,posy,posz){\r\n const setrobotEvent = new CustomEvent(events.setrobotPos_eve,{detail:{x:posx,y:posy,z:posz}});\r\n document.dispatchEvent(setrobotEvent);\r\n }\r\n setRobotRotation(rotation){\r\n const setrobotEvent = new CustomEvent(events.setrobot_angle,{detail:{angle:rotation}});\r\n document.dispatchEvent(setrobotEvent);\r\n }\r\n}\r\n\r\n\r\n","export default class SceneManager{\r\n constructor(){\r\n this.sceneState = {firefighting:1,maze:2,demo:3}; \r\n this.currentSceneState = 0;\r\n window[\"setSceneState\"] = this.setSceneState.bind(this);\r\n }\r\n setSceneState(scenestate)\r\n {\r\n this.currentSceneState = scenestate;\r\n }\r\n}","export default class SceneOptimiser{\r\n\r\n constructor(targertframeRate,time,scene)\r\n {\r\n this.options = new BABYLON.SceneOptimizerOptions(targertframeRate,time);\r\n BABYLON.SceneOptimizerOptions.LowDegradationAllowed();\r\n BABYLON.SceneOptimizerOptions.ModerateDegradationAllowed();\r\n BABYLON.SceneOptimizerOptions.HighDegradationAllowed();\r\n this.options.addOptimization(new BABYLON.HardwareScalingOptimization(0, 1.5));\r\n this.optimizer = new BABYLON.SceneOptimizer(scene,this.options);\r\n this.optimizer.onSuccessObservable.add(function () {\r\n console.log(\"optimizer.onSuccessObservable\");\r\n });\r\n this.optimizer.onNewOptimizationAppliedObservable.add(function (optim) {\r\n console.log(\"optimizer.onNewOptimizationAppliedObservable\");\r\n });\r\n this.optimizer.onFailureObservable.add(function () {\r\n console.log(\"optimizer.onFailureObservable\");\r\n });\r\n window[\"startOptimiser\"] = this.startOptimiser.bind(this);\r\n window[\"stopOptimiser\"] = this.stopOptimiser.bind(this);\r\n }\r\n startOptimiser()\r\n {\r\n this.optimizer.start();\r\n } \r\n stopOptimiser()\r\n {\r\n this.optimizer.stop();\r\n } \r\n}","import * as BABYLON from 'babylonjs';\r\nimport * as CANNON from 'cannon';\r\nimport { getValueByUnitType, UnitTypes } from './units.js';\r\nimport * as Utils from './utils.js';\r\n\r\nexport default class WorldManager {\r\n constructor(scene,texture_path) {\r\n this.scene=scene;\r\n this.world; //Physical World\r\n this.gravity = new BABYLON.Vector3(0, Utils.GRAVITY, 0); //World Gravity\r\n this.boxes = [];\r\n this.id = 0;\r\n //Materials\r\n this.alphaMat=new BABYLON.StandardMaterial(\"alpha_Mat\",this.scene);\r\n this.alphaMat.alpha=.6;\r\n this.fixedTimeStep = 1/60.0; // seconds\r\n this.maxSubSteps = 4;\r\n this.lastTime = undefined;\r\n this.curentTime = new Date().getTime();\r\n this.groundMat = new BABYLON.StandardMaterial(\"myMat\", this.scene);\r\n // this.groundMat.diffuseColor = BABYLON.Color3.FromHexString(\"#706654\");\r\n this.groundMat.diffuseColor = BABYLON.Color3.FromHexString(\"#ffffff\");\r\n const tex = new BABYLON.Texture(texture_path, this.scene);\r\n tex.hasAlpha=true;\r\n this.groundMat.diffuseTexture = tex;\r\n this.groundMat.freeze();\r\n \r\n let faceUV = new Array(6);\r\n for (let i = 0; i < 6; i++) {\r\n faceUV[i] = new BABYLON.Vector4(0, 0, 0, 0);\r\n }\r\n faceUV[0] = new BABYLON.Vector4(0,0,1,1);\r\n let options = {\r\n width: 1,\r\n height: 1,\r\n depth: 1,\r\n faceUV: faceUV\r\n };\r\n this.vGround = BABYLON.MeshBuilder.CreateBox(\"\",options,this.scene);\r\n this.vGround.isPickable = false;\r\n this.vGround.material = this.groundMat;\r\n this.vGround.setEnabled(false);\r\n this.vGround.freezeWorldMatrix();\r\n this.createPhysicsWorld();\r\n } \r\n\r\n createPhysicsWorld () { //first Load\r\n\r\n this.world = new CANNON.World();\r\n this.world.gravity.set(0, this.gravity.y, 0);\r\n \r\n this.world.broadphase = new CANNON.NaiveBroadphase();\r\n this.world.defaultContactMaterial.friction = .001;\r\n this.world.defaultContactMaterial.restitution =.1;\r\n this.world.solver.iterations = 40;\r\n this.world.quatNormalizeSkip = 0;\r\n this.world.quatNormalizeFast = true;\r\n this.world.solver.tolerance = .0001;\r\n this.world.defaultContactMaterial.contactEquationStiffness = 1e9; //1e9 5e6\r\n this.world.defaultContactMaterial.contactEquationRelaxation = 5;\r\n let groundMaterial = new CANNON.Material(\"physicgroundMaterial\");\r\n groundMaterial.friction = .3;\r\n groundMaterial.restitution = .3;\r\n let wheelMaterial = new CANNON.Material(\"wheelMaterial\");\r\n const wheelGroundContactMaterial = window[\"wheelGroundContactMaterial\"] = new CANNON.ContactMaterial(wheelMaterial, groundMaterial, {\r\n friction: .3,\r\n restitution:.3,\r\n // contactEquationStiffness: 1e7,\r\n // contactEquationRelaxation:10,\r\n // frictionEquationStiffness: 1e7,\r\n // frictionEquationRelaxation:10\r\n });\r\n // We must add the contact materials to the world\r\n this.world.addContactMaterial(wheelGroundContactMaterial);\r\n\r\n // this.world.addEventListener('beginContact', () => {\r\n // console.log('contact!!!')\r\n // })\r\n\r\n // this.world.addEventListener('endContact', () => {\r\n // console.log('end contact!!!')\r\n // })\r\n // this.calculateArea();\r\n }\r\n createGroundTile (groundName, groundPosition, groundSizeV3,visibleValue) { //Physical & NormalGrounds\r\n let groundRot = new BABYLON.Vector3(0,0,0); // Ground Angle\r\n // Step 1 -- Create Physics Ground\r\n let groundSize = new CANNON.Vec3(groundSizeV3.x/2, groundSizeV3.y/2, groundSizeV3.z/2);// Step 1 -- Make Shape\r\n let BoxShape = new CANNON.Box(groundSize);\r\n let pGround = new CANNON.Body({mass: 0, shape: BoxShape}); // Step 2 -- Build the body\r\n pGround.addShape(BoxShape);\r\n pGround.name = \"physicground\";\r\n switch(groundName){\r\n case \"Left\":\r\n pGround.position.set(groundPosition.x, groundPosition.y, groundPosition.z+.3);\r\n break;\r\n case \"Right\": \r\n pGround.position.set(groundPosition.x, groundPosition.y, groundPosition.z-.3);\r\n break;\r\n case \"Forward\": \r\n pGround.position.set(groundPosition.x-.3, groundPosition.y, groundPosition.z);\r\n break;\r\n case \"BackWard\":\r\n pGround.position.set(groundPosition.x+.3, groundPosition.y, groundPosition.z);\r\n break\r\n case \"Ground\":\r\n pGround.position.set(groundPosition.x, groundPosition.y, groundPosition.z);\r\n break;\r\n }\r\n pGround.quaternion.setFromEuler(groundRot.x,groundRot.y, groundRot.z,\"XYZ\");\r\n this.world.add(pGround); \r\n // Step 2 -- Create Virtual Ground\r\n let tmpGround = this.vGround.clone(groundName+\"_v\"); // BABYLON.MeshBuilder.CreateBox(groundName+\"_v\", {height: groundSizeV3.y, width:groundSizeV3.x, depth:groundSizeV3.z}, this.scene);\r\n tmpGround.scaling = new BABYLON.Vector3(groundSizeV3.x,groundSizeV3.y*3,groundSizeV3.z)\r\n tmpGround.position = new BABYLON.Vector3(groundPosition.x,groundPosition.y+1.5, groundPosition.z);\r\n // tmpGround.rotationQuaternion = new BABYLON.Quaternion.FromEulerAngles(groundRot.x,groundRot.y, groundRot.z);\r\n tmpGround.visibility = visibleValue;\r\n tmpGround.isPickable=true;\r\n \r\n let mat = this.groundMat.clone(groundName+\"mat\");\r\n tmpGround.material = mat;\r\n \r\n if(groundName.includes(\"Left\"))\r\n tmpGround.material.diffuseTexture.wAng = BABYLON.Angle.FromDegrees(180).radians();\r\n if(groundName.includes(\"Right\")){\r\n tmpGround.material.diffuseTexture.wAng = BABYLON.Angle.FromDegrees(180).radians();\r\n tmpGround.rotation.y = BABYLON.Angle.FromDegrees(180).radians();\r\n }\r\n if(groundName.includes(\"Forward\")){\r\n tmpGround.material.diffuseTexture.wAng = BABYLON.Angle.FromDegrees(180).radians();\r\n tmpGround.scaling = new BABYLON.Vector3(groundSizeV3.z,groundSizeV3.y*3,groundSizeV3.x)\r\n tmpGround.rotation.y = BABYLON.Angle.FromDegrees(270).radians();\r\n }\r\n if(groundName.includes(\"BackWard\")){\r\n tmpGround.material.diffuseTexture.wAng = BABYLON.Angle.FromDegrees(180).radians();\r\n tmpGround.scaling = new BABYLON.Vector3(groundSizeV3.z,groundSizeV3.y*3,groundSizeV3.x)\r\n tmpGround.rotation.y = BABYLON.Angle.FromDegrees(-270).radians();\r\n }\r\n tmpGround.material.freeze();\r\n tmpGround.freezeWorldMatrix();\r\n tmpGround.setEnabled(true);\r\n this.vGround.setEnabled(false);\r\n // Step 5 -- Add To Physical World\r\n return {\r\n pBody : pGround,\r\n vBody : tmpGround,\r\n };\r\n }\r\n createCub (name,position){\r\n // Step 1 -- Create Physics Cube\r\n let cubeSize = new BABYLON.Vector3(1, 1, 1); \r\n let cubeShape = new CANNON.Box(new CANNON.Vec3(cubeSize.x, cubeSize.y, cubeSize.z));\r\n let cubeBody = new CANNON.Body({mass: 1, shape: cubeShape}); // Step 2 -- Build the body\r\n cubeBody.addShape(cubeShape);\r\n cubeBody.position.set(position.x, position.y, position.z);\r\n cubeBody.quaternion.setFromEuler(0, 0, 0,\"XYZ\");\r\n\r\n this.world.add(cubeBody);\r\n // Step 2 -- Create Virtual Cube\r\n let vCube = BABYLON.MeshBuilder.CreateBox(name, {width: cubeSize.x * 2, height: cubeSize.y * 2, depth: cubeSize.z * 2}, this.scene);\r\n vCube.position = new BABYLON.Vector3.Zero();\r\n let boxMat = new BABYLON.StandardMaterial(\"boxMat\", this.scene);\r\n vCube.material = boxMat;\r\n this.boxes.push(\r\n {\r\n pCube: cubeBody,\r\n vCube: vCube,\r\n }\r\n )\r\n return {\r\n p: cubeBody,\r\n v: vCube,\r\n }\r\n }\r\n createBalls () {\r\n const cubeShape = new CANNON.Sphere(0.25);\r\n const cubeBody = new CANNON.Body({ mass: 1, shape: cubeShape }); // Step 2 -- Build the body\r\n cubeBody.addShape(cubeShape);\r\n cubeBody.position.set(this.carPosition.x, 5, this.carPosition.z);\r\n this.world.add(cubeBody);\r\n const sphere = BABYLON.MeshBuilder.CreateSphere(\"sphere\" + this.id,{ diameter: 0.25 * 2 },this.scene);\r\n this.boxes.push({pCube: cubeBody,vCube: sphere,});\r\n this.id++;\r\n if(this.id < Utils.ballsCount){\r\n setTimeout(() => {\r\n this.createBalls();\r\n }, 2000);\r\n }\r\n }\r\n createObjectMaterial(){\r\n let objMaterial = new CANNON.Material(\"cannonobj_mat\");\r\n objMaterial.friction = .3;\r\n objMaterial.restitution=.3;\r\n return objMaterial;\r\n }\r\n updateWorld(frameRate){\r\n this.curentTime = new Date().getTime();\r\n if(this.lastTime !== undefined){\r\n let delta = (this.curentTime - this.lastTime) / 1000;\r\n if(frameRate<30)\r\n frameRate =30;\r\n\r\n frameRate = frameRate.toFixed(1);\r\n this.fixedTimeStep = 1/frameRate;\r\n this.world.step(this.fixedTimeStep,delta,this.maxSubSteps);\r\n }\r\n this.lastTime = this.curentTime;\r\n \r\n }\r\n calculateArea(){\r\n let size=.5\r\n let tmp = BABYLON.MeshBuilder.CreateBox(\"\", {size:size},this.scene);\r\n tmp.position = new BABYLON.Vector3(-18,0,0);\r\n tmp.isPickable = false;\r\n \r\n let tmp1 = tmp.clone(\"1\");\r\n tmp1.position = new BABYLON.Vector3(18,0,0);\r\n tmp1.isPickable = false;\r\n\r\n const myPoints = [tmp1.position,tmp.position];\r\n const lines = BABYLON.MeshBuilder.CreateLines(\"lines\", {points: myPoints});\r\n lines.isPickable = false;\r\n let vDis = BABYLON.Vector3.Distance(tmp.position,tmp1.position); \r\n console.log(\"!!! vdistance!!! \"+getValueByUnitType(vDis,UnitTypes.mm)+\"mm\");\r\n\r\n\r\n\r\n let tmp2 = tmp.clone(\"2\");\r\n tmp2.position = new BABYLON.Vector3(0,0,12);\r\n tmp2.isPickable = false;\r\n\r\n let tmp3 = tmp.clone(\"3\");\r\n tmp3.position = new BABYLON.Vector3(0,0,-12);\r\n tmp3.isPickable = false;\r\n\r\n const myPoints2 = [tmp2.position,tmp3.position];\r\n const lines2 = BABYLON.MeshBuilder.CreateLines(\"lines\", {points: myPoints2});\r\n lines2.isPickable = false;\r\n let hDis = BABYLON.Vector3.Distance(tmp2.position,tmp3.position); \r\n console.log(\"!!! hdistance!!! \"+getValueByUnitType(hDis,UnitTypes.mm)+\"mm\");\r\n\r\n\r\n \r\n let centertmp = tmp.clone(\"4\");\r\n centertmp.position = new BABYLON.Vector3(0,0,0);\r\n\r\n let centertmp2 = tmp.clone(\"4\");\r\n centertmp2.position = new BABYLON.Vector3(14,0,0);\r\n\r\n\r\n // let groundcube = BABYLON.MeshBuilder.CreateBox(\"\", {width: 20, height: .2, depth: 20},this.scene);\r\n // groundcube.position = new BABYLON.Vector3(0,-.2,0);\r\n\r\n // let mat = new BABYLON.PBRMaterial(\"mymat\",this.scene);\r\n // mat.albedoTexture = new BABYLON.Texture(\"./textures/Ground/Sand_003_COLOR.jpg\", this.scene);\r\n // mat.bumpTexture = new BABYLON.Texture(\"textures/Ground/Sand_003_NORM.jpg\", this.scene); \r\n // mat.ambientTexture = new BABYLON.Texture(\"textures/Ground/Sand_003_OCC.jpg\", this.scene); \r\n // mat.metallicTexture = new BABYLON.Texture(\"textures/Ground/Sand_003_ROUGH.jpg\", this.scene); \r\n // groundcube.material = mat;\r\n\r\n\r\n\r\n }\r\n\r\n\r\n\r\n}","\nexport default class MyRobotWrapper\n{\n constructor()\n {\n this.loaderManager = null;\n this.createMyRobot(this); \n window['createMyRobot'] = this.createMyRobot.bind(this);\n } \n createMyRobot() \n {\n return this;\n }\n setLoaderManager(loadmanager)\n {\n this.loaderManager = loadmanager;\n } \n getleftMotorPower()\n {\n if(this.loaderManager.loaded)\n {\n console.log(\"!! LeftPower is!!! \"+this.loaderManager.carManager.leftEnginePower);\n }\n }\n // getleftEngineSpeed()\n // {\n // if(this.loaderManager.loaded)\n // {\n // console.log(\"!! LeftSpeed is!!! \"+this.loaderManager.carManager.leftEngineSpeed);\n // }\n // }\n getrightMotorPower()\n {\n if(this.loaderManager.loaded)\n {\n console.log(\"!! RightPower is!!! \"+this.loaderManager.carManager.rightEnginePower);\n }\n }\n // getrightEngineSpeed()\n // {\n // if(this.loaderManager.loaded)\n // {\n // console.log(\"!! RightSpeed is!!! \"+this.loaderManager.carManager.rightEngineSpeed);\n // }\n // }\n applyRoboEnginesPowers(leftMotor,rightMotor)\n {\n // this.lInput.value = leftMotor;\n // this.rInput.value = rightMotor;\n // document.getElementById(\"leftEngineInput\").value= this.lInput.value;\n // document.getElementById(\"rightEngineInput\").value= this.rInput.value;\n this.loaderManager.carManager.applyEnginesPowers(leftMotor,rightMotor);\n }\n applyRoboEnginesBrake()\n {\n this.loaderManager.carManager.stopEngines();\n }\n switchFanAnim(fanSwitch)\n {\n if(document.getElementById(\"fanAnim\"))\n document.getElementById(\"fanAnim\").checked = fanSwitch;\n \n console.log(this.loaderManager.carManager.fanComponent+\" !!! fan!!!! \");\n this.loaderManager.carManager.fanComponent.runFanAnimation(fanSwitch);\n }\n getColorSensorValue()\n {\n let leftsensor = this.loaderManager.carManager.leftcolorSensor.sensorValue;\n let rightsensor = this.loaderManager.carManager.rightcolorSensor.sensorValue;\n return {\"left\":leftsensor,\"right\":rightsensor};\n }\n getFlameSenseorValue() \n {\n let flameSsensor = this.loaderManager.carManager.flameSensor.sensorValue;\n return flameSsensor;\n }\n getDistanceSenseorValue() \n {\n // let distacneSsensor = {\"distancesensor\":{state:this.loaderManager.inputs.disState,name:this.loaderManager.inputs.dis_name.value,direction:this.loaderManager.inputs.dis_dir.value}};\n let distanceSsensor = this.loaderManager.carManager.distanceSensor.sensorValue;\n return distanceSsensor;\n }\n getRobotPosition() \n {\n let robot = this.loaderManager.carManager.chassisBody;\n let pos = {x:robot.position.x,y:robot.position.y,z:robot.position.z};\n return pos;\n }\n getRobotVelocity() \n {\n let velocity = this.loaderManager.carManager.getRobotVelocity();\n return velocity;\n }\n \n getAllSensorValue()\n { \n let sensorval={\n \"flamesensor\" : this.loaderManager.carManager.flameSensor.sensorValue,\n \"distancesensor\" : this.loaderManager.carManager.distanceSensor.sensorValue,\n \"irsensor\":{\n \"left\" :this.loaderManager.carManager.leftcolorSensor.sensorValue,\n \"right\":this.loaderManager.carManager.rightcolorSensor.sensorValue\n },\n \"robot\":{\n \"position\": {\"x\":this.getRobotPosition().x,\"y\":this.getRobotPosition().y,\"z\":this.getRobotPosition().z},\n \"velocity\": this.getRobotVelocity() \n }\n }\n // console.log(val);\n return sensorval;\n\n }\n\n\n turnOnRobotLight()\n {\n this.loaderManager.carManager.turnOnRobotLight(); \n \n }\n turnOffRobotLight()\n {\n this.loaderManager.carManager.turnOffRobotLight(); \n \n }\n showRayCast()\n {\n this.loaderManager.carManager.leftcolorSensor.isVisibleRay=true;\n this.loaderManager.carManager.rightcolorSensor.isVisibleRay=true;\n this.loaderManager.carManager.distanceSensor.isVisibleRay=true;\n this.loaderManager.carManager.flameSensor.isVisibleRay=true;\n this.loaderManager.carManager.fanSensor.rayvisible=true;\n\n }\n hideRayCast()\n {\n this.loaderManager.carManager.leftcolorSensor.isVisibleRay=false;\n this.loaderManager.carManager.rightcolorSensor.isVisibleRay=false;\n this.loaderManager.carManager.distanceSensor.isVisibleRay=false;\n this.loaderManager.carManager.flameSensor.isVisibleRay=false;\n this.loaderManager.carManager.fanSensor.rayvisible=false;\n }\n followCamera()\n {\n this.loaderManager.carManager.arcCam.lockedTarget = this.loaderManager.carManager.babylonCarBox\n }\n unfollowCamera()\n {\n this.loaderManager.carManager.arcCam.lockedTarget = new BABYLON.Vector3(0,0,0);\n }\n} ","import * as BABYLON from \"babylonjs\";\r\nimport \"babylonjs-loaders\";\r\nimport LoaderManager from \"../LoaderManager.js\";\r\nimport FlameEffectGenerator from \"../Effects/FlameEffectGenerator.js\";\r\nimport ObstacleGenerator from \"../Helper/ObstacleGenerator.js\";\r\nimport WorldManager from \"../WorldManager.js\";\r\nimport * as Utils from \"../utils.js\";\r\nimport Common from '../Common.js'\r\nimport MyRobotWrapper from \"../Wrapper/MyRobo.js\";\r\nimport SceneConfig from '../SceneConfig';\r\nimport { candlePositionConfig } from \"../SceneConfig\";\r\nimport { BOARD_DISTANCE } from \"../SceneConfig\";\r\nimport SceneOptimiser from \"../SceneOptimiser.js\";\r\nimport BallonAnim from \"../BallonAnim.js\";\r\n\r\nconst CANDLE_STATE = { state1: \"UPRIGHT\", state2: \"ON THE GROUND\" };\r\nclass CandleInfo {\r\n constructor(_name) {\r\n this.info = {\r\n name: _name,\r\n candlesPosition: CANDLE_STATE.state1,\r\n isflameon: true,\r\n OnFlameOff: {\r\n IsFlameOffByFan: false,\r\n RobotDistanceFromCandle: undefined,\r\n IsRobotTouchingCandle: false\r\n }\r\n }\r\n this.isFlameExtinguish = false;\r\n this.isRobotTouch = false;\r\n }\r\n}\r\nclass BoardInfo {\r\n constructor(name) {\r\n this.name = name;\r\n this.position = \"UPRIGHT\";\r\n this.collideRobot = false;\r\n }\r\n}\r\nexport default class FireFightingScene {\r\n constructor(gameManager) {\r\n this.game = gameManager;\r\n this.sceneCommon = new Common(this.game);\r\n this.scene = this.sceneCommon.createScene(\"firefightingscene\");\r\n this.arcCam = this.sceneCommon.createCamera(this.scene);\r\n this.isUi = false;\r\n this.rayState = false;\r\n //TilesHolder\r\n this.tiles = [];\r\n this.mysceneConfig = new SceneConfig();\r\n this.robotInterFace = new MyRobotWrapper();\r\n this.flameEffect = [];\r\n this.board = [];\r\n this.objMaterial;\r\n this.initScene();\r\n this.game.engine.hideLoadingUI();\r\n this.boardEvent = new Event(Utils.events.boardDown);\r\n this.sceneOptimiser = new SceneOptimiser(50, 500, this.scene);\r\n //this.sceneOptimiser.startOptimiser();\r\n this.candleState = [];\r\n this.boardState = [];\r\n window[\"getCandleState\"] = this.getCandleState.bind(this);\r\n window[\"getFireFightingEvents\"] = this.getFireFightingEvents.bind(this);\r\n // window[\"setMap\"] = this.setMap.bind(this);\r\n\r\n }\r\n initScene() {\r\n //Physics World\r\n this.ballonObj = new BallonAnim(this.scene);\r\n const ballonsphere = BABYLON.MeshBuilder.CreateSphere(\"ballonsphere\", { diameter: .5 }, this.scene); //scene is \r\n let ballonmat = new BABYLON.StandardMaterial(\"ballonMat\", this.scene);\r\n ballonmat.diffuseColor = new BABYLON.Color3(1, 0, 0);\r\n ballonsphere.material = ballonmat;\r\n this.ballonObj.setBallonObj(ballonsphere);\r\n\r\n this.worldManager = new WorldManager(this.scene, \"textures/name.png\");\r\n this.loaderManager = new LoaderManager(this);\r\n this.loaderManager.initializeSceneAssets();\r\n this.initializeEnvironMent();\r\n\r\n\r\n this.leftPanel = document.getElementById(\"l_ui\");\r\n this.rightPanel = document.getElementById(\"r_ui\");\r\n\r\n this.simulateBut = document.getElementById(\"simulate\");\r\n this.stopBut = document.getElementById(\"stop\");\r\n\r\n this.lInput = document.getElementById(\"leftEngineInput\");\r\n this.rInput = document.getElementById(\"rightEngineInput\");\r\n\r\n this.Inputs = {\r\n xInput: document.getElementById(\"pos_x\"), // x input\r\n yInput: document.getElementById(\"pos_y\"), // y input\r\n zInput: document.getElementById(\"pos_z\"), // z input\r\n vInput: document.getElementById(\"velocity\"), //Velocity Input\r\n //\r\n l_surState: document.getElementById(\"l_sur_state\"), //sur_state Input\r\n l_surR: document.getElementById(\"l_sur_r\"), //sur_color_r Input\r\n l_surG: document.getElementById(\"l_sur_g\"), //sur_color_g Input\r\n l_surB: document.getElementById(\"l_sur_b\"), //sur_color_b Input\r\n l_surImg: document.getElementById(\"l_sur_img\"), //sur_color_b Input\r\n left_IR: document.getElementById(\"left_ir\"), //sur_ir value\r\n //\r\n r_surState: document.getElementById(\"r_sur_state\"), //sur_state Input\r\n r_surR: document.getElementById(\"r_sur_r\"), //sur_color_r Input\r\n r_surG: document.getElementById(\"r_sur_g\"), //sur_color_g Input\r\n r_surB: document.getElementById(\"r_sur_b\"), //sur_color_b Input\r\n r_surImg: document.getElementById(\"r_sur_img\"), //sur_color_b Input\r\n right_IR: document.getElementById(\"right_ir\"), //sur_ir value\r\n\r\n\r\n //\r\n disState: document.getElementById(\"dis_state\"), //sur_state Input\r\n dis_name: document.getElementById(\"dis_name\"), //sur_color_r Input\r\n dis_dir: document.getElementById(\"dis_dir\"), //sur_color_r Input\r\n\r\n flameSensorDis: document.getElementById(\"flameSensor_state\"), //sur_state Input\r\n flameSensorName: document.getElementById(\"flameSensor_name\"), //sur_color_r Input\r\n flameSensorValue: document.getElementById(\"flameSensor_value\"), //sur_color_r Input\r\n };\r\n // //init LoadManager\r\n this.robotInterFace.setLoaderManager(this.loaderManager);\r\n this.addFireFightingEventListner();\r\n this.simulateBut.addEventListener(\"click\", () => {\r\n //confirm Button\r\n this.loaderManager.carManager.applyEnginesPowers(this.lInput.value, this.rInput.value);\r\n });\r\n this.stopBut.addEventListener(\"click\", () => {\r\n //confirm Button \r\n this.loaderManager.carManager.stopEngines();\r\n });\r\n\r\n this.scene.onKeyboardObservable.add((kbInfo) => {\r\n switch (kbInfo.type) {\r\n case BABYLON.KeyboardEventTypes.KEYDOWN:\r\n // console.log(\"KEY DOWN: \", kbInfo);\r\n if (kbInfo.event.keyCode === 72) {\r\n //h\r\n this.leftPanel.style.display = this.isUi ? \"none\" : \"block\";\r\n this.rightPanel.style.display = this.isUi ? \"none\" : \"block\";\r\n this.isUi = !this.isUi;\r\n } else if (kbInfo.event.keyCode === 74) {\r\n //j\r\n // this.loaderManager.carManager.toggleRays(this.rayState);\r\n // this.rayState = !this.rayState;\r\n } else if (kbInfo.event.keyCode === 66) {\r\n //B\r\n // this.loaderManager.carManager.handleCreateBalls();\r\n } else if (kbInfo.event.keyCode === 32) {\r\n //SPACE\r\n // this.loaderManager.carManager.openBoxDoor();\r\n }\r\n break;\r\n }\r\n });\r\n // this.scene.debugLayer.show();\r\n // return this.scene;\r\n }\r\n initializeEnvironMent() {\r\n this.initVisualScene();\r\n }\r\n\r\n initVisualScene() {\r\n //here we can create scene elements (ground,borders,etc)\r\n //Ground\r\n let sizeV3 = new BABYLON.Vector3(Utils.groundWidth, 0.1, Utils.groundDepth); // Ground Size\r\n let ground = this.worldManager.createGroundTile(\"Ground\", new BABYLON.Vector3(0, Utils.groundY, 0), sizeV3, 0);\r\n ground.vBody.tag = \"ground\";\r\n\r\n //create trigger ground\r\n var pickedGround = BABYLON.MeshBuilder.CreateBox(\"pickedGround\", { height: sizeV3.y, width: sizeV3.x, depth: sizeV3.z }, this.scene);\r\n pickedGround.position = new BABYLON.Vector3(0, 0, 0);\r\n pickedGround.rotationQuaternion = new BABYLON.Quaternion.FromEulerAngles(0, 0, 0);\r\n pickedGround.visibility = 0;\r\n pickedGround.isPickable = false;\r\n //pickedGround.material = this.groundMat;\r\n\r\n //Create CubicTexture\r\n // let skyboxCubecTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(\"Textures/environment/autoshop_01_4k.env\",/* \"./environment/Panorama.env\",*/this.scene);\r\n // skyboxCubecTexture.gammaSpace = true;\r\n // skyboxCubecTexture.level = 1;\r\n // this.scene.environmentTexture = skyboxCubecTexture;\r\n\r\n //Left\r\n sizeV3 = new BABYLON.Vector3(Utils.groundWidth, Utils.border.height, Utils.border.depth); // Border Size\r\n let leftBorder = this.worldManager.createGroundTile(\"Left\", new BABYLON.Vector3(0, Utils.border.height / 2, -(Utils.groundDepth / 2) + -Utils.border.depth / 2), sizeV3, 1);\r\n\r\n //Right\r\n sizeV3 = new BABYLON.Vector3(Utils.groundWidth, Utils.border.height, Utils.border.depth); // Border Size\r\n let rightBorder = this.worldManager.createGroundTile(\"Right\", new BABYLON.Vector3(0, Utils.border.height / 2, Utils.groundDepth / 2 + Utils.border.depth / 2), sizeV3, 1);\r\n\r\n //Forward\r\n sizeV3 = new BABYLON.Vector3(Utils.border.depth, Utils.border.height, Utils.groundDepth); // Border Size\r\n let forwardBorder = this.worldManager.createGroundTile(\"Forward\", new BABYLON.Vector3(Utils.groundWidth / 2 + Utils.border.depth / 2, Utils.border.height / 2, 0), sizeV3, 1);\r\n //BackWard\r\n sizeV3 = new BABYLON.Vector3(Utils.border.depth, Utils.border.height, Utils.groundDepth); // Border Size\r\n let backBorder = this.worldManager.createGroundTile(\"BackWard\", new BABYLON.Vector3(-Utils.groundWidth / 2 + Utils.border.depth / 2, Utils.border.height / 2, 0), sizeV3, 1);\r\n\r\n // BABYLON.SceneLoader.ImportMesh(\"\",\"/models/scene/\",\"Fire_Challenge.glb\",this.scene,(meshes, particleSystems, skeletons) => {\r\n // // console.log(\"meshes\", meshes)\r\n // let carpet = this.scene.getNodeByID(\"Carpet\");\r\n // carpet.position.y = Utils.groundY;\r\n // let circle = this.scene.getNodeByID(\"Circle\");\r\n // circle.setEnabled(false);\r\n // let candle = this.scene.getNodeByID(\"Candle\");\r\n // candle.setEnabled(false);\r\n // this.initCandle(); \r\n // }\r\n // );\r\n }\r\n initCandle() {\r\n //event for set candle\r\n window.setCandle(1, 0);\r\n }\r\n addFireFightingEventListner() {\r\n this.positionEvent = (e) => {\r\n this.loaderManager.carManager.setRobotPosition(e.detail.x, e.detail.y, e.detail.z);\r\n }\r\n document.addEventListener(Utils.events.setrobotPos_eve, this.positionEvent);\r\n\r\n this.rotationEvent = (e) => {\r\n this.loaderManager.carManager.setRobotRotation(e.detail.angle);\r\n }\r\n document.addEventListener(Utils.events.setrobot_angle, this.rotationEvent);\r\n this.candleDownEvent = (e) => {\r\n this.setCandleState(e.detail.id, CANDLE_STATE.state2, e.detail.candleFlame, e.detail.distance);\r\n }\r\n document.addEventListener(Utils.events.candleDown, this.candleDownEvent, false);\r\n\r\n this.candleRobotCollisionEvent = (e) => {\r\n // console.log({\"info\":\"candle collide with robot\",\"candle\":e.detail.candleFlame});\r\n for (let i = 0; i < this.candleState.length; i++) {\r\n if (this.candleState[i].info.name === e.detail.id && !e.detail.candleFlame) {\r\n this.candleState[i].isRobotTouch = true;\r\n break;\r\n }\r\n }\r\n this.setCandleState(e.detail.id, e.detail.candleFlame ? CANDLE_STATE.state1 : CANDLE_STATE.state2, e.detail.candleFlame, e.detail.distance);\r\n }\r\n document.addEventListener(Utils.events.candleRobotCollision, this.candleRobotCollisionEvent);\r\n\r\n this.candleBlowOffEvent = (e) => {\r\n // console.log({\"info\":e.detail.candleFlame,\"distance\":e.detail.distance+\"mm\"});\r\n for (let i = 0; i < this.candleState.length; i++) {\r\n if (this.candleState[i].info.name === e.detail.id) {\r\n this.candleState[i].isRobotTouch = e.detail.collide;\r\n break;\r\n }\r\n }\r\n this.setCandleState(e.detail.id, CANDLE_STATE.state1, false, e.detail.distance);\r\n this.ballonObj.setBallonPos(e.detail.position);\r\n }\r\n document.addEventListener(Utils.events.candleBlowOff, this.candleBlowOffEvent);\r\n\r\n this.boardDownEvent = (e) => {\r\n for (let i = 0; i < this.boardState.length; i++) {\r\n if (this.boardState[i].name === e.detail.name) {\r\n this.boardState[i].position = \"GROUND\";\r\n break;\r\n }\r\n }\r\n }\r\n document.addEventListener(Utils.events.boardDown, this.boardDownEvent);\r\n\r\n this.boardRobotCollisionEvent = (e) => {\r\n for (let i = 0; i < this.boardState.length; i++) {\r\n if (this.boardState[i].name === e.detail.name) {\r\n this.boardState[i].collideRobot = true;\r\n break;\r\n }\r\n }\r\n }\r\n document.addEventListener(Utils.events.boardRobotCollision, this.boardRobotCollisionEvent);\r\n\r\n this.changemotorEvent = (e) => {// console.log({\"info\":\"power change\",\"value\":e.detail});\r\n }\r\n document.addEventListener(Utils.events.changemotor, this.changemotorEvent);\r\n\r\n let objMaterial = this.worldManager.createObjectMaterial();\r\n this.setCandle = (e) => {\r\n console.log(\"!!! setCandle !!!\");\r\n if (this.scene) {\r\n for (let i = 0; i < this.flameEffect.length; i++)\r\n this.flameEffect[i].removeCandlefromScene();\r\n for (let b = 0; b < this.board.length; b++)\r\n this.board[b].removeBoardFromScene();\r\n\r\n // let randomMap = Math.floor(Math.random()*4);\r\n // randomMap=3;\r\n // let boardConfig = candlePositionConfig.positionmap[this.mysceneConfig.mapno];\r\n const mapConfig = candlePositionConfig.positionmap[e.detail.mapno][0];\r\n this.flameEffect = [];\r\n this.board = [];\r\n this.candleState = [];\r\n this.boardState = [];\r\n let boardNo = 0;\r\n for (let i = 0; i < e.detail.candleno; i++) {\r\n // console.log(this.mysceneConfig.candleno+\" 222222 \"+this.mysceneConfig.boardno+\" \"+i);\r\n this.flameEffect[i] = new FlameEffectGenerator(\"candle\" + i, new BABYLON.Vector2(mapConfig[i].x, mapConfig[i].z), { height: .7, diameter: .15 }\r\n , \"#12e04c\", .5, true, 1, this.worldManager, this.scene, this.loaderManager.carManager.babylonCarBox);\r\n this.candleState[i] = new CandleInfo(this.flameEffect[i].name);\r\n const obstacleSize = { width: 1.1, height: 2, depth: .4 };\r\n if (mapConfig[i].direction.left === 1) {\r\n this.board[boardNo] = new ObstacleGenerator(i + \"board\" + boardNo, new BABYLON.Vector2(mapConfig[i].x, mapConfig[i].z + BOARD_DISTANCE), obstacleSize,\r\n 0, \"textures/adbanner1.jpg\", this.worldManager, this.scene, this.boardEvent, objMaterial);\r\n this.boardState[boardNo] = new BoardInfo(this.board[boardNo].name);\r\n boardNo++;\r\n }\r\n if (mapConfig[i].direction.right === 1) {\r\n this.board[boardNo] = new ObstacleGenerator(i + \"board\" + boardNo, new BABYLON.Vector2(mapConfig[i].x, mapConfig[i].z - BOARD_DISTANCE), obstacleSize,\r\n 0, \"textures/adbanner1.jpg\", this.worldManager, this.scene, this.boardEvent, objMaterial);\r\n this.boardState[boardNo] = new BoardInfo(this.board[boardNo].name);\r\n boardNo++;\r\n }\r\n if (mapConfig[i].direction.up === 1) {\r\n this.board[boardNo] = new ObstacleGenerator(i + \"board\" + boardNo, new BABYLON.Vector2(mapConfig[i].x - BOARD_DISTANCE, mapConfig[i].z), obstacleSize,\r\n 1.57, \"textures/adbanner1.jpg\", this.worldManager, this.scene, this.boardEvent, objMaterial);\r\n this.boardState[boardNo] = new BoardInfo(this.board[boardNo].name);\r\n boardNo++;\r\n }\r\n if (mapConfig[i].direction.down === 1) {\r\n this.board[boardNo] = new ObstacleGenerator(i + \"board\" + boardNo, new BABYLON.Vector2(mapConfig[i].x + BOARD_DISTANCE, mapConfig[i].z), obstacleSize,\r\n 1.57, \"textures/adbanner1.jpg\", this.worldManager, this.scene, this.boardEvent, objMaterial);\r\n this.boardState[boardNo] = new BoardInfo(this.board[boardNo].name);\r\n boardNo++;\r\n }\r\n }\r\n const robotpositionConfig = candlePositionConfig.positionmap[e.detail.mapno][1];\r\n // console.log(robotpositionConfig[0].robotposition);\r\n if (robotpositionConfig[0].robotposition)\r\n window.setRobotPosition(robotpositionConfig[0].robotposition.x, robotpositionConfig[0].robotposition.y, robotpositionConfig[0].robotposition.z);\r\n if (robotpositionConfig[0].robotposition.angle)\r\n window.setRobotRotation(robotpositionConfig[0].robotposition.angle);\r\n if (this.loaderManager.carManager !== undefined)\r\n this.loaderManager.carManager.fanSensor.setCandleForSensor(this.flameEffect);\r\n }\r\n }\r\n // console.log(setCandle);\r\n document.addEventListener(Utils.events.setcandle_eve, this.setCandle);\r\n }\r\n setCandleState(id, state, flamestate, distance) {\r\n for (let i = 0; i < this.candleState.length; i++) {\r\n if (this.candleState[i].info.name === id) {\r\n this.candleState[i].info.candlesPosition = state;\r\n this.candleState[i].info.isflameon = flamestate;\r\n if (!this.candleState[i].isFlameExtinguish && !this.candleState[i].info.isflameon) {\r\n this.candleState[i].isFlameExtinguish = true;\r\n this.candleState[i].info.OnFlameOff.IsFlameOffByFan = this.candleState[i].info.candlesPosition === CANDLE_STATE.state1 ? true : false;\r\n this.candleState[i].info.OnFlameOff.RobotDistanceFromCandle = distance;\r\n this.candleState[i].info.OnFlameOff.IsRobotTouchingCandle = this.candleState[i].isRobotTouch;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n getCandleState() {\r\n let candleState = { info: [] };\r\n for (let i = 0; i < this.candleState.length; i++) {\r\n candleState.info.push(this.candleState[i].info);\r\n }\r\n return candleState.info;\r\n }\r\n getBoardState() {\r\n let boardState = { info: [] };\r\n for (let i = 0; i < this.boardState.length; i++) {\r\n boardState.info.push({ position: this.boardState[i].position, collideRobot: this.boardState[i].collideRobot });\r\n }\r\n return boardState.info;\r\n }\r\n releaseScene() {\r\n if(!this.scene)\r\n return;\r\n this.removeListner();\r\n for (let i = 0; i < this.flameEffect.length; i++)\r\n this.flameEffect[i].removeCandlefromScene();\r\n this.flameEffect = [];\r\n for (let b = 0; b < this.board.length; b++)\r\n this.board[b].removeBoardFromScene();\r\n this.board = [];\r\n for (let i = 0; i < this.scene.meshes.length; i++) {\r\n if (this.scene.meshes[i]) {\r\n // console.log(this.scene.meshes[i].name);\r\n if (this.scene.meshes[i])\r\n this.scene.meshes[i].dispose();\r\n this.scene.removeMesh(this.scene.meshes[i]);\r\n console.log(this.scene.meshes[i], \" \", i);\r\n }\r\n }\r\n this.loaderManager.carManager.releaseRobot();\r\n this.scene.stopAllAnimations();\r\n this.scene.cleanCachedTextureBuffer();\r\n this.scene.clearCachedVertexData();\r\n this.sceneCommon.release();\r\n this.game.releaseWorld();\r\n }\r\n removeListner() {\r\n document.removeEventListener(Utils.events.setcandle_eve, this.setCandle);\r\n document.removeEventListener(Utils.events.setrobotPos_eve, this.positionEvent);\r\n document.removeEventListener(Utils.events.setrobot_angle, this.rotationEvent);\r\n\r\n document.removeEventListener(Utils.events.candleDown, this.candleDownEvent);\r\n document.removeEventListener(Utils.events.candleRobotCollision, this.candleRobotCollisionEvent);\r\n document.removeEventListener(Utils.events.candleBlowOff, this.candleBlowOffEvent);\r\n document.removeEventListener(Utils.events.boardDown, this.boardDownEvent);\r\n document.removeEventListener(Utils.events.boardRobotCollision, this.boardRobotCollisionEvent);\r\n document.removeEventListener(Utils.events.changemotor, this.changemotorEvent);\r\n // this.worldManager.world.removeEventListener(\"postStep\",this.loaderManager.carManager.postlistner);\r\n }\r\n getFireFightingEvents() {\r\n\r\n const candleInfo = this.getCandleState();\r\n const boardInfo = this.getBoardState();\r\n\r\n console.log({ candleInfo: candleInfo, boardInfo: boardInfo });\r\n\r\n\r\n // let candleInfo=[];\r\n // if(this.candleState){\r\n // for(let i=0;i {\r\n if (this.mazeInfo[MazeMap2.data[i][j].id])\r\n this.mazeInfo[MazeMap2.data[i][j].id].start = true;\r\n }\r\n )\r\n );\r\n }\r\n if (MazeMap2.data[i][j].ismilestone) {\r\n this.mapTile[this.tileCnt]._children[0].material.diffuseColor = new BABYLON.Color3.FromHexString(random_hex_color_code());\r\n this.mapTile[this.tileCnt]._children[0].actionManager = new BABYLON.ActionManager(this.scene);\r\n this.mapTile[this.tileCnt]._children[0].actionManager.registerAction(\r\n new BABYLON.ExecuteCodeAction({\r\n trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger,\r\n parameter: { mesh: this.loaderManager.carManager.babylonWheelBodies[0]._children[0]._children[1] }\r\n },\r\n () => {\r\n if (!this.complete && this.mazeInfo[MazeMap2.data[i][j].id]) {\r\n this.mazeInfo[MazeMap2.data[i][j].id].milestone = true;\r\n }\r\n }\r\n )\r\n );\r\n }\r\n if (MazeMap2.data[i][j].end) {\r\n let rx = -this.row - this.tileSize / 2;\r\n let ry = this.col - this.tileSize / 2;\r\n const ballonPos = new BABYLON.Vector3(this.mapTile[this.tileCnt].position.x, this.mapTile[this.tileCnt].position.y, this.mapTile[this.tileCnt].position.z);\r\n this.mapTile[this.tileCnt]._children[0].material = this.groundTile.material.clone(\"endmaterial\");\r\n this.mapTile[this.tileCnt]._children[0].material.diffuseColor = new BABYLON.Color3(1, 0, 0);\r\n this.mapTile[this.tileCnt]._children[0].material.specularColor = new BABYLON.Color3(0, 0, 0);\r\n this.mapTile[this.tileCnt]._children[0].material.emissiveColor = new BABYLON.Color3(0, 0, 0);\r\n this.mapTile[this.tileCnt]._children[0].actionManager = new BABYLON.ActionManager(this.scene);\r\n this.mapTile[this.tileCnt]._children[0].actionManager.registerAction(\r\n new BABYLON.ExecuteCodeAction({\r\n trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger,\r\n parameter: { mesh: this.loaderManager.carManager.babylonWheelBodies[0]._children[0]._children[1] }\r\n },\r\n () => {\r\n if (!this.complete) {\r\n this.mazeInfo[MazeMap2.data[i][j].id].end = true;\r\n this.complete = true;\r\n this.setBallon(ballonPos);\r\n }\r\n }\r\n )\r\n );\r\n }\r\n this.tileCnt++;\r\n }\r\n }\r\n this.singleTile.setEnabled(false);\r\n this.tilecompoundBody.position.set(this.mapParent.position.x, 0, this.mapParent.position.z);\r\n this.worldManager.world.add(this.tilecompoundBody);\r\n this.worldManager.boxes.push({ pCube: this.tilecompoundBody, vCube: this.mapParent });\r\n this.arcCam.lockedTarget = this.mapParent;\r\n // this.arcCam.setTarget(this.mapParent);\r\n console.log(this.tileCnt);\r\n }\r\n createGround() {\r\n const groundShape = new CANNON.Plane();\r\n this.groundBody = new CANNON.Body({ mass: 0 });\r\n this.groundBody.position.set(0, 0, 0);\r\n this.groundBody.addShape(groundShape);\r\n this.groundBody.quaternion.setFromAxisAngle(new CANNON.Vec3(1, 0, 0), -Math.PI / 2)\r\n this.worldManager.world.add(this.groundBody);\r\n // this.worldManager.boxes.push({pCube:this.groundBody,vCube:this.ground});\r\n }\r\n createSingleTile(tilesize) {\r\n this.singleTile = new BABYLON.TransformNode(\"singletile\", this.scene);\r\n const tilemat = new BABYLON.StandardMaterial(\"namematerial\", this.scene);\r\n tilemat.diffuseColor = new BABYLON.Color3(197 / 255, 197 / 255, 197 / 255);\r\n tilemat.specularColor = new BABYLON.Color3(0, 0, 0);\r\n tilemat.emissiveColor = new BABYLON.Color3(0, 0, 0);\r\n this.groundTile = BABYLON.MeshBuilder.CreatePlane(\"groundplane\", { width: tilesize, height: tilesize, sideOrientation: BABYLON.Mesh.FRONTSIDE });\r\n this.groundTile.material = tilemat;\r\n this.groundTile.position.set(0, 0, 0);\r\n this.groundTile.rotation.x = Math.PI / 2;\r\n this.groundTile.parent = this.singleTile;\r\n\r\n const bordermat = new BABYLON.StandardMaterial(\"namematerial\", this.scene);\r\n bordermat.diffuseColor = new BABYLON.Color3(44 / 255, 156 / 255, 171 / 255);\r\n bordermat.specularColor = new BABYLON.Color3(0, 0, 0);\r\n bordermat.emissiveColor = new BABYLON.Color3(0, 0, 0);\r\n\r\n this.vborderRight = BABYLON.MeshBuilder.CreateBox(\"vtileRight\", { width: .2, height: 1, depth: tilesize }, this.scene);\r\n this.vborderRight.material = bordermat;\r\n this.vborderRight.position.set(-tilesize / 2, .5, 0);\r\n this.vborderRight.parent = this.singleTile;\r\n this.vborderRight.setEnabled(false);\r\n\r\n this.vborderLeft = this.vborderRight.clone(\"vtileleft\", this.singleTile);\r\n this.vborderLeft.material = bordermat.clone(\"vtileleftmat\");\r\n this.vborderLeft.position.set(tilesize / 2, .5, 0);\r\n this.vborderLeft.setEnabled(false);\r\n\r\n this.hborderDown = BABYLON.MeshBuilder.CreateBox(\"htileup\", { width: tilesize, height: 1, depth: .2 }, this.scene);\r\n this.hborderDown.material = bordermat.clone(\"htileupmat\");\r\n this.hborderDown.parent = this.singleTile;\r\n this.hborderDown.position.set(0, .5, tilesize / 2);\r\n this.hborderDown.setEnabled(false);\r\n\r\n this.hborderUp = this.hborderDown.clone(\"htiledown\", this.singleTile);\r\n this.hborderUp.material = bordermat.clone(\"htileupmat\");\r\n this.hborderUp.position.set(0, .5, -tilesize / 2);\r\n this.hborderUp.setEnabled(false);\r\n this.singleTile.position.set(0, 0, 0);\r\n // console.log(this.singleTile);\r\n }\r\n releaseScene() {\r\n // this.scene.removeTransformNode(this.singleTile);\r\n // this.singleTile.dispose();\r\n // this.scene.removeMesh(this.groundTile);\r\n // this.groundTile.dispose();\r\n // this.scene.removeMesh(this.vborderLeft);\r\n // this.vborderLeft.dispose();\r\n // this.scene.removeMesh(this.vborderRight);\r\n // this.vborderRight.dispose();\r\n // this.scene.removeMesh(this.hborderUp);\r\n // this.hborderUp.dispose();\r\n // this.scene.removeMesh(this.hborderDown);\r\n // this.hborderDown.dispose();\r\n // for(let i=0;i {\r\n // this.worldManager.world.remove(body); \r\n // });\r\n // }\r\n\r\n // this.worldManager.world.remove(this.groundBody);\r\n // this.worldManager.world.remove(this.tilecompoundBody);\r\n this.loaderManager.carManager.releaseRobot();\r\n this.game.releaseWorld();\r\n this.sceneCommon.release();\r\n this.scene.stopAllAnimations();\r\n this.scene.cleanCachedTextureBuffer();\r\n this.scene.clearCachedVertexData();\r\n }\r\n setBallon(ballonPos) {\r\n this.ballonObj = new BallonAnim(this.scene);\r\n const ballonsphere = BABYLON.MeshBuilder.CreateSphere(\"ballonsphere\", { diameter: .5 }, this.scene); //scene is \r\n let ballonmat = new BABYLON.StandardMaterial(\"ballonMat\", this.scene);\r\n ballonmat.diffuseColor = new BABYLON.Color3(1, 0, 0);\r\n ballonsphere.material = ballonmat;\r\n this.ballonObj.setBallonObj(ballonsphere);\r\n this.ballonObj.setBallonPos(ballonPos);\r\n }\r\n getMazeInfo() {\r\n return this.mazeInfo;\r\n }\r\n}\r\nfunction shuffle(array) {\r\n array.sort(() => Math.random() - 0.5);\r\n}\r\nconst random_hex_color_code = () => {\r\n let n = (Math.random() * 0xfffff * 1000000).toString(16);\r\n return '#' + n.slice(0, 6);\r\n};","import CANNON from 'cannon';\r\nimport Common from '../Common.js' \r\nimport WorldManager from '../WorldManager.js';\r\nimport LoaderManager from '../LoaderManager.js';\r\nimport FlameEffectGenerator from '../Effects/FlameEffectGenerator.js';\r\nimport { getJointDistance } from '../CarManager.js';\r\nexport class DemoScene{\r\n constructor(gameManager) {\r\n this.game = gameManager;\r\n this.sceneCommon = new Common(this.game);\r\n this.scene = this.sceneCommon.createScene(\"demoscene\");\r\n this.arcCam = this.sceneCommon.createCamera(this.scene);\r\n this.worldManager = new WorldManager(this.scene);\r\n this.loaderManager = new LoaderManager(this);\r\n this.loaderManager.initializeSceneAssets();\r\n this.game.engine.hideLoadingUI();\r\n this.createGround();\r\n setTimeout(() => {\r\n this.createPickObject(); \r\n }, 4000);\r\n }\r\n createGround(){\r\n const groundShape = new CANNON.Plane();\r\n this.groundBody = new CANNON.Body({ mass: 0 });\r\n this.groundBody.position.set(0,0,0);\r\n this.groundBody.addShape(groundShape);\r\n this.groundBody.quaternion.setFromAxisAngle(new CANNON.Vec3(1, 0, 0),-Math.PI/2)\r\n this.worldManager.world.add(this.groundBody);\r\n // this.worldManager.boxes.push({pCube:this.groundBody,vCube:this.ground});\r\n }\r\n \r\n createPickObject () {\r\n const size = .25;\r\n // const ballShape = new CANNON.Sphere(size);\r\n const shape = new CANNON.Box(new CANNON.Vec3(size*.5,size*.5,size*.5));\r\n const pickObject = new CANNON.Body({mass:.1,shape:shape,linearDamping:.5,angularDamping:.5,velocity:CANNON.Vec3.ZERO,\r\n angularVelocity:CANNON.Vec3.ZERO});\r\n pickObject.name = \"pick_body\";\r\n pickObject.position.set(5,2,0);\r\n pickObject.velocity.set(0,0,0);\r\n pickObject.angularVelocity.set(0,0,0);\r\n const physicmat = new CANNON.Material(\"ground_obj\");\r\n pickObject.material = physicmat;\r\n pickObject.material.restitution=0;\r\n pickObject.material.friction=1;\r\n const pick_box = BABYLON.MeshBuilder.CreateBox(\"pick_box\",{size:size},this.scene);\r\n this.worldManager.world.add(pickObject);\r\n this.worldManager.boxes.push({pCube: pickObject,vCube: pick_box});\r\n\r\n\r\n const shape2 = new CANNON.Cylinder(.15,.15,.7,4);\r\n const pickObject2 = new CANNON.Body({mass:.1,shape:shape2,linearDamping:.5,angularDamping:.5,velocity:CANNON.Vec3.ZERO,\r\n angularVelocity:CANNON.Vec3.ZERO});\r\n pickObject2.name = \"pick_body\";\r\n pickObject2.material = physicmat;\r\n pickObject2.material.restitution=0;\r\n pickObject2.material.friction=1;\r\n console.log(pickObject2.collisionFilterGroup+\" \"+pickObject2.collisionFilterMask);\r\n // pickObject2.quaternion.setFromAxisAngle(new CANNON.Vec3(1,0,0),Math.PI/2);\r\n const quat = new CANNON.Quaternion();\r\n quat.setFromAxisAngle(new CANNON.Vec3(-1,0,0),-Math.PI/2);\r\n const translation = new CANNON.Vec3(0,0,0);\r\n pickObject2.shapes[0].transformAllPoints(translation,quat);\r\n \r\n const pick_cylinder = BABYLON.MeshBuilder.CreateCylinder(\"pick_cylinder\",{diameter:.3,height:.7,subdivisions:4},this.scene);\r\n pick_cylinder.position.set(0,5,5);\r\n pick_cylinder.rotationQuaternion= new BABYLON.Quaternion.FromEulerAngles(0,0,0);\r\n pickObject2.position = (new CANNON.Vec3(pick_cylinder.position.x,pick_cylinder.position.y,pick_cylinder.position.z));\r\n this.worldManager.world.add(pickObject2);\r\n this.worldManager.boxes.push({pCube: pickObject2,vCube: pick_cylinder});\r\n\r\n // this.flameEffect = new FlameEffectGenerator(\"cc\",new BABYLON.Vector2(0,5),{ height:.7,diameter:.15}\r\n // ,\"#12e04c\",.5,true,1,this.worldManager,this.scene,this.loaderManager.carManager.robotBox); \r\n const friction = 1;\r\n const contactStiffness = 1e7;\r\n const contactRelaxation = 3;\r\n const frictionStiffness = 1e5;\r\n const frictionRelaxation = 10;\r\n const jointballcontactMaterial = new CANNON.ContactMaterial(physicmat, this.loaderManager.carManager.grabRight.contactMat, {\r\n friction: friction,\r\n restitution:0,\r\n contactEquationStiffness: contactStiffness,\r\n contactEquationRelaxation:contactRelaxation,\r\n frictionEquationStiffness:frictionStiffness,\r\n frictionEquationRelaxation:frictionRelaxation,\r\n });\r\n console.log(jointballcontactMaterial.contactEquationStiffness+\" !! contact!! \"+jointballcontactMaterial.contactEquationRelaxation);\r\n console.log(jointballcontactMaterial.frictionEquationStiffness+\" !! friction!! \"+jointballcontactMaterial.frictionEquationRelaxation);\r\n this.worldManager.world.addContactMaterial(jointballcontactMaterial);\r\n\r\n const jointballcontactMaterial2 = new CANNON.ContactMaterial(physicmat, this.loaderManager.carManager.grabLeft.contactMat, {\r\n friction: friction,\r\n restitution:0,\r\n contactEquationStiffness: contactStiffness, \r\n contactEquationRelaxation:contactRelaxation,\r\n frictionEquationStiffness:frictionStiffness,\r\n frictionEquationRelaxation:frictionRelaxation,\r\n });\r\n this.worldManager.world.addContactMaterial(jointballcontactMaterial2);\r\n let isPick=false;\r\n let joint=null;\r\n setInterval(() => {\r\n const value1 = this.loaderManager.carManager.bodiesAreInContact(this.loaderManager.carManager.grabRight.grabBody,pickObject2)\r\n const value2 = this.loaderManager.carManager.bodiesAreInContact(this.loaderManager.carManager.grabLeft.grabBody,pickObject2)\r\n if(value1 && value2){\r\n if(!isPick){\r\n console.log(\"!! in pick!!\");\r\n isPick = true;\r\n const force = 1e7;\r\n joint = new CANNON.HingeConstraint(this.loaderManager.carManager.jointCeter.grabBody,pickObject2,{\r\n pivotA:new CANNON.Vec3(0,0,0),\r\n axisA: new CANNON.Vec3(0,1,0),\r\n pivotB:new CANNON.Vec3(0,0,0),\r\n axisB: new CANNON.Vec3(0,1,0),\r\n maxForce:force,\r\n });\r\n joint.collideConnected=false;\r\n joint.enableMotor();\r\n joint.motorMaxForce = force;\r\n joint.motorMinForce = force;\r\n pickObject2.collisionFilterGroup=0;\r\n pickObject2.collisionFilterMask=0;\r\n this.worldManager.world.addConstraint(joint);\r\n }\r\n }\r\n if( getJointDistance()>.6 && isPick && joint){\r\n console.log(\"!! in relase!!\");\r\n pickObject2.collisionFilterGroup=1;\r\n pickObject2.collisionFilterMask=1;\r\n this.worldManager.world.removeConstraint(joint);\r\n joint = null;\r\n isPick = false;\r\n }\r\n\r\n },100); \r\n }\r\n}","export const UnitTypes = {\r\n cm: 10, // 1 cm equals 10 babylon unit\r\n mm: 100, // 1 mm equals to 1 babylon unit\r\n}\r\n\r\nexport function getValueByUnitType(value, unitType){\r\n switch (unitType) {\r\n default:\r\n case UnitTypes.cm:\r\n return Math.round(value * UnitTypes.cm).toFixed(0);\r\n case UnitTypes.mm:\r\n return Math.round(value * UnitTypes.mm).toFixed(0);\r\n }\r\n}","//Tags\r\nexport const EffectsTags = { //All environment modes\r\n flame : \"flame\",\r\n}\r\n\r\nexport const EnvironmentModeEnum = { //All environment modes\r\n standard:\"standard\",\r\n grid : \"grid\",\r\n line : \"line\",\r\n}\r\n\r\nexport const EnvironmentMode = EnvironmentModeEnum.standard; //Current environment mode\r\n\r\n//Grid\r\n//Note !! Square size = majorUnitFrequency * gridRatio = 5 mm !!\r\nexport const gridRatio = 0.5;\r\nexport const majorUnitFrequency = 10;\r\nexport const textHeight = 1;\r\n\r\n//LineGround\r\nexport const linePoints = [\r\n new BABYLON.Vector3(10, 0, 0),\r\n new BABYLON.Vector3(20, 0, 0),\r\n new BABYLON.Vector3(30, 0, 10),\r\n new BABYLON.Vector3(30, 0, 20),\r\n new BABYLON.Vector3(30, 0, 30),\r\n new BABYLON.Vector3(40, 0, 40),\r\n new BABYLON.Vector3(30, 0, 40),\r\n new BABYLON.Vector3(20, 0, 30),\r\n new BABYLON.Vector3(10, 0, 15),\r\n new BABYLON.Vector3(-20, 0, 40),\r\n new BABYLON.Vector3(-30, 0, 30),\r\n new BABYLON.Vector3(-40, 0, 20),\r\n new BABYLON.Vector3(-25, 0, 10),\r\n]\r\nexport const isClosedLine = true;\r\nexport const lineColor = new BABYLON.Color4(0, 1, 1, 1);\r\nexport const lineThickness = 1;\r\nexport const lineHeight = -.35;\r\n\r\n\r\n//Scene space\r\nexport const groundWidth = 67;\r\nexport const groundDepth = 50;\r\nexport const backGroundColor = \"#99CCFF\";\r\n\r\nexport const numberOfCubes = 10;\r\nexport const border = {\r\n height: 2,\r\n depth: 1,\r\n}\r\n\r\n//Car Manager\r\nexport const maxVelocity = 60;\r\nexport const maxForce = 200;\r\nexport const maxBrakeForce = maxForce*50;\r\nexport const robtotBodyMass= 100;\r\nexport const weheelBodyMass= 10;\r\nexport const GRAVITY=-20;\r\n//sensorsType\r\nexport const SensorTypes = { //All environment modes\r\n distance : \"distance\",\r\n color : \"color\",\r\n}\r\n\r\n//RatCast Manager\r\nexport const distanceRayLength = 40;\r\nexport const distanceRayTimeOut = 100000; //ms\r\n\r\nexport const surfaceRayLength = 3; //fixed\r\nexport const surfaceRayTimeOut = 100000; //ms\r\n\r\n\r\n//BoxConfig\r\nexport const boxConfing = {\r\n boxPosition : new BABYLON.Vector2(0, 1), //x-z\r\n height : 2,\r\n width : 2, //x\r\n depth : 2, //z\r\n boxHeight : .5,\r\n doorPercentage: 20,\r\n}\r\nexport const ballsCount = 5;\r\n\r\n//Not Used For Now \r\nexport const groundSize = 15;\r\nexport const groundOffsetX = 5;\r\nexport const groundOffsetZ = 5;\r\nexport const yOffset = 0;\r\n\r\nexport const events={candleDown:\"candleDown_eve\",boardDown:\"boardDown_eve\",setcandle_eve:\"setcandle_eve\",setrobotPos_eve:\"setrobotPos_eve\",candleRobotCollision:\"candleRobotCollision_eve\"\r\n,candleBlowOff:\"candleBlowOff_eve\",boardRobotCollision:\"boardRobotCollision_eve\",changemotor:\"changemotor_eve\",setrobot_angle:\"setrobot_angle_eve\"};\r\nexport const scaleFactor=.5;\r\nexport const groundY=-.0;\r\n\r\n\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","__webpack_require__.nc = undefined;","import \"./index.css\";\n\n\nimport {GameManger} from './scripts/GameManager';\nimport SceneManager from './scripts/SceneManager';\nexport let gameManager = undefined;\n\n//Start GameManger\n// GManager = new GameManger(\"game\"); \nlet buildVersion=2.4;\nwindow[\"startFireFighting\"] = startFireFighting;\nwindow[\"startMaze\"] = startMaze;\nwindow[\"getVersion\"] = getVersion;\nwindow[\"clearEngine\"] = clearEngine;\nlet sceneNo;\nconst sceneManager = new SceneManager();\nfunction startFireFighting(){\n // console.log(\"!! 111111111!!!\");\n sceneNo = sceneManager.sceneState.firefighting;\n if(gameManager !== undefined){\n if(gameManager.engine){\n console.log(gameManager.engine);\n releaseEngine();\n }\n }\n else{\n console.log(\"!! Fresh!!!\");\n gameManager = new GameManger(\"game\",sceneNo);\n }\n if(document.getElementById(\"start_game\")!== null)\n document.getElementById(\"start_game\").style.display = \"none\";\n if(document.getElementById(\"loader_spiner\"))\n document.getElementById(\"loader_spiner\").style.display = \"block\";\n}\nfunction startMaze(){\n // console.log(\"!! 111111111!!!\");\n sceneNo = sceneManager.sceneState.maze;\n if(gameManager !== undefined){\n if(gameManager.engine){\n console.log(gameManager.engine);\n releaseEngine();\n }\n }\n else{\n console.log(\"!! Fresh!!!\");\n gameManager = new GameManger(\"game\",sceneNo);\n }\n if(document.getElementById(\"start_game\")!== null)\n document.getElementById(\"start_game\").style.display = \"none\";\n if(document.getElementById(\"loader_spiner\"))\n document.getElementById(\"loader_spiner\").style.display = \"block\";\n}\nfunction releaseEngine(){\n console.log(\"!! 1111relaeseEngine111111 !!!\");\n gameManager.releaseWorld();\n if(gameManager.firefightingScene){\n gameManager.firefightingScene.releaseScene();\n gameManager.firefightingScene.scene.dispose();\n }\n if(gameManager.mazescene){\n gameManager.mazescene.releaseScene();\n gameManager.mazescene.scene.dispose();\n }\n gameManager.engine.dispose();\n gameManager.engine = null;\n gameManager = null;\n gameManager = new GameManger(\"game\",sceneNo);\n console.log(\"!! 22222relaeseEngine2222 !!!\");\n}\nfunction clearEngine(){\n console.log(\"!! clearEngine !!!\");\n gameManager.releaseWorld();\n if(gameManager.firefightingScene){\n gameManager.firefightingScene.releaseScene();\n gameManager.firefightingScene.scene.dispose();\n }\n if(gameManager.mazescene){\n gameManager.mazescene.releaseScene();\n gameManager.mazescene.scene.dispose();\n }\n gameManager.engine.dispose();\n gameManager.engine = null;\n console.log(\"!! clearEngine22222222 !!!\");\n}\nfunction getVersion(){\n return \"v_\"+buildVersion;\n}"],"names":[],"sourceRoot":""}