Skip to content

Use three.js in google web app script – not able to use the script module type to load three.js

I would like to use three.js in the google web script to load 3D CAD file, while in the installation instruction on it explains the script need to be “module” type. At the same time, it looks like the google web app script does not support the “module” after I googled around for several days.

Is there anyone ever used three.js for google script? Thanks a lot for sharing your experience. otherwise I have to give up my idea to load CAD data on the web app I am building.

<script type="module">

  // Find the latest version by visiting The URL will
  // redirect to the newest stable release.
  import * as THREE from '';

  const scene = new THREE.Scene();




Modules are not supported with Apps Script


Caution: ES6 modules are not yet supported.

You can however call the script like you would a library such as jQuery.

<script src=""></script>

Web App Example

function doGet(){
 HTMLOutput = HtmlService.createHtmlOutputFromFile('index.html')
 return HTMLOutput


<!DOCTYPE html>
        <title>My first three.js app</title>
            body { margin: 0; }
        <script src=""></script>
            const scene = new THREE.Scene();
            const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

            const renderer = new THREE.WebGLRenderer();
            renderer.setSize( window.innerWidth, window.innerHeight );
            document.body.appendChild( renderer.domElement );

            const geometry = new THREE.BoxGeometry();
            const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
            const cube = new THREE.Mesh( geometry, material );
            scene.add( cube );

            camera.position.z = 5;

            const animate = function () {
                requestAnimationFrame( animate );

                cube.rotation.x += 0.01;
                cube.rotation.y += 0.01;

                renderer.render( scene, camera );


Adapted from:


When deploying this as a Web App I get this result:

enter image description here


1 People found this is helpful