three-low-poly 0.9.21 → 0.9.22
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.cjs.js +12 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +148 -11
- package/dist/index.es.js +1653 -1560
- package/dist/index.es.js.map +1 -1
- package/dist/index.iife.js +14 -9
- package/dist/index.iife.js.map +1 -1
- package/dist/index.umd.js +14 -9
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { BufferGeometry } from 'three';
|
|
|
3
3
|
import { Camera } from 'three';
|
|
4
4
|
import { Color } from 'three';
|
|
5
5
|
import { DataTexture } from 'three';
|
|
6
|
+
import { ExtrudeGeometry } from 'three';
|
|
6
7
|
import { Group } from 'three';
|
|
7
8
|
import { InstancedMesh } from 'three';
|
|
8
9
|
import { Light } from 'three';
|
|
@@ -22,6 +23,45 @@ import { Uniform } from 'three';
|
|
|
22
23
|
import { Vector2 } from 'three';
|
|
23
24
|
import { Vector3 } from 'three';
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Shader modification to support instance-specific colors.
|
|
28
|
+
* This function modifies the provided material to accept instance-specific colors.
|
|
29
|
+
*
|
|
30
|
+
* This is not generally necessary for materials that already support vertex colors,
|
|
31
|
+
* but it can be useful for custom materials or when using InstancedMesh.
|
|
32
|
+
*
|
|
33
|
+
* Instanced meshes already allow for per-instance colors, implemented as:
|
|
34
|
+
* ```ts
|
|
35
|
+
* const colors = new Float32Array(instancedMesh.count * 3);
|
|
36
|
+
* for (let i = 0; i < instancedMesh.count; i++) {
|
|
37
|
+
* const [r, g, b] = [Math.random(), Math.random(), Math.random()];
|
|
38
|
+
* colors.set([r, g, b], i * 3); // Normalized to [0, 1]
|
|
39
|
+
* }
|
|
40
|
+
* instancedMesh.instanceColor = new THREE.InstancedBufferAttribute(colors, 3);
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Example usage:
|
|
44
|
+
* ```ts
|
|
45
|
+
* // Material
|
|
46
|
+
* const material = new THREE.MeshStandardMaterial();
|
|
47
|
+
*
|
|
48
|
+
* // Add instance color modifier
|
|
49
|
+
* addInstanceColor(material);
|
|
50
|
+
*
|
|
51
|
+
* // RGB color for each instance
|
|
52
|
+
* const colors = new Float32Array(instancedMesh.count * 3);
|
|
53
|
+
* for (let i = 0; i < instancedMesh.count; i++) {
|
|
54
|
+
* getAnalogousColors(hue).forEach((color, index) => {
|
|
55
|
+
* colors[i * 3 + index] = color / 0xff;
|
|
56
|
+
* });
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* // Add the instance color attribute to the geometry
|
|
60
|
+
* instancedMesh.geometry.setAttribute("instanceColor", new THREE.InstancedBufferAttribute(colors, 3));
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function addInstanceColor(material: Material): Material;
|
|
64
|
+
|
|
25
65
|
/**
|
|
26
66
|
* Utility function to add noise-based vertex displacement to an existing Three.js material.
|
|
27
67
|
* @param {Material} material - The material to mutate, e.g., MeshStandardMaterial.
|
|
@@ -464,6 +504,18 @@ export declare class BunsenBurner extends Group {
|
|
|
464
504
|
}
|
|
465
505
|
|
|
466
506
|
export declare class Burst extends Mesh {
|
|
507
|
+
constructor({ sides, innerRadius, outerRadius, depth }?: {
|
|
508
|
+
sides?: number | undefined;
|
|
509
|
+
innerRadius?: number | undefined;
|
|
510
|
+
outerRadius?: number | undefined;
|
|
511
|
+
depth?: number | undefined;
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Extrude geometry of Burst Shape.
|
|
517
|
+
*/
|
|
518
|
+
export declare class BurstGeometry extends ExtrudeGeometry {
|
|
467
519
|
constructor(sides?: number, innerRadius?: number, outerRadius?: number, depth?: number);
|
|
468
520
|
}
|
|
469
521
|
|
|
@@ -528,7 +580,7 @@ export declare function calculateYFromSlopeIntercept(x1: number, y1: number, x2:
|
|
|
528
580
|
*
|
|
529
581
|
* Example:
|
|
530
582
|
* ```
|
|
531
|
-
*
|
|
583
|
+
* cameraDollyAnimation(camera, 5, 3000, () => {
|
|
532
584
|
* console.log("Dolly animation complete");
|
|
533
585
|
* });
|
|
534
586
|
* ```
|
|
@@ -540,7 +592,7 @@ export declare function cameraDollyAnimation(camera: Camera, distance: number, d
|
|
|
540
592
|
*
|
|
541
593
|
* Example:
|
|
542
594
|
* ```
|
|
543
|
-
*
|
|
595
|
+
* cameraFlythroughAnimation(
|
|
544
596
|
* camera,
|
|
545
597
|
* [
|
|
546
598
|
* new THREE.Vector3(0, 5, 5),
|
|
@@ -561,7 +613,7 @@ export declare function cameraFlythroughAnimation(camera: Camera, waypoints: Vec
|
|
|
561
613
|
*
|
|
562
614
|
* Example:
|
|
563
615
|
* ```
|
|
564
|
-
*
|
|
616
|
+
* cameraOrbitAnimation(camera, new THREE.Vector3(0, 0, 0), 10, 5000, () => {
|
|
565
617
|
* console.log("Orbit animation complete");
|
|
566
618
|
* });
|
|
567
619
|
* ```
|
|
@@ -573,7 +625,7 @@ export declare function cameraOrbitAnimation(camera: Camera, target: Vector3, ra
|
|
|
573
625
|
*
|
|
574
626
|
* Example:
|
|
575
627
|
* ```
|
|
576
|
-
*
|
|
628
|
+
* cameraPendulumAnimation(camera, new THREE.Vector3(0, 5, 5), 0.5, 9000, 3, () => {
|
|
577
629
|
* console.log("Pendulum animation complete");
|
|
578
630
|
* });
|
|
579
631
|
* ```
|
|
@@ -585,7 +637,7 @@ export declare function cameraPendulumAnimation(camera: Camera, center: Vector3,
|
|
|
585
637
|
*
|
|
586
638
|
* Example:
|
|
587
639
|
* ```
|
|
588
|
-
*
|
|
640
|
+
* cameraSpiralAscensionAnimation(camera, new THREE.Vector3(0, 0, 0), 10, 300, 7, 12000, () => {
|
|
589
641
|
* console.log("Spiral ascension animation complete");
|
|
590
642
|
* });
|
|
591
643
|
* ```
|
|
@@ -597,7 +649,7 @@ export declare function cameraSpiralAscensionAnimation(camera: Camera, center: V
|
|
|
597
649
|
*
|
|
598
650
|
* Example:
|
|
599
651
|
* ```
|
|
600
|
-
*
|
|
652
|
+
* cameraWobbleAnimation(camera, 0.5, 1000, () => {
|
|
601
653
|
* console.log("Wobble animation complete");
|
|
602
654
|
* });
|
|
603
655
|
* ```
|
|
@@ -610,7 +662,7 @@ export declare function cameraWobbleAnimation(camera: Camera, intensity: number,
|
|
|
610
662
|
*
|
|
611
663
|
* Example:
|
|
612
664
|
* ```
|
|
613
|
-
*
|
|
665
|
+
* cameraZoomInAnimation(camera, new THREE.Vector3(0, 0, 0), 120, 75, 2000, () => {
|
|
614
666
|
* console.log("Zoom in animation complete");
|
|
615
667
|
* });
|
|
616
668
|
* ```
|
|
@@ -858,24 +910,43 @@ export declare const createDampedCurvePoints: (start: Vector2, end: Vector2, dam
|
|
|
858
910
|
*/
|
|
859
911
|
export declare const createExponentialCurvePoints: (start: Vector2, end: Vector2, base: number, factor: number, segments?: number) => Vector2[];
|
|
860
912
|
|
|
913
|
+
/**
|
|
914
|
+
* Hexagonal tile pattern factory with density control.
|
|
915
|
+
*
|
|
916
|
+
* Example usage:
|
|
917
|
+
* ```ts
|
|
918
|
+
* const hexTile = createHexagonalTilesByCount({
|
|
919
|
+
* width: 10,
|
|
920
|
+
* depth: 10,
|
|
921
|
+
* height: 0.01,
|
|
922
|
+
* count: 10, // 10 tiles along the x-axis
|
|
923
|
+
* gap: 0.01,
|
|
924
|
+
* material: new THREE.MeshStandardMaterial({ color: 0xffffff }),
|
|
925
|
+
* });
|
|
926
|
+
*
|
|
927
|
+
* scene.add(hexTile);
|
|
928
|
+
* ```
|
|
929
|
+
*/
|
|
930
|
+
export declare function createHexagonalTilesByCount(options: HexagonalTileCountOptions): InstancedMesh;
|
|
931
|
+
|
|
861
932
|
/**
|
|
862
933
|
* Hexagonal tile pattern factory.
|
|
863
934
|
*
|
|
864
935
|
* Example usage:
|
|
865
936
|
* ```ts
|
|
866
|
-
* const hexTile =
|
|
937
|
+
* const hexTile = createHexagonalTilesByRadius({
|
|
867
938
|
* width: 10,
|
|
868
939
|
* depth: 10,
|
|
869
940
|
* height: 0.01,
|
|
870
941
|
* radius: 0.1,
|
|
871
942
|
* gap: 0.01,
|
|
872
|
-
* material: new THREE.MeshStandardMaterial({ color:
|
|
943
|
+
* material: new THREE.MeshStandardMaterial({ color: 0xffffff }),
|
|
873
944
|
* });
|
|
874
945
|
*
|
|
875
946
|
* scene.add(hexTile);
|
|
876
947
|
* ```
|
|
877
948
|
*/
|
|
878
|
-
export declare function
|
|
949
|
+
export declare function createHexagonalTilesByRadius(options: HexagonalTileRadiusOptions): InstancedMesh;
|
|
879
950
|
|
|
880
951
|
/**
|
|
881
952
|
* Function to create logarithmic curve points
|
|
@@ -1432,6 +1503,20 @@ export declare class FlorenceFlaskGeometry extends BufferGeometry {
|
|
|
1432
1503
|
export declare const gaussian: (t: number) => number;
|
|
1433
1504
|
|
|
1434
1505
|
export declare class Gear extends Mesh {
|
|
1506
|
+
constructor({ sides, innerRadius, outerRadius, holeSides, holeRadius, depth }?: {
|
|
1507
|
+
sides?: number | undefined;
|
|
1508
|
+
innerRadius?: number | undefined;
|
|
1509
|
+
outerRadius?: number | undefined;
|
|
1510
|
+
holeSides?: number | undefined;
|
|
1511
|
+
holeRadius?: number | undefined;
|
|
1512
|
+
depth?: number | undefined;
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* Extrude geometry of Gear Shape.
|
|
1518
|
+
*/
|
|
1519
|
+
export declare class GearGeometry extends ExtrudeGeometry {
|
|
1435
1520
|
constructor(sides?: number, innerRadius?: number, outerRadius?: number, holeSides?: number, holeRadius?: number, depth?: number);
|
|
1436
1521
|
}
|
|
1437
1522
|
|
|
@@ -1450,6 +1535,19 @@ export declare class GearShape extends Shape {
|
|
|
1450
1535
|
export declare function getAnalogousColors(baseHue: number): [number, number, number];
|
|
1451
1536
|
|
|
1452
1537
|
export declare class Heart extends Mesh {
|
|
1538
|
+
constructor({ size, width, height, tipDepth, depth }?: {
|
|
1539
|
+
size?: number | undefined;
|
|
1540
|
+
width?: number | undefined;
|
|
1541
|
+
height?: number | undefined;
|
|
1542
|
+
tipDepth?: number | undefined;
|
|
1543
|
+
depth?: number | undefined;
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Extrude geometry of Heart Shape.
|
|
1549
|
+
*/
|
|
1550
|
+
export declare class HeartGeometry extends ExtrudeGeometry {
|
|
1453
1551
|
constructor(size?: number, width?: number, height?: number, tipDepth?: number, depth?: number);
|
|
1454
1552
|
}
|
|
1455
1553
|
|
|
@@ -1457,7 +1555,23 @@ export declare class HeartShape extends Shape {
|
|
|
1457
1555
|
constructor(size?: number, width?: number, height?: number, tipDepth?: number);
|
|
1458
1556
|
}
|
|
1459
1557
|
|
|
1460
|
-
export declare
|
|
1558
|
+
export declare class Hexagon extends Mesh {
|
|
1559
|
+
constructor({ radius, depth }?: {
|
|
1560
|
+
radius?: number | undefined;
|
|
1561
|
+
depth?: number | undefined;
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
export declare interface HexagonalTileCountOptions {
|
|
1566
|
+
width: number;
|
|
1567
|
+
depth: number;
|
|
1568
|
+
height: number;
|
|
1569
|
+
count: number;
|
|
1570
|
+
gap: number;
|
|
1571
|
+
material?: Material;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
export declare interface HexagonalTileRadiusOptions {
|
|
1461
1575
|
width: number;
|
|
1462
1576
|
depth: number;
|
|
1463
1577
|
height: number;
|
|
@@ -1466,6 +1580,17 @@ export declare interface HexagonalTileOptions {
|
|
|
1466
1580
|
material?: Material;
|
|
1467
1581
|
}
|
|
1468
1582
|
|
|
1583
|
+
/**
|
|
1584
|
+
* Extrude geometry of Hexagon Shape.
|
|
1585
|
+
*/
|
|
1586
|
+
export declare class HexagonGeometry extends ExtrudeGeometry {
|
|
1587
|
+
constructor(radius?: number, depth?: number);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
export declare class HexagonShape extends Shape {
|
|
1591
|
+
constructor(radius?: number);
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1469
1594
|
export declare function hexToHsl(hex: number): [number, number, number];
|
|
1470
1595
|
|
|
1471
1596
|
/**
|
|
@@ -2299,6 +2424,18 @@ export declare class StandGeometry extends BufferGeometry {
|
|
|
2299
2424
|
}
|
|
2300
2425
|
|
|
2301
2426
|
export declare class Star extends Mesh {
|
|
2427
|
+
constructor({ points, innerRadius, outerRadius, depth }?: {
|
|
2428
|
+
points?: number | undefined;
|
|
2429
|
+
innerRadius?: number | undefined;
|
|
2430
|
+
outerRadius?: number | undefined;
|
|
2431
|
+
depth?: number | undefined;
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
/**
|
|
2436
|
+
* Extrude geometry of Star Shape.
|
|
2437
|
+
*/
|
|
2438
|
+
export declare class StarGeometry extends ExtrudeGeometry {
|
|
2302
2439
|
constructor(points?: number, innerRadius?: number, outerRadius?: number, depth?: number);
|
|
2303
2440
|
}
|
|
2304
2441
|
|