Robert Wildling
Robert Wildling

Reputation: 1186

Three.js on CodePen with PLYLoader

I am preparing a CodePen for a question about Three.js's PLYLoader. Unfortunately I cannot get the CodePen working, no matter how I include Three.js I keep geting the error "Three is not defined".

This is the Codepen:

https://codepen.io/rowild/pen/mdZobaw

Currently, the scripts are implemented in the HTML part of the pen, which I have seen in many other examples, too. The error will eventually show up in the codeblock that starts with

const init = (plyModel, plyModelName) => {

at around line 85ff.

I do not see my mistake – could you help me find it, please?

(The question I am going to ask, once the Pen works, is how I can delete a PointCloud before loading a new one.)

Upvotes: 0

Views: 126

Answers (1)

Łukasz Daniel Mastalerz
Łukasz Daniel Mastalerz

Reputation: 2217

Try like this

<script type="importmap">
  {
    "imports": {
      "three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
      "three/addons/": "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"
    }
  }
</script>

//...

import * as THREE from 'three';
import { PLYLoader } from 'three/addons/loaders/PLYLoader.js';

Upvotes: 0

Related Questions