three-low-poly 0.9.18 → 0.9.20

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
@@ -12,6 +12,8 @@ import { MeshLambertMaterial } from 'three';
12
12
  import { MeshPhongMaterial } from 'three';
13
13
  import { MeshPhysicalMaterial } from 'three';
14
14
  import { MeshStandardMaterial } from 'three';
15
+ import { Object3D } from 'three';
16
+ import { ParametricGeometry } from 'three-stdlib';
15
17
  import { PerspectiveCamera } from 'three';
16
18
  import { ShaderMaterial } from 'three';
17
19
  import { Shape } from 'three';
@@ -45,6 +47,37 @@ export declare function addWaterDisplacement<T extends Material>(material: T, {
45
47
  waveAmplitude?: number | undefined;
46
48
  }): void;
47
49
 
50
+ /**
51
+ * Align a BufferGeometry to a surface by adjusting its vertices.
52
+ */
53
+ export declare function alignBufferGeometryToSurface(geometry: BufferGeometry, targetPositionY: number): void;
54
+
55
+ /**
56
+ * Align a specific instance in an InstancedMesh to a surface.
57
+ */
58
+ export declare function alignInstancedMeshIndexToSurface(instancedMesh: InstancedMesh, targetPosition: Vector3, instanceIndex: number, offset?: Vector3): void;
59
+
60
+ /**
61
+ * Align an InstancedMesh to a surface.
62
+ */
63
+ export declare function alignInstancedMeshToSurface(instancedMesh: InstancedMesh, targetPosition: Vector3, offset?: Vector3): void;
64
+
65
+ /**
66
+ * Align an Object3D to a surface by adjusting its position.
67
+ */
68
+ export declare function alignObjectToSurface(object: Object3D, targetPosition: Vector3, offset?: Vector3): void;
69
+
70
+ /**
71
+ * Aligns an array of Object3D objects (or subclasses) to a specified side
72
+ * (left, right, top, bottom, front, or back) based on their world-space bounding boxes.
73
+ */
74
+ export declare function alignToEdge<T extends Object3D>(objects: T[], side: BoxSide): void;
75
+
76
+ /**
77
+ * Aligns an array of `Object3D` objects along a specified direction with optional spacing.
78
+ */
79
+ export declare function alignToRow<T extends Object3D>(objects: T[], direction?: Vector3, spacing?: number): void;
80
+
48
81
  /**
49
82
  * Generates spherical curve profile points, for use with geometry.
50
83
  * Enables connective geometry via holes at the top and bottom of the sphere.
@@ -390,6 +423,15 @@ export declare class BookshelfGeometry extends BufferGeometry {
390
423
  });
391
424
  }
392
425
 
426
+ export declare enum BoxSide {
427
+ LEFT = "left",
428
+ RIGHT = "right",
429
+ TOP = "top",
430
+ BOTTOM = "bottom",
431
+ FRONT = "front",
432
+ BACK = "back"
433
+ }
434
+
393
435
  export declare class BubblingEffect extends InstancedMesh {
394
436
  private bubblePositions;
395
437
  private velocities;
@@ -575,14 +617,38 @@ export declare function cameraWobbleAnimation(camera: Camera, intensity: number,
575
617
  */
576
618
  export declare function cameraZoomInAnimation(camera: PerspectiveCamera, target: Vector3, startFov: number, endFov: number, duration: number, onComplete?: () => void): void;
577
619
 
578
- export declare class Candle extends Group {
579
- private candle;
580
- private flame;
581
- private candleLight;
582
- private height;
583
- private radius;
584
- constructor(height?: number, radius?: number);
585
- animateFlicker(): void;
620
+ /**
621
+ * Material indices
622
+ * 0: Stick
623
+ * 1: Flame
624
+ */
625
+ export declare class Candle extends Mesh<CandleGeometry, MeshStandardMaterial[]> {
626
+ constructor({ radiusTop, //
627
+ radiusBottom, height, flameHeight, flameRadius, segments, }?: {
628
+ radiusTop?: number | undefined;
629
+ radiusBottom?: number | undefined;
630
+ height?: number | undefined;
631
+ flameHeight?: number | undefined;
632
+ flameRadius?: number | undefined;
633
+ segments?: number | undefined;
634
+ });
635
+ }
636
+
637
+ /**
638
+ * Group indices
639
+ * 0: Stick
640
+ * 1: Flame
641
+ */
642
+ export declare class CandleGeometry extends BufferGeometry {
643
+ constructor({ radiusTop, //
644
+ radiusBottom, height, flameHeight, flameRadius, segments, }?: {
645
+ radiusTop?: number | undefined;
646
+ radiusBottom?: number | undefined;
647
+ height?: number | undefined;
648
+ flameHeight?: number | undefined;
649
+ flameRadius?: number | undefined;
650
+ segments?: number | undefined;
651
+ });
586
652
  }
587
653
 
588
654
  /**
@@ -610,24 +676,41 @@ export declare const cartesianToSpherical: (x: number, y: number, z: number) =>
610
676
  phi: number;
611
677
  };
612
678
 
613
- export declare function centerGroup<T extends Group>(group: T): void;
614
-
615
- export declare function centerGroupAtTarget<T extends Group>(group: T, target?: Vector3): void;
679
+ export declare const Center: {
680
+ object: typeof centerObject;
681
+ objectGeometry: typeof centerObjectGeometry;
682
+ meshGeometry: typeof centerMeshGeometry;
683
+ };
616
684
 
617
- export declare function centerInstancedMesh<T extends InstancedMesh>(mesh: T): void;
685
+ /**
686
+ * Centers the geometry of a `Mesh` relative to a target position with an optional offset.
687
+ *
688
+ * This function calculates the bounding box center of the `Mesh` geometry and adjusts its
689
+ * position by translating the geometry such that it is centered at the specified target
690
+ * position, with an optional offset applied. The function modifies the geometry directly,
691
+ * leaving the `Mesh`'s transformation properties (`position`, `rotation`, `scale`) unchanged.
692
+ */
693
+ export declare function centerMeshGeometry<T extends Mesh>(mesh: T, target?: Vector3, offset?: Vector3): void;
618
694
 
619
695
  /**
620
- * Centers the given mesh at the origin (0, 0, 0) of the scene by adjusting its position.
621
- * The mesh is moved so that its bounding box center is placed at the origin.
696
+ * Centers an `Object3D` relative to a specified target position with an optional offset.
697
+ *
698
+ * This function calculates the bounding box center of the given `Object3D` and adjusts
699
+ * its position so that it is centered at the specified target position, with an optional
700
+ * offset applied. The centering respects the object's current transformation, including
701
+ * its scale and rotation.
622
702
  */
623
- export declare function centerMesh<T extends Mesh>(mesh: T): void;
703
+ export declare function centerObject<T extends Object3D>(object: T, target?: Vector3, offset?: Vector3): void;
624
704
 
625
705
  /**
626
- * Centers the geometry of the given mesh at the local origin (0, 0, 0) by modifying the geometry vertices.
627
- * This method moves the geometry itself so that its center is at the local origin,
628
- * without affecting the position, rotation, or scale of the mesh.
706
+ * Centers the geometry of an `Object3D` relative to a target position with an optional offset.
707
+ *
708
+ * This function calculates the bounding box center of the given `Object3D` and adjusts its
709
+ * geometry's position by translating it such that the geometry is centered at the specified
710
+ * target position, with an optional offset applied. Unlike modifying the `position` property,
711
+ * this function directly translates the geometry within the object's local space.
629
712
  */
630
- export declare function centerMeshGeometry<T extends Mesh>(mesh: T): void;
713
+ export declare function centerObjectGeometry<T extends Object3D>(object: T, target?: Vector3, offset?: Vector3): void;
631
714
 
632
715
  /**
633
716
  * Create a checkerboard texture
@@ -652,8 +735,9 @@ export declare const ColorPalette: {
652
735
  CHERRY_RED: number;
653
736
  CRIMSON: number;
654
737
  ALIZARIN_CRIMSON: number;
655
- RUST: number;
656
738
  DARK_RED: number;
739
+ RUST: number;
740
+ CORAL_ORANGE: number;
657
741
  TANGERINE: number;
658
742
  ORANGE_PEEL: number;
659
743
  CADMIUM_ORANGE: number;
@@ -673,6 +757,7 @@ export declare const ColorPalette: {
673
757
  MINT_GREEN: number;
674
758
  AQUAMARINE: number;
675
759
  PHTHALO_BLUE: number;
760
+ AETHER_BLUE: number;
676
761
  SKY_BLUE: number;
677
762
  CERULEAN_BLUE: number;
678
763
  AZURE: number;
@@ -1016,8 +1101,41 @@ export declare class DeskGeometry extends BufferGeometry {
1016
1101
  constructor();
1017
1102
  }
1018
1103
 
1104
+ /**
1105
+ * A diorama with a floor and walls.
1106
+ *
1107
+ * Material indices:
1108
+ * 0: Interior walls
1109
+ * 1: Floor
1110
+ * 2: Exterior walls
1111
+ */
1112
+ export declare class Diorama extends Mesh<DioramaGeometry, MeshStandardMaterial[]> {
1113
+ constructor({ width, height, depth, wallThickness, interiorColor, floorColor, exteriorColor, }?: {
1114
+ width?: number | undefined;
1115
+ height?: number | undefined;
1116
+ depth?: number | undefined;
1117
+ wallThickness?: number | undefined;
1118
+ interiorColor?: number | undefined;
1119
+ floorColor?: number | undefined;
1120
+ exteriorColor?: number | undefined;
1121
+ });
1122
+ }
1123
+
1124
+ /**
1125
+ * Geometry for a diorama with a floor and walls.
1126
+ *
1127
+ * Group indices:
1128
+ * 0: Interior walls
1129
+ * 1: Floor
1130
+ * 2: Exterior walls
1131
+ */
1019
1132
  export declare class DioramaGeometry extends BufferGeometry {
1020
- constructor(width?: number, height?: number, depth?: number, wallThickness?: number);
1133
+ constructor({ width, height, depth, wallThickness }?: {
1134
+ width?: number | undefined;
1135
+ height?: number | undefined;
1136
+ depth?: number | undefined;
1137
+ wallThickness?: number | undefined;
1138
+ });
1021
1139
  }
1022
1140
 
1023
1141
  /**
@@ -1250,6 +1368,24 @@ export declare function findClosestColor(inputColor: number, dataset: number[]):
1250
1368
 
1251
1369
  export declare function findClosestColorChannelWise(inputColor: number, dataset: number[]): number | null;
1252
1370
 
1371
+ export declare class Flame extends Mesh<FlameGeometry, MeshStandardMaterial> {
1372
+ constructor({ height, radius, segmentsU, segmentsV }?: {
1373
+ height?: number | undefined;
1374
+ radius?: number | undefined;
1375
+ segmentsU?: number | undefined;
1376
+ segmentsV?: number | undefined;
1377
+ });
1378
+ }
1379
+
1380
+ export declare class FlameGeometry extends ParametricGeometry {
1381
+ constructor({ height, radius, segmentsU, segmentsV }?: {
1382
+ height?: number | undefined;
1383
+ radius?: number | undefined;
1384
+ segmentsU?: number | undefined;
1385
+ segmentsV?: number | undefined;
1386
+ });
1387
+ }
1388
+
1253
1389
  /**
1254
1390
  * Flattens vertices to a given plane defined by a target height or normal direction.
1255
1391
  */
@@ -1398,6 +1534,65 @@ export declare class LeverPanel extends Group {
1398
1534
  constructor();
1399
1535
  }
1400
1536
 
1537
+ /**
1538
+ * Create a light flicker animation that will randomly change the intensity and position of a light.
1539
+ * Effect resembles a flickering flame of candlelight.
1540
+ *
1541
+ * Example usage:
1542
+ * ```
1543
+ * // Create a candle
1544
+ * const candle = new Candle({
1545
+ * height: 1,
1546
+ * flameHeight: 0.25,
1547
+ * });
1548
+ * scene.add(candle);
1549
+ *
1550
+ * // Create a point light
1551
+ * const candleLight = new THREE.PointLight(0xffa500, 1, 5);
1552
+ * scene.add(candleLight);
1553
+ *
1554
+ * // Apply the animator to the light
1555
+ * const lightAnimation = new LightFlickerAnimation({
1556
+ * light: candleLight,
1557
+ * maxIntensity: 2.2,
1558
+ * x: candle.position.x,
1559
+ * y: candle.position.y + 1 + 0.125, // height + half flame height
1560
+ * z: candle.position.z,
1561
+ * });
1562
+ * animations.push(lightAnimation);
1563
+ *
1564
+ * // Update the light animation in the render loop
1565
+ * renderer.setAnimationLoop(() => {
1566
+ * lightAnimation.update();
1567
+ * });
1568
+ * ```
1569
+ */
1570
+ export declare class LightFlickerAnimation {
1571
+ private light?;
1572
+ minIntensity: number;
1573
+ maxIntensity: number;
1574
+ x: number;
1575
+ y: number;
1576
+ z: number;
1577
+ jitterX: number;
1578
+ jitterY: number;
1579
+ jitterZ: number;
1580
+ constructor({ light, minIntensity, maxIntensity, x, y, z, jitterX, jitterY, jitterZ, }?: Partial<LightFlickerAnimationOptions>);
1581
+ update(): void;
1582
+ }
1583
+
1584
+ export declare interface LightFlickerAnimationOptions {
1585
+ light?: Light;
1586
+ minIntensity: number;
1587
+ maxIntensity: number;
1588
+ x: number;
1589
+ y: number;
1590
+ z: number;
1591
+ jitterX: number;
1592
+ jitterY: number;
1593
+ jitterZ: number;
1594
+ }
1595
+
1401
1596
  /**
1402
1597
  * A lightning animation that can be used to simulate a lightning storm.
1403
1598
  * This effect is applied to a light source.
@@ -1739,6 +1934,13 @@ export declare interface PanelOptions {
1739
1934
 
1740
1935
  export declare const parabolicCurve: (t: number, a?: number, b?: number, c?: number) => number;
1741
1936
 
1937
+ /**
1938
+ * Prismatic parallelogram, with horizontal skew (offset in X for the slant).
1939
+ */
1940
+ export declare class ParallelogramBoxGeometry extends BufferGeometry {
1941
+ constructor(width?: number, height?: number, depth?: number, angle?: number);
1942
+ }
1943
+
1742
1944
  export declare const ParametricCurve: {
1743
1945
  CUBIC: (t: number, p0: number, p1: number, p2: number, p3: number) => number;
1744
1946
  DAMPED: (t: number, damping?: number) => number;