onBeforeCompile method

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://d3js.org/d3.v6.min.js"></script>
  </head>


  <image id="imgColor" href="https://i.ibb.co/z4C9ryg/Turbo-scheme-vertical.png" alt="Turbo-scheme-vertical" style="position:absolute;margin:5px;"></image>

  <script>
    const imgData = "https://i.ibb.co/z4C9ryg/Turbo-scheme-vertical.png";

  </script>

  <body>

    <script type="module">

      import * as THREE from 'https://threejsfundamentals.org/threejs/resources/threejs/r122/build/three.module.js';
        import { OrbitControls } from 'https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/controls/OrbitControls.js';
        import { ConvexBufferGeometry } from 'https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/geometries/ConvexGeometry.js';
        import Stats from 'https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/libs/stats.module.js'
        import { GUI } from 'https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/libs/dat.gui.module.js';
        import { VertexNormalsHelper } from 'https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/helpers/VertexNormalsHelper.js';
        import { STLLoader } from "https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/loaders/STLLoader.js";
        import { OBJLoader } from "https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/loaders/OBJLoader.js";
        import { GLTFLoader } from "https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/loaders/GLTFLoader.js";
        import { BufferGeometryUtils } from 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/utils/BufferGeometryUtils.js';
       ...