Skip to content

Commit dcb51cb

Browse files
authored
Update the es-module example (#168)
1 parent c750582 commit dcb51cb

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ The library supports [three.js](https://threejs.org/) r160 and uses its GLTF, Dr
8585
Refer to the `browserslist` field in [package.json](./package.json) for target browsers.
8686

8787
### 1. ES Module
88-
Download [dist/three-loader-3dtiles.esm.min.js](dist/three-loader-3dtiles.esm.min.js) and use an `importmap` to import the dependencies. See [here](examples/installation/es-module) for a full example.
88+
Use an `importmap` to import the dependencies from the npm. See [here](examples/installation/es-module) for a full example.
8989

9090
#### **`index.html`**
9191
```html
@@ -94,7 +94,7 @@ Download [dist/three-loader-3dtiles.esm.min.js](dist/three-loader-3dtiles.esm.mi
9494
"imports": {
9595
"three": "https://unpkg.com/[email protected]/build/three.module.js",
9696
"three/examples/jsm/": "https://unpkg.com/[email protected]/examples/jsm/",
97-
"three-loader-3dtiles" : "../../../../dist/lib/three-loader-3dtiles.js"
97+
"three-loader-3dtiles" : "https://unpkg.com/three-loader-3dtiles/dist/lib/three-loader-3dtiles.js"
9898
}
9999
}
100100
</script>

examples/installation/es-module/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"imports": {
1111
"three": "https://unpkg.com/[email protected]/build/three.module.js",
1212
"three/examples/jsm/": "https://unpkg.com/[email protected]/examples/jsm/",
13-
"three-loader-3dtiles" : "../../../../dist/lib/three-loader-3dtiles.js"
13+
"three-loader-3dtiles" : "https://unpkg.com/three-loader-3dtiles/dist/lib/three-loader-3dtiles.js"
1414
}
1515
}
1616
</script>

examples/installation/es-module/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Clock,
1212
SRGBColorSpace,
1313
GridHelper,
14-
AmbientLight
14+
Vector2,
1515
} from 'three'
1616

1717
const scene = new Scene()
@@ -34,6 +34,8 @@ canvasParent.appendChild(renderer.domElement);
3434

3535
let tilesRuntime = undefined;
3636

37+
const viewportSize = new Vector2();
38+
3739

3840
async function loadTileset() {
3941
const result = await Loader3DTiles.load(
@@ -43,6 +45,7 @@ async function loadTileset() {
4345
options: {
4446
dracoDecoderPath: 'https://unpkg.com/[email protected]/examples/jsm/libs/draco',
4547
basisTranscoderPath: 'https://unpkg.com/[email protected]/examples/jsm/libs/basis',
48+
resetTransform: true,
4649
debug: true
4750
}
4851
}
@@ -60,14 +63,15 @@ function render() {
6063
const dt = clock.getDelta()
6164
controls.update();
6265
if (tilesRuntime) {
63-
tilesRuntime.update(dt, canvasParent.clientHeight, camera)
66+
tilesRuntime.update(dt, viewportSize, camera)
6467
}
6568
renderer.render(scene, camera)
6669
window.requestAnimationFrame(render)
6770
}
6871

6972
function onWindowResize() {
7073
renderer.setSize(canvasParent.clientWidth, canvasParent.clientHeight);
74+
renderer.getSize(viewportSize)
7175
camera.aspect = canvasParent.clientWidth / canvasParent.clientHeight;
7276
camera.updateProjectionMatrix();
7377
}

src/util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { Tile3D } from '@loaders.gl/tiles';
2525
import { Plane as MathGLPlane } from '@math.gl/culling';
2626
import { Matrix3 as MathGLMatrix3 } from '@math.gl/core';
2727
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils'
28-
2928
import { Gradient } from './gradients'
3029

3130
// From https://github.com/potree/potree/blob/master/src/materials/PointCloudMaterial.js

0 commit comments

Comments
 (0)