Embedded JS in HTML and VS Code intellisense

When writing three code directly in a HTML file, either importing the lib with a cdn a locally, is it possible to have VS Code intellisense working?

I notice all examples are written with embedded HTML, for example:
three.js/examples/misc_controls_transform.html at 37d6f280a5cd642e801469bb048f52300d31258e · mrdoob/three.js · GitHub. Were these written with any intellisense?

The examples are written in the style they are because they are intended to be small units of functionality, and easy to examine the code without digging into multiple source files, but for anything of scale that you’re building, you really want some kind of tree of source code.

I think you’ll find that adding code directly in the HTML gets harder over time.

It’s best to include your “./main.js” as a type=‘module’ script tag, and then build off of there.
Or to have one script tag of type=‘module’ and import the main functionality inside that tag, from other source files.

(Check out how the HTML looks for the threejs editor… three.js editor

It has a main type=‘module’ tag, and then imports most of the functional code in there, and only has the highest level state machine and event hookups in the .html

Also chrome debugger/vscode has a hard time with breakpoints/editing and hot reloading when editing the .html directly.

Thanks for the reply - however, perhaps my question wasn’t clear.

Is it possible to setup VS Code Intellisense when writing threejs (or any JS code for that matter) in HTML?

I am writing examples for teaching purposes, so I am partial to having all code in a single file :slight_smile:

Ahh sorry I misunderstood.

I found this on a necropost here: https://www.youtube.com/watch?v=zBJXXcFy6iU

1 Like

Ah! Looks great! Look forward to trying it, thanks

1 Like