three-low-poly 0.9.17 → 0.9.18

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/dist/index.d.ts CHANGED
@@ -45,6 +45,48 @@ export declare function addWaterDisplacement<T extends Material>(material: T, {
45
45
  waveAmplitude?: number | undefined;
46
46
  }): void;
47
47
 
48
+ /**
49
+ * Generates spherical curve profile points, for use with geometry.
50
+ * Enables connective geometry via holes at the top and bottom of the sphere.
51
+ *
52
+ * Example usage:
53
+ *
54
+ * Tube that connect with a sphere on the bottom:
55
+ * ```
56
+ * const points: Vector2[] = [
57
+ * new Vector2(1, 0),
58
+ * ...appendSphericalCurve(
59
+ * 2, // Radius x
60
+ * 2, // Radius y
61
+ * 5, // Start y
62
+ * 0, // Hole top radius
63
+ * 1, // Hole bottom radius
64
+ * 32, // Segments
65
+ * ),
66
+ * ];
67
+ *
68
+ * const latheGeometry = new LatheGeometry(points, 32);
69
+ * ```
70
+ *
71
+ * Tube that connect with a sphere on the top:
72
+ * ```
73
+ * const points: Vector2[] = [
74
+ * ...appendSphericalCurve(
75
+ * 2, // Radius x
76
+ * 2, // Radius y
77
+ * 1, // Start y
78
+ * 1, // Hole top radius
79
+ * 0, // Hole bottom radius
80
+ * 32, // Segments
81
+ * ),
82
+ * new Vector2(1, 5),
83
+ * ];
84
+ *
85
+ * const latheGeometry = new LatheGeometry(points, 32);
86
+ * ```
87
+ */
88
+ export declare function appendSphericalCurve(sphereRadiusX: number, sphereRadiusY: number, sphereStartY: number, holeTopRadius?: number, holeBottomRadius?: number, segments?: number): Vector2[];
89
+
48
90
  /**
49
91
  * Atmospheric scattering shader.
50
92
  *
@@ -439,6 +481,100 @@ export declare function calculateXFromSlopeIntercept(x1: number, y1: number, x2:
439
481
  */
440
482
  export declare function calculateYFromSlopeIntercept(x1: number, y1: number, x2: number, y2: number, x: number): number;
441
483
 
484
+ /**
485
+ * Dolly backward
486
+ *
487
+ * Example:
488
+ * ```
489
+ * dollyAnimation(camera, 5, 3000, () => {
490
+ * console.log("Dolly animation complete");
491
+ * });
492
+ * ```
493
+ */
494
+ export declare function cameraDollyAnimation(camera: Camera, distance: number, duration: number, onComplete?: () => void): void;
495
+
496
+ /**
497
+ * The camera flies through a sequence of points, ideal for showcasing specific elements in the scene.
498
+ *
499
+ * Example:
500
+ * ```
501
+ * flythroughAnimation(
502
+ * camera,
503
+ * [
504
+ * new THREE.Vector3(0, 5, 5),
505
+ * new THREE.Vector3(0, 5, -25.5),
506
+ * new THREE.Vector3(-20.5, 5, 0),
507
+ * ],
508
+ * 6000,
509
+ * () => {
510
+ * console.log("Flythrough animation complete");
511
+ * }
512
+ * );
513
+ * ```
514
+ */
515
+ export declare function cameraFlythroughAnimation(camera: Camera, waypoints: Vector3[], duration: number, onComplete?: () => void): void;
516
+
517
+ /**
518
+ * Orbit around a target
519
+ *
520
+ * Example:
521
+ * ```
522
+ * orbitAnimation(camera, new THREE.Vector3(0, 0, 0), 10, 5000, () => {
523
+ * console.log("Orbit animation complete");
524
+ * });
525
+ * ```
526
+ */
527
+ export declare function cameraOrbitAnimation(camera: Camera, target: Vector3, radius: number, duration: number, onComplete?: () => void): void;
528
+
529
+ /**
530
+ * The camera swings back and forth like a pendulum.
531
+ *
532
+ * Example:
533
+ * ```
534
+ * pendulumAnimation(camera, new THREE.Vector3(0, 5, 5), 0.5, 9000, 3, () => {
535
+ * console.log("Pendulum animation complete");
536
+ * });
537
+ * ```
538
+ */
539
+ export declare function cameraPendulumAnimation(camera: Camera, center: Vector3, radius: number, duration: number, oscillations: number, onComplete?: () => void): void;
540
+
541
+ /**
542
+ * The camera spirals upward, perfect for revealing a large scene or structure.
543
+ *
544
+ * Example:
545
+ * ```
546
+ * spiralAscensionAnimation(camera, new THREE.Vector3(0, 0, 0), 10, 300, 7, 12000, () => {
547
+ * console.log("Spiral ascension animation complete");
548
+ * });
549
+ * ```
550
+ */
551
+ export declare function cameraSpiralAscensionAnimation(camera: Camera, center: Vector3, radius: number, height: number, revolutions: number, duration: number, onComplete?: () => void): void;
552
+
553
+ /**
554
+ * Add a slight random wobble for intensity or realism (e.g., during an explosion).
555
+ *
556
+ * Example:
557
+ * ```
558
+ * wobbleAnimation(camera, 0.5, 1000, () => {
559
+ * console.log("Wobble animation complete");
560
+ * });
561
+ * ```
562
+ */
563
+ export declare function cameraWobbleAnimation(camera: Camera, intensity: number, duration: number, onComplete?: () => void): void;
564
+
565
+ /**
566
+ * The camera smoothly zooms in toward a target, focusing attention on a specific point,
567
+ * and resets to its original FOV after completion.
568
+ *
569
+ * Example:
570
+ * ```
571
+ * zoomInAnimation(camera, new THREE.Vector3(0, 0, 0), 120, 75, 2000, () => {
572
+ * console.log("Zoom in animation complete");
573
+ * });
574
+ * ```
575
+ */
576
+ export declare function cameraZoomInAnimation(camera: PerspectiveCamera, target: Vector3, startFov: number, endFov: number, duration: number, onComplete?: () => void): void;
577
+
442
578
  export declare class Candle extends Group {
443
579
  private candle;
444
580
  private flame;
@@ -964,18 +1100,6 @@ export declare const Direction: {
964
1100
  */
965
1101
  export declare const displacementBrush: <T extends BufferGeometry>(geometry: T, position: Vector3, radius: number, strength: number, direction?: Vector3, falloffFn?: (distance: number, radius: number) => number) => void;
966
1102
 
967
- /**
968
- * Dolly backward
969
- *
970
- * Example:
971
- * ```
972
- * dollyAnimation(camera, 5, 3000, () => {
973
- * console.log("Dolly animation complete");
974
- * });
975
- * ```
976
- */
977
- export declare function dollyAnimation(camera: Camera, distance: number, duration: number, onComplete?: () => void): void;
978
-
979
1103
  /**
980
1104
  * Easing functions for interpolating values over time.
981
1105
  */
@@ -1020,18 +1144,26 @@ export declare class EllipticLeafGeometry extends BufferGeometry {
1020
1144
  }
1021
1145
 
1022
1146
  /**
1023
- * Emissive pulse effect, designed for flickering lights.
1147
+ * Emissive pulse animation, producing a flickering light effect for materials that have emissive properties.
1024
1148
  * The emissive intensity of the material will oscillate between `minIntensity` and `maxIntensity`.
1025
1149
  *
1026
- * Use with materials that have emissive properties.
1027
- *
1028
1150
  * Oscillation time = 2π / speed
1029
1151
  * - Low speed values (e.g., 0.5) will result in a slow pulse
1030
1152
  * - High speed values (e.g., 10) will result in a rapid flicker
1031
1153
  *
1032
1154
  * Requires `update()` frame handler with `clock.getElapsedTime()` for animation.
1155
+ *
1156
+ * Example usage:
1157
+ * ```
1158
+ * const pulseAnimation = new EmissivePulseAnimation();
1159
+ * const clock = new THREE.Clock();
1160
+ *
1161
+ * function animate() {
1162
+ * pulseAnimation.update(clock.getElapsedTime());
1163
+ * }
1164
+ * ```
1033
1165
  */
1034
- export declare class EmissivePulseEffect {
1166
+ export declare class EmissivePulseAnimation {
1035
1167
  speed: number;
1036
1168
  maxIntensity: number;
1037
1169
  minIntensity: number;
@@ -1118,10 +1250,6 @@ export declare function findClosestColor(inputColor: number, dataset: number[]):
1118
1250
 
1119
1251
  export declare function findClosestColorChannelWise(inputColor: number, dataset: number[]): number | null;
1120
1252
 
1121
- export declare class Flask extends Group {
1122
- constructor();
1123
- }
1124
-
1125
1253
  /**
1126
1254
  * Flattens vertices to a given plane defined by a target height or normal direction.
1127
1255
  */
@@ -1135,27 +1263,6 @@ export declare class FlorenceFlaskGeometry extends BufferGeometry {
1135
1263
  constructor();
1136
1264
  }
1137
1265
 
1138
- /**
1139
- * The camera flies through a sequence of points, ideal for showcasing specific elements in the scene.
1140
- *
1141
- * Example:
1142
- * ```
1143
- * flythroughAnimation(
1144
- * camera,
1145
- * [
1146
- * new THREE.Vector3(0, 5, 5),
1147
- * new THREE.Vector3(0, 5, -25.5),
1148
- * new THREE.Vector3(-20.5, 5, 0),
1149
- * ],
1150
- * 6000,
1151
- * () => {
1152
- * console.log("Flythrough animation complete");
1153
- * }
1154
- * );
1155
- * ```
1156
- */
1157
- export declare function flythroughAnimation(camera: Camera, waypoints: Vector3[], duration: number, onComplete?: () => void): void;
1158
-
1159
1266
  export declare const gaussian: (t: number) => number;
1160
1267
 
1161
1268
  export declare class Gear extends Mesh {
@@ -1192,7 +1299,7 @@ export declare function hexToHsl(hex: number): [number, number, number];
1192
1299
  */
1193
1300
  export declare function hexToRgb(hex: number): [number, number, number];
1194
1301
 
1195
- export declare class Hill extends Mesh {
1302
+ export declare class Hill extends Mesh<HillGeometry, MeshStandardMaterial> {
1196
1303
  constructor({ radius, //
1197
1304
  height, widthSegments, heightSegments, phiStart, phiLength, }?: {
1198
1305
  radius?: number | undefined;
@@ -1246,6 +1353,24 @@ export declare function interpolateCurve(curveFunction: (t: number) => number, s
1246
1353
 
1247
1354
  export declare const inverse: (t: number) => number;
1248
1355
 
1356
+ /**
1357
+ * Material indices
1358
+ * 0. Jar
1359
+ * 1. Cork
1360
+ */
1361
+ export declare class Jar extends Mesh<JarGeometry, MeshStandardMaterial[]> {
1362
+ constructor();
1363
+ }
1364
+
1365
+ /**
1366
+ * Group indices
1367
+ * 0. Jar
1368
+ * 1. Cork
1369
+ */
1370
+ export declare class JarGeometry extends BufferGeometry {
1371
+ constructor();
1372
+ }
1373
+
1249
1374
  export declare class Lantern extends Group {
1250
1375
  constructor(height?: number, baseWidth?: number);
1251
1376
  }
@@ -1274,7 +1399,7 @@ export declare class LeverPanel extends Group {
1274
1399
  }
1275
1400
 
1276
1401
  /**
1277
- * A lightning effect that can be used to simulate a lightning storm.
1402
+ * A lightning animation that can be used to simulate a lightning storm.
1278
1403
  * This effect is applied to a light source.
1279
1404
  *
1280
1405
  * Example usage:
@@ -1283,12 +1408,14 @@ export declare class LeverPanel extends Group {
1283
1408
  * scene.add(lightning);
1284
1409
  * lightning.position.set(5, 10, -5);
1285
1410
  *
1411
+ * const lightningAnimation = new LightningAnimation();
1412
+ *
1286
1413
  * setRandomInterval(() => {
1287
1414
  * lightningEffect.triggerLightning();
1288
1415
  * }, 250, 1250);
1289
1416
  * ```
1290
1417
  */
1291
- export declare class LightningEffect {
1418
+ export declare class LightningAnimation {
1292
1419
  private light?;
1293
1420
  minIntensity: number;
1294
1421
  maxIntensity: number;
@@ -1401,7 +1528,21 @@ export declare class MortarGeometry extends BufferGeometry {
1401
1528
  constructor();
1402
1529
  }
1403
1530
 
1404
- export declare class MossyRocks extends Group {
1531
+ /**
1532
+ * Material indices:
1533
+ * 0. Rocks
1534
+ * 1. Moss
1535
+ */
1536
+ export declare class MossyRocks extends Mesh<MossyRocksGeometry, MeshStandardMaterial[]> {
1537
+ constructor();
1538
+ }
1539
+
1540
+ /**
1541
+ * Group indices:
1542
+ * 0. Rocks
1543
+ * 1. Moss
1544
+ */
1545
+ export declare class MossyRocksGeometry extends BufferGeometry {
1405
1546
  constructor();
1406
1547
  }
1407
1548
 
@@ -1422,7 +1563,7 @@ export declare class MossyRocks extends Group {
1422
1563
  * }
1423
1564
  * ```
1424
1565
  */
1425
- export declare class Mound extends Mesh {
1566
+ export declare class Mound extends Mesh<MoundGeometry, MeshStandardMaterial> {
1426
1567
  constructor({ radius, //
1427
1568
  widthSegments, heightSegments, phiStart, phiLength, thetaLength, }?: {
1428
1569
  radius?: number | undefined;
@@ -1562,18 +1703,6 @@ declare interface ObeliskHeadstoneOptions {
1562
1703
  totalHeight?: number;
1563
1704
  }
1564
1705
 
1565
- /**
1566
- * Orbit around a target
1567
- *
1568
- * Example:
1569
- * ```
1570
- * orbitAnimation(camera, new THREE.Vector3(0, 0, 0), 10, 5000, () => {
1571
- * console.log("Orbit animation complete");
1572
- * });
1573
- * ```
1574
- */
1575
- export declare function orbitAnimation(camera: Camera, target: Vector3, radius: number, duration: number, onComplete?: () => void): void;
1576
-
1577
1706
  /**
1578
1707
  * Prefab for a panel.
1579
1708
  * Designed to be used as a control panel for switches, lights, levels, dials, and gauges.
@@ -1636,18 +1765,6 @@ export declare const ParametricCurveUtils: {
1636
1765
  */
1637
1766
  export declare function parseHexCode(hex: string): [number, number, number];
1638
1767
 
1639
- /**
1640
- * The camera swings back and forth like a pendulum.
1641
- *
1642
- * Example:
1643
- * ```
1644
- * pendulumAnimation(camera, new THREE.Vector3(0, 5, 5), 0.5, 9000, 3, () => {
1645
- * console.log("Pendulum animation complete");
1646
- * });
1647
- * ```
1648
- */
1649
- export declare function pendulumAnimation(camera: Camera, center: Vector3, radius: number, duration: number, oscillations: number, onComplete?: () => void): void;
1650
-
1651
1768
  /**
1652
1769
  * Planar UV Mapping
1653
1770
  * Projects UVs onto the geometry from a single direction (like shining a projector onto a surface).
@@ -1772,7 +1889,11 @@ export declare class RockGeometry extends BufferGeometry {
1772
1889
  constructor(radius?: number, widthSegments?: number, heightSegments?: number);
1773
1890
  }
1774
1891
 
1775
- export declare class Rocks extends Group {
1892
+ export declare class Rocks extends Mesh<RocksGeometry, MeshStandardMaterial> {
1893
+ constructor();
1894
+ }
1895
+
1896
+ export declare class RocksGeometry extends BufferGeometry {
1776
1897
  constructor();
1777
1898
  }
1778
1899
 
@@ -1892,18 +2013,6 @@ export declare function sphericalUVMapping(vertices: [number, number, number][])
1892
2013
  */
1893
2014
  export declare const spikeBrush: <T extends BufferGeometry>(geometry: T, position: Vector3, radius: number, strength: number, inward?: boolean, falloffFn?: (distance: number, radius: number) => number) => void;
1894
2015
 
1895
- /**
1896
- * The camera spirals upward, perfect for revealing a large scene or structure.
1897
- *
1898
- * Example:
1899
- * ```
1900
- * spiralAscensionAnimation(camera, new THREE.Vector3(0, 0, 0), 10, 300, 7, 12000, () => {
1901
- * console.log("Spiral ascension animation complete");
1902
- * });
1903
- * ```
1904
- */
1905
- export declare function spiralAscensionAnimation(camera: Camera, center: Vector3, radius: number, height: number, revolutions: number, duration: number, onComplete?: () => void): void;
1906
-
1907
2016
  export declare class SpiralStaircaseGeometry extends BufferGeometry {
1908
2017
  constructor(stepWidth?: number, stepDepth?: number, stepHeight?: number, numSteps?: number, radius?: number, angleIncrement?: number);
1909
2018
  }
@@ -1971,7 +2080,21 @@ export declare class StoneFencePostGeometry extends BufferGeometry {
1971
2080
  });
1972
2081
  }
1973
2082
 
1974
- export declare class TeslaCoil extends Group {
2083
+ /**
2084
+ * Material indices
2085
+ * 0: Base
2086
+ * 1: Coil
2087
+ */
2088
+ export declare class TeslaCoil extends Mesh<TeslaCoilGeometry, MeshStandardMaterial[]> {
2089
+ constructor();
2090
+ }
2091
+
2092
+ /**
2093
+ * Group indices
2094
+ * 0: Base
2095
+ * 1: Coil
2096
+ */
2097
+ export declare class TeslaCoilGeometry extends BufferGeometry {
1975
2098
  constructor();
1976
2099
  }
1977
2100
 
@@ -1987,6 +2110,21 @@ export declare class TestTubeRack extends Group {
1987
2110
  constructor(count?: number, colors?: number[]);
1988
2111
  }
1989
2112
 
2113
+ /**
2114
+ * Calculate the thetaLength to achieve a specific hole radius in a sphere.
2115
+ * thetaLength = asin(w / (2 * R))
2116
+ *
2117
+ * Returns the thetaLength in radians.
2118
+ *
2119
+ * Example usage:
2120
+ * ```
2121
+ * const sphereRadius = 5; // Radius of the sphere
2122
+ * const holeRadius = 1; // Desired radius of the hole at the top
2123
+ * const thetaLength = thetaLengthForRadius(sphereRadius, holeRadius);
2124
+ * ```
2125
+ */
2126
+ export declare const thetaLengthForRadius: (sphereRadius: number, holeRadius: number) => number;
2127
+
1990
2128
  /**
1991
2129
  * Material indices:
1992
2130
  * 0. Trunk
@@ -2076,18 +2214,6 @@ export declare class WineBottleGeometry extends BufferGeometry {
2076
2214
  });
2077
2215
  }
2078
2216
 
2079
- /**
2080
- * Add a slight random wobble for intensity or realism (e.g., during an explosion).
2081
- *
2082
- * Example:
2083
- * ```
2084
- * wobbleAnimation(camera, 0.5, 1000, () => {
2085
- * console.log("Wobble animation complete");
2086
- * });
2087
- * ```
2088
- */
2089
- export declare function wobbleAnimation(camera: Camera, intensity: number, duration: number, onComplete?: () => void): void;
2090
-
2091
2217
  export declare class WroughtIronBar extends Mesh<WroughtIronBarGeometry, MeshStandardMaterial> {
2092
2218
  constructor({ barHeight, //
2093
2219
  barRadius, spikeHeight, spikeRadius, spikeScaleZ, radialSegments, }?: {
@@ -2149,17 +2275,4 @@ export declare class WroughtIronFenceGeometry extends BufferGeometry {
2149
2275
  });
2150
2276
  }
2151
2277
 
2152
- /**
2153
- * The camera smoothly zooms in toward a target, focusing attention on a specific point,
2154
- * and resets to its original FOV after completion.
2155
- *
2156
- * Example:
2157
- * ```
2158
- * zoomInAnimation(camera, new THREE.Vector3(0, 0, 0), 120, 75, 2000, () => {
2159
- * console.log("Zoom in animation complete");
2160
- * });
2161
- * ```
2162
- */
2163
- export declare function zoomInAnimation(camera: PerspectiveCamera, target: Vector3, startFov: number, endFov: number, duration: number, onComplete?: () => void): void;
2164
-
2165
2278
  export { }