JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BABYLON Layer for MapBox</title>
<link href='https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl.css' rel='stylesheet' />
<script src='https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl-dev.js'></script>
<script src="https://cdn.babylonjs.com/babylon.js"></script>
<script src="https://cdn.jsdelivr.net/npm/babylonjs-loaders@4.1.0/babylonjs.loaders.js"></script>
<style>
html, body {
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
</body>
</html>
JavaScript
/** https://docs.mapbox.com/mapbox-gl-js/example/add-3d-model/ **/
mapboxgl.accessToken = '';
const center = [148.9819, -35.3981]
const map = (window.map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v10',
zoom: 18 ,
center : center,
pitch: 60,
antialias: true
}));
// modified from bjs matrix class
function mmultiply(mat1, mat2, result) {
const m = mat1;
const otherM = mat2;
const offset = 0;
var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15...