Why does <script type="module"> not work?

Hi, am a complete three.js beginner -
and maybe this is a fundatmental missunderstanding,
but:
can you help me what’s wrong with this code (placed in a wordpress page),
the javascirpt code in the type="module part will not be executed:

thank you ! (sorry for the fomatting on my old pc -
i had to insert a blank before each “script”- tag and to XXX-out the links)

<php get_header(); ?>
<?php  get_footer(); ?>

< script  src=http://haho.dreampress.at/wp-content/themes/twentyfourteen/js/three.min.js>< /script>

< script type="module">
	
$j("#main").append('< canvas id="canvas" width="500" height="500" style="background:pink;">< /canvas>');

import * as THREE      from  'XXXhttp://haho.dreampress.at/wp-content/themes/twentyfourteen/js/module.js' ;

import {OrbitControls } from 'XXXhttp://haho.dreampress.at/wp-content/themes/twentyfourteen/js/OrbitControls.js';

import { OBJLoader2 }    from "XXXhttp://haho.dreampress.at/wp-content/themes/twentyfourteen/js/OBJLoader2.js";

import { MTLLoader }     from "XXXhttp://haho.dreampress.at/wp-content/themes/twentyfourteen/js/MTLLoader.js";

import { MtlObjBridge }  from "XXXhttp://haho.dreampress.at/wp-content/themes/twentyfourteen/js//MtlObjBridge.js";

function main() 
......
main();

Are you able to share a live link to your application?

Does it work if you load the JS files like so:

import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.119/build/three.module.js' ;
import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/three@0.119/examples/jsm/controls/OrbitControls.js';
import { OBJLoader2 } from "https://cdn.jsdelivr.net/npm/three@0.119/examples/jsm/loaders/OBJLoader2.js";
import { MTLLoader } from "https://cdn.jsdelivr.net/npm/three@0.119/examples/jsm/loaders/MTLLoader.js";
import { MtlObjBridge } from "https://cdn.jsdelivr.net/npm/three@0.119/examples/jsm/loaders/obj2/bridge/MtlObjBridge.js";

yes:

http://haho.dreampress.at/webgl001/

thank you - i’ll_try your suggestion

Phantastic - it works now on my smartphone google browser !

thank’s al lot !

1 Like

Yep, looks good!