@needle-tools/gltf-progressive 1.0.0-alpha.17 → 1.0.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,7 +4,10 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [1.0.0-alpha.17] - 2023-05-30
7
+ ## [1.0.0-alpha.19] - 2023-05-31
8
+ - add `LODsManager.plugins` getter
9
+
10
+ ## [1.0.0-alpha.18] - 2023-05-30
8
11
  - update README
9
12
 
10
13
  ## [1.0.0-alpha.16] - 2023-05-29
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Support for loading of glTF or GLB files with progressive mesh or texture data for three.js based engines.
4
4
 
5
+
6
+
5
7
  ## Examples
6
8
 
7
9
  Examples are in the `/examples` directory. Live versions can be found in the links below.
@@ -11,6 +13,85 @@ Examples are in the `/examples` directory. Live versions can be found in the lin
11
13
  - [React Three Fiber](https://engine.needle.tools/demos/gltf-progressive/r3f/)
12
14
 
13
15
 
16
+ ## Usage
17
+
18
+ ### react three fiber
19
+
20
+ Full example in `examples/react-three-fiber`
21
+
22
+ ```ts
23
+ function ChurchModel() {
24
+ const { gl } = useThree()
25
+ const url = 'https://engine.needle.tools/demos/gltf-progressive/assets/church/model.glb'
26
+ const { scene } = useGLTF(url, false, false, (loader) => {
27
+ useNeedleProgressive(url, gl, loader as any)
28
+ })
29
+ return <primitive object={scene} />
30
+ }
31
+ ```
32
+
33
+ ### threejs (CDN, no bundler)
34
+
35
+ The full example can be found at `examples/threejs`
36
+
37
+ ```html
38
+ <head>
39
+ <!-- Add the threejs import map to your HTML head section -->
40
+ <script type="importmap">
41
+ {
42
+ "imports": {
43
+ "three": "https://cdn.jsdelivr.net/npm/three@latest/build/three.module.js",
44
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@latest/examples/jsm/",
45
+ "three/examples/": "https://cdn.jsdelivr.net/npm/three@latest/examples/",
46
+ "@needle-engine/gltf-progressive": "https://www.unpkg.com/@needle-tools/gltf-progressive@latest"
47
+ }
48
+ }
49
+ </script>
50
+ </head>
51
+ ```
52
+
53
+ In your script:
54
+ ```ts
55
+ const gltfLoader = new GLTFLoader();
56
+
57
+ const url = "https://engine.needle.tools/demos/gltf-progressive/assets/church/model.glb";
58
+
59
+ // register the progressive loader
60
+ useNeedleProgressive(url, renderer, gltfLoader)
61
+
62
+ // just call the load method as usual
63
+ gltfLoader.load(url, gltf => {
64
+ console.log(gltf)
65
+ scene.add(gltf.scene)
66
+ gltf.scene.position.y += .95;
67
+ })
68
+ ```
69
+
70
+
71
+ ### \<model-viewer\>
72
+
73
+ The full example can be found in `examples/modelviewer.html`
74
+
75
+ ```html
76
+ <head>
77
+ <!-- Include the import map and the gltf-progressive package -->
78
+ <script type="importmap">
79
+ {
80
+ "imports": {
81
+ "three": "https://unpkg.com/three/build/three.module.js",
82
+ "three/": "https://unpkg.com/three/"
83
+ }
84
+ }
85
+ </script>
86
+ <script type="module" src="https://www.unpkg.com/@needle-tools/gltf-progressive@latest"></script>
87
+ <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.4.0/model-viewer.min.js"></script>
88
+ </head>
89
+ <body>
90
+
91
+ <model-viewer src="https://engine.needle.tools/demos/gltf-progressive/assets/church/model.glb" camera-controls auto-rotate></model-viewer>
92
+
93
+ ...
94
+ ```
14
95
 
15
96
 
16
97
  # Contact ✒️
@@ -2,20 +2,18 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <link rel="icon" href="favicon.ico">
5
+ <link rel="icon" href="favicon.png">
6
6
  <meta name="viewport" content="width=device-width, user-scalable=no">
7
7
 
8
- <title>Made with Needle</title>
9
- <meta name="description" content="🌵 Made with Needle Engine">
8
+ <title>react-three-fiber with progressive loading</title>
9
+ <meta name="description" content="🌵 gltf-progressive example">
10
10
  <meta name="twitter:card" content="summary_large_image">
11
- <meta property="og:title" content="Made with Needle" />
12
- <meta property="og:description" content="🌵 Made with Needle Engine" />
13
-
11
+ <meta property="og:title" content="react-three-fiber with progressive loading" />
12
+ <meta property="og:description" content="🌵 gltf-progressive example" />
14
13
  <meta property="twitter:image" content="" />
15
14
  <meta property="og:image" content="" />
16
15
 
17
16
  <meta name="robots" content="index,follow">
18
- <meta name="url" content="http://needle.tools">
19
17
  <link rel="stylesheet" href="./src/style.css">
20
18
  </head>
21
19
 
@@ -23,12 +23,13 @@
23
23
  "@vitejs/plugin-basic-ssl": "^1.0.1",
24
24
  "@vitejs/plugin-react": "^1.3.0",
25
25
  "typescript": "4.1.3",
26
- "vite": "<= 4.3.9"
26
+ "vite": "<= 4.3.9",
27
+ "vite-plugin-compression": "^0.5.1"
27
28
  }
28
29
  },
29
30
  "../..": {
30
31
  "name": "@needle-tools/gltf-progressive",
31
- "version": "1.0.0-alpha.16",
32
+ "version": "1.0.0-alpha.17",
32
33
  "devDependencies": {
33
34
  "@stylistic/eslint-plugin-ts": "^1.5.4",
34
35
  "@types/three": "0.162.0",
@@ -1515,6 +1516,20 @@
1515
1516
  "version": "0.6.10",
1516
1517
  "license": "MIT"
1517
1518
  },
1519
+ "node_modules/fs-extra": {
1520
+ "version": "10.1.0",
1521
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
1522
+ "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
1523
+ "dev": true,
1524
+ "dependencies": {
1525
+ "graceful-fs": "^4.2.0",
1526
+ "jsonfile": "^6.0.1",
1527
+ "universalify": "^2.0.0"
1528
+ },
1529
+ "engines": {
1530
+ "node": ">=12"
1531
+ }
1532
+ },
1518
1533
  "node_modules/fsevents": {
1519
1534
  "version": "2.3.3",
1520
1535
  "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@@ -1560,6 +1575,12 @@
1560
1575
  "version": "0.0.0",
1561
1576
  "license": "MIT"
1562
1577
  },
1578
+ "node_modules/graceful-fs": {
1579
+ "version": "4.2.11",
1580
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
1581
+ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
1582
+ "dev": true
1583
+ },
1563
1584
  "node_modules/has-flag": {
1564
1585
  "version": "3.0.0",
1565
1586
  "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
@@ -1682,6 +1703,18 @@
1682
1703
  "node": ">=6"
1683
1704
  }
1684
1705
  },
1706
+ "node_modules/jsonfile": {
1707
+ "version": "6.1.0",
1708
+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
1709
+ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
1710
+ "dev": true,
1711
+ "dependencies": {
1712
+ "universalify": "^2.0.0"
1713
+ },
1714
+ "optionalDependencies": {
1715
+ "graceful-fs": "^4.1.6"
1716
+ }
1717
+ },
1685
1718
  "node_modules/lie": {
1686
1719
  "version": "3.3.0",
1687
1720
  "license": "MIT",
@@ -2211,6 +2244,15 @@
2211
2244
  "optional": true,
2212
2245
  "peer": true
2213
2246
  },
2247
+ "node_modules/universalify": {
2248
+ "version": "2.0.1",
2249
+ "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
2250
+ "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
2251
+ "dev": true,
2252
+ "engines": {
2253
+ "node": ">= 10.0.0"
2254
+ }
2255
+ },
2214
2256
  "node_modules/update-browserslist-db": {
2215
2257
  "version": "1.0.13",
2216
2258
  "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz",
@@ -2314,6 +2356,90 @@
2314
2356
  }
2315
2357
  }
2316
2358
  },
2359
+ "node_modules/vite-plugin-compression": {
2360
+ "version": "0.5.1",
2361
+ "resolved": "https://registry.npmjs.org/vite-plugin-compression/-/vite-plugin-compression-0.5.1.tgz",
2362
+ "integrity": "sha512-5QJKBDc+gNYVqL/skgFAP81Yuzo9R+EAf19d+EtsMF/i8kFUpNi3J/H01QD3Oo8zBQn+NzoCIFkpPLynoOzaJg==",
2363
+ "dev": true,
2364
+ "dependencies": {
2365
+ "chalk": "^4.1.2",
2366
+ "debug": "^4.3.3",
2367
+ "fs-extra": "^10.0.0"
2368
+ },
2369
+ "peerDependencies": {
2370
+ "vite": ">=2.0.0"
2371
+ }
2372
+ },
2373
+ "node_modules/vite-plugin-compression/node_modules/ansi-styles": {
2374
+ "version": "4.3.0",
2375
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
2376
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
2377
+ "dev": true,
2378
+ "dependencies": {
2379
+ "color-convert": "^2.0.1"
2380
+ },
2381
+ "engines": {
2382
+ "node": ">=8"
2383
+ },
2384
+ "funding": {
2385
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
2386
+ }
2387
+ },
2388
+ "node_modules/vite-plugin-compression/node_modules/chalk": {
2389
+ "version": "4.1.2",
2390
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
2391
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
2392
+ "dev": true,
2393
+ "dependencies": {
2394
+ "ansi-styles": "^4.1.0",
2395
+ "supports-color": "^7.1.0"
2396
+ },
2397
+ "engines": {
2398
+ "node": ">=10"
2399
+ },
2400
+ "funding": {
2401
+ "url": "https://github.com/chalk/chalk?sponsor=1"
2402
+ }
2403
+ },
2404
+ "node_modules/vite-plugin-compression/node_modules/color-convert": {
2405
+ "version": "2.0.1",
2406
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
2407
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
2408
+ "dev": true,
2409
+ "dependencies": {
2410
+ "color-name": "~1.1.4"
2411
+ },
2412
+ "engines": {
2413
+ "node": ">=7.0.0"
2414
+ }
2415
+ },
2416
+ "node_modules/vite-plugin-compression/node_modules/color-name": {
2417
+ "version": "1.1.4",
2418
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
2419
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
2420
+ "dev": true
2421
+ },
2422
+ "node_modules/vite-plugin-compression/node_modules/has-flag": {
2423
+ "version": "4.0.0",
2424
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
2425
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
2426
+ "dev": true,
2427
+ "engines": {
2428
+ "node": ">=8"
2429
+ }
2430
+ },
2431
+ "node_modules/vite-plugin-compression/node_modules/supports-color": {
2432
+ "version": "7.2.0",
2433
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
2434
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
2435
+ "dev": true,
2436
+ "dependencies": {
2437
+ "has-flag": "^4.0.0"
2438
+ },
2439
+ "engines": {
2440
+ "node": ">=8"
2441
+ }
2442
+ },
2317
2443
  "node_modules/webgl-constants": {
2318
2444
  "version": "1.1.1"
2319
2445
  },
@@ -3291,6 +3417,17 @@
3291
3417
  "fflate": {
3292
3418
  "version": "0.6.10"
3293
3419
  },
3420
+ "fs-extra": {
3421
+ "version": "10.1.0",
3422
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
3423
+ "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
3424
+ "dev": true,
3425
+ "requires": {
3426
+ "graceful-fs": "^4.2.0",
3427
+ "jsonfile": "^6.0.1",
3428
+ "universalify": "^2.0.0"
3429
+ }
3430
+ },
3294
3431
  "fsevents": {
3295
3432
  "version": "2.3.3",
3296
3433
  "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@@ -3319,6 +3456,12 @@
3319
3456
  "glsl-noise": {
3320
3457
  "version": "0.0.0"
3321
3458
  },
3459
+ "graceful-fs": {
3460
+ "version": "4.2.11",
3461
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
3462
+ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
3463
+ "dev": true
3464
+ },
3322
3465
  "has-flag": {
3323
3466
  "version": "3.0.0",
3324
3467
  "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
@@ -3392,6 +3535,16 @@
3392
3535
  "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
3393
3536
  "dev": true
3394
3537
  },
3538
+ "jsonfile": {
3539
+ "version": "6.1.0",
3540
+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
3541
+ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
3542
+ "dev": true,
3543
+ "requires": {
3544
+ "graceful-fs": "^4.1.6",
3545
+ "universalify": "^2.0.0"
3546
+ }
3547
+ },
3395
3548
  "lie": {
3396
3549
  "version": "3.3.0",
3397
3550
  "requires": {
@@ -3744,6 +3897,12 @@
3744
3897
  "optional": true,
3745
3898
  "peer": true
3746
3899
  },
3900
+ "universalify": {
3901
+ "version": "2.0.1",
3902
+ "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
3903
+ "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
3904
+ "dev": true
3905
+ },
3747
3906
  "update-browserslist-db": {
3748
3907
  "version": "1.0.13",
3749
3908
  "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz",
@@ -3776,6 +3935,68 @@
3776
3935
  "rollup": "^3.21.0"
3777
3936
  }
3778
3937
  },
3938
+ "vite-plugin-compression": {
3939
+ "version": "0.5.1",
3940
+ "resolved": "https://registry.npmjs.org/vite-plugin-compression/-/vite-plugin-compression-0.5.1.tgz",
3941
+ "integrity": "sha512-5QJKBDc+gNYVqL/skgFAP81Yuzo9R+EAf19d+EtsMF/i8kFUpNi3J/H01QD3Oo8zBQn+NzoCIFkpPLynoOzaJg==",
3942
+ "dev": true,
3943
+ "requires": {
3944
+ "chalk": "^4.1.2",
3945
+ "debug": "^4.3.3",
3946
+ "fs-extra": "^10.0.0"
3947
+ },
3948
+ "dependencies": {
3949
+ "ansi-styles": {
3950
+ "version": "4.3.0",
3951
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
3952
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
3953
+ "dev": true,
3954
+ "requires": {
3955
+ "color-convert": "^2.0.1"
3956
+ }
3957
+ },
3958
+ "chalk": {
3959
+ "version": "4.1.2",
3960
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
3961
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
3962
+ "dev": true,
3963
+ "requires": {
3964
+ "ansi-styles": "^4.1.0",
3965
+ "supports-color": "^7.1.0"
3966
+ }
3967
+ },
3968
+ "color-convert": {
3969
+ "version": "2.0.1",
3970
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
3971
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
3972
+ "dev": true,
3973
+ "requires": {
3974
+ "color-name": "~1.1.4"
3975
+ }
3976
+ },
3977
+ "color-name": {
3978
+ "version": "1.1.4",
3979
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
3980
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
3981
+ "dev": true
3982
+ },
3983
+ "has-flag": {
3984
+ "version": "4.0.0",
3985
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
3986
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
3987
+ "dev": true
3988
+ },
3989
+ "supports-color": {
3990
+ "version": "7.2.0",
3991
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
3992
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
3993
+ "dev": true,
3994
+ "requires": {
3995
+ "has-flag": "^4.0.0"
3996
+ }
3997
+ }
3998
+ }
3999
+ },
3779
4000
  "webgl-constants": {
3780
4001
  "version": "1.1.1"
3781
4002
  },
@@ -18,7 +18,8 @@
18
18
  "@vitejs/plugin-basic-ssl": "^1.0.1",
19
19
  "@vitejs/plugin-react": "^1.3.0",
20
20
  "typescript": "4.1.3",
21
- "vite": "<= 4.3.9"
21
+ "vite": "<= 4.3.9",
22
+ "vite-plugin-compression": "^0.5.1"
22
23
  },
23
24
  "scripts": {
24
25
  "start": "vite --host",
@@ -2,6 +2,7 @@ import * as path from 'path';
2
2
  import { defineConfig } from 'vite';
3
3
  import react from '@vitejs/plugin-react';
4
4
  import basicSsl from '@vitejs/plugin-basic-ssl'
5
+ import viteCompression from 'vite-plugin-compression';
5
6
 
6
7
  export default defineConfig(async (command) => {
7
8
 
@@ -13,6 +14,7 @@ export default defineConfig(async (command) => {
13
14
  plugins: [
14
15
  react(),
15
16
  basicSsl(),
17
+ viteCompression({ deleteOriginFile: true }),
16
18
  ],
17
19
 
18
20
  server: {
@@ -20,19 +22,12 @@ export default defineConfig(async (command) => {
20
22
  proxy: { // workaround: specifying a proxy skips HTTP2 which is currently problematic in Vite since it causes session memory timeouts.
21
23
  'https://localhost:3000': 'https://localhost:3000'
22
24
  },
23
- watch: {
24
- awaitWriteFinish: {
25
- stabilityThreshold: 500,
26
- pollInterval: 1000
27
- },
28
- },
29
25
  strictPort: true,
30
26
  port: 3001
31
27
  },
32
28
  build: {
33
29
  outDir: "./dist",
34
30
  emptyOutDir: true,
35
- keepNames: true,
36
31
  },
37
32
  resolve: {
38
33
  alias: {
@@ -46,7 +46,7 @@ function xe(a) {
46
46
  function we(a, e) {
47
47
  (a.type === "Mesh" || a.type === "SkinnedMesh") && (a.userData || (a.userData = {}), a.userData["needle:raycast-mesh"] = e);
48
48
  }
49
- const G = new Array(), E = "NEEDLE_progressive", v = ee("debugprogressive"), H = Symbol("needle-progressive-texture"), N = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Set();
49
+ const E = new Array(), I = "NEEDLE_progressive", v = ee("debugprogressive"), H = Symbol("needle-progressive-texture"), N = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Set();
50
50
  if (v) {
51
51
  let a = function() {
52
52
  e += 1, console.log("Toggle LOD level", e, N), N.forEach((i, n) => {
@@ -84,7 +84,7 @@ const O = class {
84
84
  }
85
85
  /** The name of the extension */
86
86
  get name() {
87
- return E;
87
+ return I;
88
88
  }
89
89
  static getMeshLODInformation(e) {
90
90
  const t = this.getAssignedLODInformation(e);
@@ -141,7 +141,7 @@ const O = class {
141
141
  const i = e.geometry, n = this.getAssignedLODInformation(i);
142
142
  if (!n)
143
143
  return Promise.resolve(null);
144
- for (const s of G)
144
+ for (const s of E)
145
145
  (r = s.onBeforeGetLODMesh) == null || r.call(s, e, t);
146
146
  return e["LOD:requested level"] = t, O.getOrLoadLOD(i, t).then((s) => {
147
147
  if (e["LOD:requested level"] === t) {
@@ -220,7 +220,7 @@ const O = class {
220
220
  var t, r;
221
221
  return v && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, n) => {
222
222
  if (i != null && i.extensions) {
223
- const s = i == null ? void 0 : i.extensions[E];
223
+ const s = i == null ? void 0 : i.extensions[I];
224
224
  if (s) {
225
225
  let o = !1;
226
226
  for (const l of this.parser.associations.keys())
@@ -232,7 +232,7 @@ const O = class {
232
232
  }
233
233
  }), (r = this.parser.json.meshes) == null || r.forEach((i, n) => {
234
234
  if (i != null && i.extensions) {
235
- const s = i == null ? void 0 : i.extensions[E];
235
+ const s = i == null ? void 0 : i.extensions[I];
236
236
  if (s && s.lods) {
237
237
  for (const o of this.parser.associations.keys())
238
238
  if (o.isMesh) {
@@ -295,7 +295,7 @@ const O = class {
295
295
  let m = !1;
296
296
  for (const d of y.parser.json.textures) {
297
297
  if (d != null && d.extensions) {
298
- const M = d == null ? void 0 : d.extensions[E];
298
+ const M = d == null ? void 0 : d.extensions[I];
299
299
  if (M != null && M.guid && M.guid === L.guid) {
300
300
  m = !0;
301
301
  break;
@@ -313,7 +313,7 @@ const O = class {
313
313
  let m = !1;
314
314
  for (const d of y.parser.json.meshes) {
315
315
  if (d != null && d.extensions) {
316
- const M = d == null ? void 0 : d.extensions[E];
316
+ const M = d == null ? void 0 : d.extensions[I];
317
317
  if (M != null && M.guid && M.guid === L.guid) {
318
318
  m = !0;
319
319
  break;
@@ -329,9 +329,9 @@ const O = class {
329
329
  } else {
330
330
  const _ = new Array();
331
331
  for (let B = 0; B < d.children.length; B++) {
332
- const I = d.children[B];
333
- if (I instanceof X) {
334
- const $ = I.geometry;
332
+ const G = d.children[B];
333
+ if (G instanceof X) {
334
+ const $ = G.geometry;
335
335
  O.assignLODInformation(i.url, $, n, t, B, M.density), _.push($);
336
336
  }
337
337
  }
@@ -385,7 +385,7 @@ u(S, "registerMesh", (e, t, r, i, n, s) => {
385
385
  o.userData || (o.userData = {}), O.assignLODInformation(e, o, t, i, n, s.density), O.lodInfos.set(t, s);
386
386
  let l = O.lowresCache.get(t);
387
387
  l ? l.push(r.geometry) : l = [r.geometry], O.lowresCache.set(t, l), i > 0 && !xe(r) && we(r, o);
388
- for (const f of G)
388
+ for (const f of E)
389
389
  (g = f.onRegisteredNewMesh) == null || g.call(f, r, s);
390
390
  }), /** A map of key = asset uuid and value = LOD information */
391
391
  u(S, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
@@ -441,11 +441,11 @@ const J = ee("debugprogressive"), Me = ee("noprogressive"), ie = Symbol("Needle:
441
441
  return (t = e.userData) == null ? void 0 : t.LOD_state;
442
442
  }
443
443
  static addPlugin(e) {
444
- G.push(e);
444
+ E.push(e);
445
445
  }
446
446
  static removePlugin(e) {
447
- const t = G.indexOf(e);
448
- t >= 0 && G.splice(t, 1);
447
+ const t = E.indexOf(e);
448
+ t >= 0 && E.splice(t, 1);
449
449
  }
450
450
  /**
451
451
  * Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
@@ -455,6 +455,10 @@ const J = ee("debugprogressive"), Me = ee("noprogressive"), ie = Symbol("Needle:
455
455
  static get(e) {
456
456
  return e[ie] ? e[ie] : new P(e);
457
457
  }
458
+ /** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
459
+ get plugins() {
460
+ return E;
461
+ }
458
462
  /**
459
463
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
460
464
  */
@@ -517,7 +521,7 @@ const J = ee("debugprogressive"), Me = ee("noprogressive"), ie = Symbol("Needle:
517
521
  /** Update the LOD levels for the renderer. */
518
522
  updateLODs(e, t, r, i) {
519
523
  var l, g;
520
- for (const f of G)
524
+ for (const f of E)
521
525
  (l = f.onBeforeUpdateLOD) == null || l.call(f, this.renderer, e, t, r);
522
526
  let n = r.userData.LOD_state;
523
527
  n || (n = new ve(), r.userData.LOD_state = n);
@@ -532,7 +536,7 @@ const J = ee("debugprogressive"), Me = ee("noprogressive"), ie = Symbol("Needle:
532
536
  else
533
537
  this.loadProgressiveTextures(r.material, o);
534
538
  }
535
- for (const f of G)
539
+ for (const f of E)
536
540
  (g = f.onAfterUpdatedLOD) == null || g.call(f, this.renderer, e, t, r, s);
537
541
  n.lastLodLevel = s;
538
542
  }
@@ -591,8 +595,8 @@ const J = ee("debugprogressive"), Me = ee("noprogressive"), ie = Symbol("Needle:
591
595
  if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && p.fov > 70) {
592
596
  const D = this._tempBox.min, y = this._tempBox.max;
593
597
  let T = D.x, w = D.y, m = y.x, d = y.y;
594
- const M = 2, _ = 1.5, B = (D.x + y.x) * 0.5, I = (D.y + y.y) * 0.5;
595
- T = (T - B) * M + B, w = (w - I) * M + I, m = (m - B) * M + B, d = (d - I) * M + I;
598
+ const M = 2, _ = 1.5, B = (D.x + y.x) * 0.5, G = (D.y + y.y) * 0.5;
599
+ T = (T - B) * M + B, w = (w - G) * M + G, m = (m - B) * M + B, d = (d - G) * M + G;
596
600
  const $ = T < 0 && m > 0 ? 0 : Math.min(Math.abs(D.x), Math.abs(y.x)), le = w < 0 && d > 0 ? 0 : Math.min(Math.abs(D.y), Math.abs(y.y)), V = Math.max($, le);
597
601
  r.lastCentrality = (_ - V) * (_ - V) * (_ - V);
598
602
  } else
@@ -694,8 +698,8 @@ class Te {
694
698
  console.warn("Texture data not found for texture index " + A);
695
699
  continue;
696
700
  }
697
- if ((p = C == null ? void 0 : C.extensions) != null && p[E]) {
698
- const x = C.extensions[E];
701
+ if ((p = C == null ? void 0 : C.extensions) != null && p[I]) {
702
+ const x = C.extensions[I];
699
703
  x && i && S.registerTexture(i, L, x.lods.length, x);
700
704
  }
701
705
  }
@@ -717,7 +721,7 @@ class Te {
717
721
  const r = this.getUrl();
718
722
  if (!r)
719
723
  return;
720
- const i = (s = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : s[E];
724
+ const i = (s = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : s[I];
721
725
  if (i && r) {
722
726
  const o = t.uuid;
723
727
  S.registerMesh(r, o, t, 0, i.lods.length, i);
@@ -733,7 +737,7 @@ document.addEventListener("DOMContentLoaded", () => {
733
737
  Se(document.querySelector("model-viewer"));
734
738
  });
735
739
  export {
736
- E as EXTENSION_NAME,
740
+ I as EXTENSION_NAME,
737
741
  b as LODsManager,
738
742
  S as NEEDLE_progressive,
739
743
  ae as addDracoAndKTX2Loaders,