@casmo/tree.js 0.3.0 → 0.5.0
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/README.md +775 -4
- package/dist/effects/custom.d.ts +62 -0
- package/dist/effects/custom.d.ts.map +1 -0
- package/dist/effects/effects.d.ts +92 -6
- package/dist/effects/effects.d.ts.map +1 -1
- package/dist/effects/glow.d.ts +5 -0
- package/dist/effects/glow.d.ts.map +1 -1
- package/dist/effects/grade.d.ts +3 -0
- package/dist/effects/grade.d.ts.map +1 -1
- package/dist/effects/highlight.d.ts +35 -0
- package/dist/effects/highlight.d.ts.map +1 -0
- package/dist/effects/index.d.ts +7 -1
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/inner-lines.d.ts +39 -0
- package/dist/effects/inner-lines.d.ts.map +1 -0
- package/dist/effects/live.d.ts +12 -0
- package/dist/effects/live.d.ts.map +1 -0
- package/dist/effects/mask.d.ts +32 -12
- package/dist/effects/mask.d.ts.map +1 -1
- package/dist/effects/outline.d.ts +12 -0
- package/dist/effects/outline.d.ts.map +1 -1
- package/dist/effects/pass.d.ts +27 -0
- package/dist/effects/pass.d.ts.map +1 -0
- package/dist/effects/screen.d.ts +31 -0
- package/dist/effects/screen.d.ts.map +1 -0
- package/dist/effects/suggested.d.ts +5 -0
- package/dist/effects/suggested.d.ts.map +1 -1
- package/dist/effects/tree-id.d.ts +50 -0
- package/dist/effects/tree-id.d.ts.map +1 -0
- package/dist/effects-qHx_8Dlk.js +1052 -0
- package/dist/effects-qHx_8Dlk.js.map +1 -0
- package/dist/effects.js +3 -249
- package/dist/forest/Forest.d.ts +82 -4
- package/dist/forest/Forest.d.ts.map +1 -1
- package/dist/forest/forest-lod.d.ts +70 -0
- package/dist/forest/forest-lod.d.ts.map +1 -0
- package/dist/forest/impostor-material.d.ts +106 -0
- package/dist/forest/impostor-material.d.ts.map +1 -0
- package/dist/forest/impostor-season.d.ts +13 -0
- package/dist/forest/impostor-season.d.ts.map +1 -0
- package/dist/forest/impostor.d.ts +105 -0
- package/dist/forest/impostor.d.ts.map +1 -0
- package/dist/forest/index.d.ts +1 -0
- package/dist/forest/index.d.ts.map +1 -1
- package/dist/forest/levels.d.ts +144 -0
- package/dist/forest/levels.d.ts.map +1 -0
- package/dist/forest/lod.d.ts +106 -0
- package/dist/forest/lod.d.ts.map +1 -0
- package/dist/forest/nodes.d.ts +42 -1
- package/dist/forest/nodes.d.ts.map +1 -1
- package/dist/forest/octahedral.d.ts +33 -0
- package/dist/forest/octahedral.d.ts.map +1 -0
- package/dist/{forest-ChEaWJrf.js → forest-CM5DrklM.js} +1727 -340
- package/dist/forest-CM5DrklM.js.map +1 -0
- package/dist/generator/fruit.d.ts +2 -0
- package/dist/generator/fruit.d.ts.map +1 -1
- package/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/light.d.ts +36 -0
- package/dist/generator/light.d.ts.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/materials/crown-nodes.d.ts +5 -0
- package/dist/materials/crown-nodes.d.ts.map +1 -1
- package/dist/materials/leaf-translucency-model.d.ts +6 -1
- package/dist/materials/leaf-translucency-model.d.ts.map +1 -1
- package/dist/materials/material-features.d.ts +12 -0
- package/dist/materials/material-features.d.ts.map +1 -1
- package/dist/materials/shader-hooks.d.ts +155 -0
- package/dist/materials/shader-hooks.d.ts.map +1 -0
- package/dist/motion-Qd7xjeZM.js +276 -0
- package/dist/motion-Qd7xjeZM.js.map +1 -0
- package/dist/nodes-DxgTyF9B.js +436 -0
- package/dist/nodes-DxgTyF9B.js.map +1 -0
- package/dist/react/Forest.d.ts +17 -3
- package/dist/react/Forest.d.ts.map +1 -1
- package/dist/react/ScenePipeline.d.ts +63 -0
- package/dist/react/ScenePipeline.d.ts.map +1 -0
- package/dist/react/SceneShaderHooks.d.ts +25 -0
- package/dist/react/SceneShaderHooks.d.ts.map +1 -0
- package/dist/react/Tree.d.ts +9 -2
- package/dist/react/Tree.d.ts.map +1 -1
- package/dist/react/Weather.d.ts +45 -0
- package/dist/react/Weather.d.ts.map +1 -0
- package/dist/react/Wind.d.ts +12 -1
- package/dist/react/Wind.d.ts.map +1 -1
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react.js +347 -10
- package/dist/react.js.map +1 -1
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/scene/antialias.d.ts +35 -0
- package/dist/scene/antialias.d.ts.map +1 -0
- package/dist/scene/ao.d.ts +46 -0
- package/dist/scene/ao.d.ts.map +1 -0
- package/dist/scene/bloom.d.ts +19 -0
- package/dist/scene/bloom.d.ts.map +1 -0
- package/dist/scene/fog.d.ts +49 -0
- package/dist/scene/fog.d.ts.map +1 -0
- package/dist/scene/godrays.d.ts +37 -0
- package/dist/scene/godrays.d.ts.map +1 -0
- package/dist/scene/index.d.ts +14 -0
- package/dist/scene/index.d.ts.map +1 -0
- package/dist/scene/motion-blur.d.ts +23 -0
- package/dist/scene/motion-blur.d.ts.map +1 -0
- package/dist/scene/pipeline.d.ts +109 -0
- package/dist/scene/pipeline.d.ts.map +1 -0
- package/dist/scene/settings.d.ts +36 -0
- package/dist/scene/settings.d.ts.map +1 -0
- package/dist/scene/stack.d.ts +25 -0
- package/dist/scene/stack.d.ts.map +1 -0
- package/dist/scene/stage.d.ts +52 -0
- package/dist/scene/stage.d.ts.map +1 -0
- package/dist/scene/suggested.d.ts +12 -0
- package/dist/scene/suggested.d.ts.map +1 -0
- package/dist/scene/tone-mapping.d.ts +20 -0
- package/dist/scene/tone-mapping.d.ts.map +1 -0
- package/dist/scene/velocity.d.ts +34 -0
- package/dist/scene/velocity.d.ts.map +1 -0
- package/dist/scene.js +889 -0
- package/dist/scene.js.map +1 -0
- package/dist/season/nodes.d.ts +13 -0
- package/dist/season/nodes.d.ts.map +1 -1
- package/dist/shader-hooks-BFRtlWGI.js +275 -0
- package/dist/shader-hooks-BFRtlWGI.js.map +1 -0
- package/dist/tree/Tree.d.ts +8 -3
- package/dist/tree/Tree.d.ts.map +1 -1
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/weather/index.d.ts +3 -0
- package/dist/weather/index.d.ts.map +1 -0
- package/dist/weather/shared.d.ts +43 -0
- package/dist/weather/shared.d.ts.map +1 -0
- package/dist/weather/snow.d.ts +87 -0
- package/dist/weather/snow.d.ts.map +1 -0
- package/dist/weather/wetness.d.ts +75 -0
- package/dist/weather/wetness.d.ts.map +1 -0
- package/dist/weather.js +288 -0
- package/dist/weather.js.map +1 -0
- package/dist/wind/Wind.d.ts +100 -5
- package/dist/wind/Wind.d.ts.map +1 -1
- package/dist/wind/burst.d.ts +28 -0
- package/dist/wind/burst.d.ts.map +1 -0
- package/dist/wind/index.d.ts +3 -2
- package/dist/wind/index.d.ts.map +1 -1
- package/dist/wind/motion.d.ts +30 -0
- package/dist/wind/motion.d.ts.map +1 -0
- package/dist/wind/node.d.ts +17 -3
- package/dist/wind/node.d.ts.map +1 -1
- package/package.json +9 -1
- package/dist/effects.js.map +0 -1
- package/dist/forest-ChEaWJrf.js.map +0 -1
package/dist/forest/nodes.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Node } from 'three/webgpu';
|
|
2
|
-
import { type WindResponse, type WindSource } from '../wind';
|
|
2
|
+
import { type WindBurstFrame, type WindResponse, type WindSource } from '../wind';
|
|
3
3
|
/**
|
|
4
4
|
* Per-instance data of a Forest (one interleaved instanced buffer, 8 floats per tree):
|
|
5
5
|
* `iRotation` = the tree's rotation as a quaternion (x, y, z, w);
|
|
@@ -10,6 +10,24 @@ export declare const INSTANCE_ATTRIBUTES: {
|
|
|
10
10
|
readonly iRotation: 0;
|
|
11
11
|
readonly iState: 4;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* What a mesh that draws one Detail Level of a Variant (ADR 0010) reads instead of the instanced
|
|
15
|
+
* attributes: the tree's data by slot, the slot coming from the level list at `instanceIndex`.
|
|
16
|
+
*/
|
|
17
|
+
export interface LevelInstance {
|
|
18
|
+
/** The tree's slot in the Variant (`uint`). */
|
|
19
|
+
slot: Node<'uint'>;
|
|
20
|
+
/** As `iRotation`. */
|
|
21
|
+
rotation: Node<'vec4'>;
|
|
22
|
+
/** As `iState`. */
|
|
23
|
+
state: Node<'vec4'>;
|
|
24
|
+
/** The tree's base in forest space. */
|
|
25
|
+
position: Node<'vec3'>;
|
|
26
|
+
/** The tree's cross-fade mask at this level (`bool`: draw this fragment), see `levelDither`. */
|
|
27
|
+
visible: Node<'bool'>;
|
|
28
|
+
}
|
|
29
|
+
/** @internal Marks `mesh` as drawing a Detail Level: every Forest node built for it reads `instance`. */
|
|
30
|
+
export declare function drawsDetailLevel(mesh: object, instance: LevelInstance): void;
|
|
13
31
|
/** Per-tree values in the instanced Season/Growth/Wind slots. */
|
|
14
32
|
export declare function instanceState(): {
|
|
15
33
|
scale: Node<'float'>;
|
|
@@ -17,8 +35,31 @@ export declare function instanceState(): {
|
|
|
17
35
|
season: Node<'float'>;
|
|
18
36
|
windPhase: Node<'float'>;
|
|
19
37
|
};
|
|
38
|
+
/** The tree's slot in its Variant (`uint`): the instance index on the instanced meshes, from the level list on a Detail Level mesh. */
|
|
39
|
+
export declare function instanceSlot(): Node<'uint'>;
|
|
40
|
+
/** Whether to draw this fragment: the Detail Level cross-fade (always true on the instanced meshes). */
|
|
41
|
+
export declare function levelVisible(): Node<'bool'>;
|
|
42
|
+
/**
|
|
43
|
+
* The tree's base in forest space, on a Detail Level mesh (the Impostor card places itself from it).
|
|
44
|
+
* Throws when built for any other object: the instanced meshes get their position from three.js.
|
|
45
|
+
*/
|
|
46
|
+
export declare function levelTreePosition(): Node<'vec3'>;
|
|
47
|
+
/**
|
|
48
|
+
* The tree's base in forest space, on the instanced meshes and the Detail Level meshes alike, as the
|
|
49
|
+
* vertex stage knows it before `positionNode` runs. On an InstancedMesh three.js only hands over the
|
|
50
|
+
* placed vertex (M·p), so the base is M·p − R·s·p, kept in a variable so that it is worked out before
|
|
51
|
+
* `positionNode` replaces `positionLocal`; on a Detail Level mesh it is the tree's data.
|
|
52
|
+
*/
|
|
53
|
+
export declare function instanceTreeBase(): Node<'vec3'>;
|
|
54
|
+
/** Rotates `v` by the quaternion `q` (`inverse` = by its conjugate). */
|
|
55
|
+
export declare function rotateByQuaternion(q: Node<'vec4'>, v: Node<'vec3'>, inverse?: boolean): Node<'vec3'>;
|
|
20
56
|
/** Rotates `v` by the instance quaternion (`inverse` = by its conjugate): tree space to forest space. */
|
|
21
57
|
export declare function instanceRotate(v: Node<'vec3'>, inverse?: boolean): Node<'vec3'>;
|
|
58
|
+
/**
|
|
59
|
+
* Where a Wind Burst finds a Forest tree: its own base (through the Forest's transform) and its own
|
|
60
|
+
* rotation, so each instance bends away from the burst point like a single Tree does.
|
|
61
|
+
*/
|
|
62
|
+
export declare function instanceBurstFrame(): WindBurstFrame;
|
|
22
63
|
/**
|
|
23
64
|
* The vertex position of a Forest tree (positionNode of an instanced Variant mesh).
|
|
24
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/forest/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/forest/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAGtD,OAAO,EAAqD,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrI;;;;GAIG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,mBAAmB;;;CAAuC,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA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IAAI,CAAC,MAAM,CAAC,CAE7E;AAiBD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,CAMnD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,GAAE,IAAI,CAAC,MAAM,CAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,CAkB5H"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type Vec3 = readonly [number, number, number];
|
|
2
|
+
/** A frame's camera: it looks along -forward, with `right` and `up` across its picture (right × up = forward). */
|
|
3
|
+
export interface FrameBasis {
|
|
4
|
+
right: Vec3;
|
|
5
|
+
up: Vec3;
|
|
6
|
+
forward: Vec3;
|
|
7
|
+
}
|
|
8
|
+
/** The (up to) four frames a view blends, with their weights (they sum to 1). */
|
|
9
|
+
export interface FrameBlend {
|
|
10
|
+
frames: [number, number][];
|
|
11
|
+
weights: number[];
|
|
12
|
+
}
|
|
13
|
+
/** A view direction (from the tree towards the viewer) on the unit square; views from below count as from the horizon. */
|
|
14
|
+
export declare function octahedralEncode(direction: Vec3): [number, number];
|
|
15
|
+
/** The unit direction at a point of the unit square (inverse of `octahedralEncode`). */
|
|
16
|
+
export declare function octahedralDecode(u: number, v: number): Vec3;
|
|
17
|
+
/** The direction frame (i, j) pictures the tree from. */
|
|
18
|
+
export declare function frameDirection(i: number, j: number, frames: number): Vec3;
|
|
19
|
+
/** The camera basis of a frame looking at the tree from `forward`. */
|
|
20
|
+
export declare function frameBasis(forward: Vec3): FrameBasis;
|
|
21
|
+
/**
|
|
22
|
+
* The four frames around a view direction and their bilinear weights, in the order (i, j), (i+1, j),
|
|
23
|
+
* (i, j+1), (i+1, j+1). On the grid's edge (and with one frame) the frames are clamped to the grid.
|
|
24
|
+
*/
|
|
25
|
+
export declare function blendFrames(view: Vec3, frames: number): FrameBlend;
|
|
26
|
+
/**
|
|
27
|
+
* Where frame `forward` pictured what is seen through `point` of the card (tree space, relative to
|
|
28
|
+
* the tree's centre) looking along `-view`: the line of sight meets the frame's plane (through the
|
|
29
|
+
* centre, facing `forward`) and that spot is projected onto the frame. In 0..1 across the frame,
|
|
30
|
+
* whose picture spans `2 · half` (the card's size).
|
|
31
|
+
*/
|
|
32
|
+
export declare function frameUv(point: Vec3, view: Vec3, forward: Vec3, half: number): [number, number];
|
|
33
|
+
//# sourceMappingURL=octahedral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"octahedral.d.ts","sourceRoot":"","sources":["../../src/forest/octahedral.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,kHAAkH;AAClH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,IAAI,CAAC;IACZ,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,IAAI,CAAC;CACf;AAED,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAqBD,0HAA0H;AAC1H,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAMlE;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3D;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAEzE;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,UAAU,CAIpD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAelE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAK9F"}
|