@casmo/tree.js 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +485 -2
- package/dist/bake/index.d.ts +39 -0
- package/dist/bake/index.d.ts.map +1 -0
- package/dist/definition/defaults.d.ts +9 -0
- package/dist/definition/defaults.d.ts.map +1 -0
- package/dist/definition/index.d.ts +5 -0
- package/dist/definition/index.d.ts.map +1 -0
- package/dist/definition/migrations.d.ts +12 -0
- package/dist/definition/migrations.d.ts.map +1 -0
- package/dist/definition/parse.d.ts +30 -0
- package/dist/definition/parse.d.ts.map +1 -0
- package/dist/definition/schema.d.ts +13 -0
- package/dist/definition/schema.d.ts.map +1 -0
- package/dist/definition/types.d.ts +217 -0
- package/dist/definition/types.d.ts.map +1 -0
- package/dist/effects/effects.d.ts +46 -0
- package/dist/effects/effects.d.ts.map +1 -0
- package/dist/effects/glow.d.ts +19 -0
- package/dist/effects/glow.d.ts.map +1 -0
- package/dist/effects/grade.d.ts +19 -0
- package/dist/effects/grade.d.ts.map +1 -0
- package/dist/effects/index.d.ts +7 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/mask.d.ts +44 -0
- package/dist/effects/mask.d.ts.map +1 -0
- package/dist/effects/outline.d.ts +18 -0
- package/dist/effects/outline.d.ts.map +1 -0
- package/dist/effects/suggested.d.ts +13 -0
- package/dist/effects/suggested.d.ts.map +1 -0
- package/dist/effects.js +249 -0
- package/dist/effects.js.map +1 -0
- package/dist/forest/Forest.d.ts +156 -0
- package/dist/forest/Forest.d.ts.map +1 -0
- package/dist/forest/index.d.ts +14 -0
- package/dist/forest/index.d.ts.map +1 -0
- package/dist/forest/nodes.d.ts +31 -0
- package/dist/forest/nodes.d.ts.map +1 -0
- package/dist/forest/placement.d.ts +52 -0
- package/dist/forest/placement.d.ts.map +1 -0
- package/dist/forest-OX9WvAwh.js +3057 -0
- package/dist/forest-OX9WvAwh.js.map +1 -0
- package/dist/generator/attributes.d.ts +20 -0
- package/dist/generator/attributes.d.ts.map +1 -0
- package/dist/generator/branches.d.ts +12 -0
- package/dist/generator/branches.d.ts.map +1 -0
- package/dist/generator/frames.d.ts +21 -0
- package/dist/generator/frames.d.ts.map +1 -0
- package/dist/generator/growth.d.ts +15 -0
- package/dist/generator/growth.d.ts.map +1 -0
- package/dist/generator/index.d.ts +22 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/leaf-shapes.d.ts +10 -0
- package/dist/generator/leaf-shapes.d.ts.map +1 -0
- package/dist/generator/leaves.d.ts +14 -0
- package/dist/generator/leaves.d.ts.map +1 -0
- package/dist/generator/mesh.d.ts +11 -0
- package/dist/generator/mesh.d.ts.map +1 -0
- package/dist/generator/sculpt.d.ts +28 -0
- package/dist/generator/sculpt.d.ts.map +1 -0
- package/dist/generator/trunk.d.ts +6 -0
- package/dist/generator/trunk.d.ts.map +1 -0
- package/dist/generator/types.d.ts +126 -0
- package/dist/generator/types.d.ts.map +1 -0
- package/dist/generator/vec.d.ts +12 -0
- package/dist/generator/vec.d.ts.map +1 -0
- package/dist/generator/wind.d.ts +27 -0
- package/dist/generator/wind.d.ts.map +1 -0
- package/dist/growth/evaluate.d.ts +32 -0
- package/dist/growth/evaluate.d.ts.map +1 -0
- package/dist/growth/index.d.ts +3 -0
- package/dist/growth/index.d.ts.map +1 -0
- package/dist/growth/tsl.d.ts +12 -0
- package/dist/growth/tsl.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +198 -0
- package/dist/index.js.map +1 -0
- package/dist/materials/index.d.ts +18 -0
- package/dist/materials/index.d.ts.map +1 -0
- package/dist/materials/maps.d.ts +23 -0
- package/dist/materials/maps.d.ts.map +1 -0
- package/dist/materials/shading.d.ts +18 -0
- package/dist/materials/shading.d.ts.map +1 -0
- package/dist/materials/toon.d.ts +12 -0
- package/dist/materials/toon.d.ts.map +1 -0
- package/dist/math/index.d.ts +23 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/profiles-BAiyeFlh.js +113 -0
- package/dist/profiles-BAiyeFlh.js.map +1 -0
- package/dist/random/index.d.ts +37 -0
- package/dist/random/index.d.ts.map +1 -0
- package/dist/react/Forest.d.ts +54 -0
- package/dist/react/Forest.d.ts.map +1 -0
- package/dist/react/Tree.d.ts +41 -0
- package/dist/react/Tree.d.ts.map +1 -0
- package/dist/react/Wind.d.ts +17 -0
- package/dist/react/Wind.d.ts.map +1 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/useTreeStyle.d.ts +15 -0
- package/dist/react/useTreeStyle.d.ts.map +1 -0
- package/dist/react.js +239 -0
- package/dist/react.js.map +1 -0
- package/dist/renderer/index.d.ts +7 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/season/check.d.ts +3 -0
- package/dist/season/check.d.ts.map +1 -0
- package/dist/season/index.d.ts +4 -0
- package/dist/season/index.d.ts.map +1 -0
- package/dist/season/nodes.d.ts +32 -0
- package/dist/season/nodes.d.ts.map +1 -0
- package/dist/season/profile.d.ts +78 -0
- package/dist/season/profile.d.ts.map +1 -0
- package/dist/season/profiles.d.ts +40 -0
- package/dist/season/profiles.d.ts.map +1 -0
- package/dist/styles/low-poly/index.d.ts +16 -0
- package/dist/styles/low-poly/index.d.ts.map +1 -0
- package/dist/styles/low-poly.js +165 -0
- package/dist/styles/low-poly.js.map +1 -0
- package/dist/styles/realistic/index.d.ts +23 -0
- package/dist/styles/realistic/index.d.ts.map +1 -0
- package/dist/styles/realistic.js +206 -0
- package/dist/styles/realistic.js.map +1 -0
- package/dist/styles/registry.d.ts +17 -0
- package/dist/styles/registry.d.ts.map +1 -0
- package/dist/styles/stylized/index.d.ts +17 -0
- package/dist/styles/stylized/index.d.ts.map +1 -0
- package/dist/styles/stylized.js +266 -0
- package/dist/styles/stylized.js.map +1 -0
- package/dist/styles/types.d.ts +12 -0
- package/dist/styles/types.d.ts.map +1 -0
- package/dist/textures/index.d.ts +44 -0
- package/dist/textures/index.d.ts.map +1 -0
- package/dist/textures/realistic/bark-normal.png +0 -0
- package/dist/textures/realistic/bark.png +0 -0
- package/dist/textures/realistic/leaf.png +0 -0
- package/dist/textures/realistic/needles.png +0 -0
- package/dist/tree/Tree.d.ts +70 -0
- package/dist/tree/Tree.d.ts.map +1 -0
- package/dist/tree/index.d.ts +14 -0
- package/dist/tree/index.d.ts.map +1 -0
- package/dist/types-BZjHhNz7.js +20 -0
- package/dist/types-BZjHhNz7.js.map +1 -0
- package/dist/wind/Wind.d.ts +54 -0
- package/dist/wind/Wind.d.ts.map +1 -0
- package/dist/wind/index.d.ts +4 -0
- package/dist/wind/index.d.ts.map +1 -0
- package/dist/wind/node.d.ts +38 -0
- package/dist/wind/node.d.ts.map +1 -0
- package/dist/wind/response.d.ts +27 -0
- package/dist/wind/response.d.ts.map +1 -0
- package/package.json +107 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"low-poly.js","names":[],"sources":["../../src/styles/low-poly/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/low-poly: faceted geometry, flat vertex colours, no image files.\n// Pure data (no library code beyond shared constants), so it stays a tiny chunk fetched only when imported.\nimport { CURRENT_SCHEMA_VERSION, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport type { TreeStyle } from '../types';\n\n/**\n * Low-poly broadleaf: a short, stout trunk and a few branches, crowned by faceted foliage\n * clumps. Deciduous Season Profile: fresh green in spring, autumn colours, bare in winter.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Low-poly broadleaf',\n form: 'broadleaf',\n trunk: { length: 3, radius: 0.22, taper: 0.5, sides: 5, sections: 3, lengthVariation: 0.15, bend: 0.12 },\n branches: [\n { count: 5, start: 0.5, end: 0.92, angle: 42, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.55, taper: 0.45, sides: 4, sections: 2, bend: 0.12, gravity: 0.15 },\n { count: 3, start: 0.35, end: 1, angle: 38, angleVariation: 0.25, spiral: 120, length: 0.55, lengthVariation: 0.25, radius: 0.6, taper: 0.4, sides: 3, sections: 1, bend: 0.1, gravity: 0.1 },\n ],\n leaves: { count: 2, shape: 'clump', size: 1, sizeVariation: 0.25, start: 0.55, angle: 25 },\n materials: {\n shading: 'flat',\n bark: { color: '#7a5233', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: SEASON_PROFILES.deciduous,\n wind: { trunk: 0.15, branches: 0.4, leaves: 0.5, frequency: 1 },\n variation: { color: 0.12, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Low-poly conifer: a straight trunk with drooping whorls that shrink towards the top\n * (the conifer Form), covered in faceted needle tufts. Evergreen Season Profile: it only darkens a little in winter.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Low-poly conifer',\n form: 'conifer',\n trunk: { length: 5, radius: 0.2, taper: 0.15, sides: 5, sections: 4, lengthVariation: 0.15, bend: 0.03 },\n branches: [\n { count: 24, start: 0.18, end: 0.97, angle: 95, angleVariation: 0.08, spiral: 137.5, length: 0.42, lengthVariation: 0.15, radius: 0.4, taper: 0.3, sides: 3, sections: 2, bend: 0.05, gravity: -0.08 },\n ],\n leaves: { count: 7, shape: 'needle', size: 0.65, sizeVariation: 0.2, start: 0, angle: 35 },\n materials: {\n shading: 'flat',\n bark: { color: '#5c4030', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: SEASON_PROFILES.evergreen,\n wind: { trunk: 0.1, branches: 0.3, leaves: 0.3, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The low-poly Style. */\nconst lowPoly: TreeStyle = { name: 'low-poly', broadleaf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AI,gBAAgB;EAAM,QAAQ;EAAO,QAAQ;EAAM,iBAAiB;EAAM,QAAQ;EAAK,OAAO;EAAK,OAAO;EAAG,UAAU;EAAG,MAAM;EAAM,SAAS;CAAM,CACvM;CACA,QAAQ;EAAE,OAAO;EAAG,OAAO;EAAU,MAAM;EAAM,eAAe;EAAK,OAAO;EAAG,OAAO;CAAG;CACzF,WAAW;EACT,SAAS;EACT,MAAM;GAAE,OAAO;GAAW,WAAW;GAAG,KAAK;GAAM,WAAW;EAAK;EACnE,MAAM;GAAE,WAAW;GAAG,KAAK;GAAM,WAAW;EAAI;CAClD;CACA,QAAQ,gBAAgB;CACxB,MAAM;EAAE,OAAO;EAAK,UAAU;EAAK,QAAQ;EAAK,WAAW;CAAI;CAC/D,WAAW;EAAE,OAAO;EAAM,QAAQ;EAAK,QAAQ;CAAK;CACpD,SAAS,CAAC;AACZ;;AAGA,IAAM,UAAqB;CAAE,MAAM;CAAY;CAAW;AAAQ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type TreeDefinition } from '../../definition/types';
|
|
2
|
+
import type { TreeStyle } from '../types';
|
|
3
|
+
/** The realistic Style's texture files, as relative URLs (resolved against the texture base path). */
|
|
4
|
+
export declare const TEXTURES: {
|
|
5
|
+
readonly bark: "realistic/bark.png";
|
|
6
|
+
readonly barkNormal: "realistic/bark-normal.png";
|
|
7
|
+
readonly leaf: "realistic/leaf.png";
|
|
8
|
+
readonly needles: "realistic/needles.png";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Realistic broadleaf: a tall, slightly leaning trunk with three branching levels and many
|
|
12
|
+
* leaf-spray cards. Deciduous Season Profile: fresh green in spring, autumn colours, bare in winter.
|
|
13
|
+
*/
|
|
14
|
+
export declare const broadleaf: TreeDefinition;
|
|
15
|
+
/**
|
|
16
|
+
* Realistic conifer: a straight trunk with dense, drooping whorls that shrink towards the top
|
|
17
|
+
* (the conifer Form), covered in needle-spray cards. Evergreen Season Profile.
|
|
18
|
+
*/
|
|
19
|
+
export declare const conifer: TreeDefinition;
|
|
20
|
+
/** The realistic Style. */
|
|
21
|
+
declare const realistic: TreeStyle;
|
|
22
|
+
export default realistic;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/styles/realistic/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAErF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,sGAAsG;AACtG,eAAO,MAAM,QAAQ;;;;;CAKX,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,cAoBvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,cAmBrB,CAAC;AAEF,2BAA2B;AAC3B,QAAA,MAAM,SAAS,EAAE,SAAqD,CAAC;AACvE,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import "../types-BZjHhNz7.js";
|
|
2
|
+
import { t as SEASON_PROFILES } from "../profiles-BAiyeFlh.js";
|
|
3
|
+
// src/styles/realistic/index.ts
|
|
4
|
+
/** The realistic Style's texture files, as relative URLs (resolved against the texture base path). */
|
|
5
|
+
var TEXTURES = {
|
|
6
|
+
bark: "realistic/bark.png",
|
|
7
|
+
barkNormal: "realistic/bark-normal.png",
|
|
8
|
+
leaf: "realistic/leaf.png",
|
|
9
|
+
needles: "realistic/needles.png"
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Realistic broadleaf: a tall, slightly leaning trunk with three branching levels and many
|
|
13
|
+
* leaf-spray cards. Deciduous Season Profile: fresh green in spring, autumn colours, bare in winter.
|
|
14
|
+
*/
|
|
15
|
+
var broadleaf = {
|
|
16
|
+
schemaVersion: 2,
|
|
17
|
+
name: "Realistic broadleaf",
|
|
18
|
+
form: "broadleaf",
|
|
19
|
+
trunk: {
|
|
20
|
+
length: 5,
|
|
21
|
+
radius: .28,
|
|
22
|
+
taper: .35,
|
|
23
|
+
sides: 12,
|
|
24
|
+
sections: 10,
|
|
25
|
+
lengthVariation: .15,
|
|
26
|
+
bend: .1
|
|
27
|
+
},
|
|
28
|
+
branches: [
|
|
29
|
+
{
|
|
30
|
+
count: 8,
|
|
31
|
+
start: .4,
|
|
32
|
+
end: .95,
|
|
33
|
+
angle: 48,
|
|
34
|
+
angleVariation: .2,
|
|
35
|
+
spiral: 137.5,
|
|
36
|
+
length: .5,
|
|
37
|
+
lengthVariation: .2,
|
|
38
|
+
radius: .5,
|
|
39
|
+
taper: .5,
|
|
40
|
+
sides: 8,
|
|
41
|
+
sections: 6,
|
|
42
|
+
bend: .15,
|
|
43
|
+
gravity: .05
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
count: 5,
|
|
47
|
+
start: .25,
|
|
48
|
+
end: 1,
|
|
49
|
+
angle: 40,
|
|
50
|
+
angleVariation: .25,
|
|
51
|
+
spiral: 120,
|
|
52
|
+
length: .5,
|
|
53
|
+
lengthVariation: .25,
|
|
54
|
+
radius: .55,
|
|
55
|
+
taper: .5,
|
|
56
|
+
sides: 5,
|
|
57
|
+
sections: 4,
|
|
58
|
+
bend: .15,
|
|
59
|
+
gravity: .1
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
count: 3,
|
|
63
|
+
start: .3,
|
|
64
|
+
end: 1,
|
|
65
|
+
angle: 35,
|
|
66
|
+
angleVariation: .3,
|
|
67
|
+
spiral: 140,
|
|
68
|
+
length: .5,
|
|
69
|
+
lengthVariation: .3,
|
|
70
|
+
radius: .6,
|
|
71
|
+
taper: .5,
|
|
72
|
+
sides: 3,
|
|
73
|
+
sections: 2,
|
|
74
|
+
bend: .1,
|
|
75
|
+
gravity: .15
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
leaves: {
|
|
79
|
+
count: 6,
|
|
80
|
+
shape: "card",
|
|
81
|
+
size: .7,
|
|
82
|
+
sizeVariation: .25,
|
|
83
|
+
start: .2,
|
|
84
|
+
angle: 45
|
|
85
|
+
},
|
|
86
|
+
materials: {
|
|
87
|
+
shading: "standard",
|
|
88
|
+
bark: {
|
|
89
|
+
color: "#c9bba8",
|
|
90
|
+
roughness: .95,
|
|
91
|
+
map: TEXTURES.bark,
|
|
92
|
+
normalMap: TEXTURES.barkNormal
|
|
93
|
+
},
|
|
94
|
+
leaf: {
|
|
95
|
+
roughness: .65,
|
|
96
|
+
map: TEXTURES.leaf,
|
|
97
|
+
alphaTest: .4
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
season: SEASON_PROFILES.deciduous,
|
|
101
|
+
wind: {
|
|
102
|
+
trunk: .15,
|
|
103
|
+
branches: .45,
|
|
104
|
+
leaves: .8,
|
|
105
|
+
frequency: 1
|
|
106
|
+
},
|
|
107
|
+
variation: {
|
|
108
|
+
color: .1,
|
|
109
|
+
growth: .1,
|
|
110
|
+
season: .05
|
|
111
|
+
},
|
|
112
|
+
sculpts: []
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Realistic conifer: a straight trunk with dense, drooping whorls that shrink towards the top
|
|
116
|
+
* (the conifer Form), covered in needle-spray cards. Evergreen Season Profile.
|
|
117
|
+
*/
|
|
118
|
+
var conifer = {
|
|
119
|
+
schemaVersion: 2,
|
|
120
|
+
name: "Realistic conifer",
|
|
121
|
+
form: "conifer",
|
|
122
|
+
trunk: {
|
|
123
|
+
length: 7,
|
|
124
|
+
radius: .24,
|
|
125
|
+
taper: .08,
|
|
126
|
+
sides: 10,
|
|
127
|
+
sections: 10,
|
|
128
|
+
lengthVariation: .12,
|
|
129
|
+
bend: .03
|
|
130
|
+
},
|
|
131
|
+
branches: [{
|
|
132
|
+
count: 34,
|
|
133
|
+
start: .12,
|
|
134
|
+
end: .97,
|
|
135
|
+
angle: 88,
|
|
136
|
+
angleVariation: .1,
|
|
137
|
+
spiral: 137.5,
|
|
138
|
+
length: .38,
|
|
139
|
+
lengthVariation: .15,
|
|
140
|
+
radius: .22,
|
|
141
|
+
taper: .25,
|
|
142
|
+
sides: 5,
|
|
143
|
+
sections: 4,
|
|
144
|
+
bend: .08,
|
|
145
|
+
gravity: .12
|
|
146
|
+
}, {
|
|
147
|
+
count: 6,
|
|
148
|
+
start: .15,
|
|
149
|
+
end: 1,
|
|
150
|
+
angle: 55,
|
|
151
|
+
angleVariation: .2,
|
|
152
|
+
spiral: 180,
|
|
153
|
+
length: .45,
|
|
154
|
+
lengthVariation: .2,
|
|
155
|
+
radius: .5,
|
|
156
|
+
taper: .4,
|
|
157
|
+
sides: 3,
|
|
158
|
+
sections: 2,
|
|
159
|
+
bend: .05,
|
|
160
|
+
gravity: .1
|
|
161
|
+
}],
|
|
162
|
+
leaves: {
|
|
163
|
+
count: 8,
|
|
164
|
+
shape: "card",
|
|
165
|
+
size: .8,
|
|
166
|
+
sizeVariation: .2,
|
|
167
|
+
start: 0,
|
|
168
|
+
angle: 35
|
|
169
|
+
},
|
|
170
|
+
materials: {
|
|
171
|
+
shading: "standard",
|
|
172
|
+
bark: {
|
|
173
|
+
color: "#b0a090",
|
|
174
|
+
roughness: .95,
|
|
175
|
+
map: TEXTURES.bark,
|
|
176
|
+
normalMap: TEXTURES.barkNormal
|
|
177
|
+
},
|
|
178
|
+
leaf: {
|
|
179
|
+
roughness: .7,
|
|
180
|
+
map: TEXTURES.needles,
|
|
181
|
+
alphaTest: .4
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
season: SEASON_PROFILES.evergreen,
|
|
185
|
+
wind: {
|
|
186
|
+
trunk: .08,
|
|
187
|
+
branches: .3,
|
|
188
|
+
leaves: .4,
|
|
189
|
+
frequency: .8
|
|
190
|
+
},
|
|
191
|
+
variation: {
|
|
192
|
+
color: .08,
|
|
193
|
+
growth: .1,
|
|
194
|
+
season: .05
|
|
195
|
+
},
|
|
196
|
+
sculpts: []
|
|
197
|
+
};
|
|
198
|
+
/** The realistic Style. */
|
|
199
|
+
var realistic = {
|
|
200
|
+
name: "realistic",
|
|
201
|
+
broadleaf,
|
|
202
|
+
conifer
|
|
203
|
+
};
|
|
204
|
+
export { TEXTURES, broadleaf, conifer, realistic as default };
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=realistic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realistic.js","names":[],"sources":["../../src/styles/realistic/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/realistic: smooth PBR shading, textured bark and alpha-cut leaf cards.\n// Pure data (no library code beyond shared constants), so it stays a tiny chunk fetched only when imported.\n// The textures are separate files (dist/textures/realistic/*.png, made by scripts/generate-textures.mjs),\n// referenced by relative URLs that resolve against the texture base path (`setTextureOptions`,\n// or `createTree(definition, { textures: { basePath } })`), so an app can host them on its own CDN.\nimport { CURRENT_SCHEMA_VERSION, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport type { TreeStyle } from '../types';\n\n/** The realistic Style's texture files, as relative URLs (resolved against the texture base path). */\nexport const TEXTURES = {\n bark: 'realistic/bark.png',\n barkNormal: 'realistic/bark-normal.png',\n leaf: 'realistic/leaf.png',\n needles: 'realistic/needles.png',\n} as const;\n\n/**\n * Realistic broadleaf: a tall, slightly leaning trunk with three branching levels and many\n * leaf-spray cards. Deciduous Season Profile: fresh green in spring, autumn colours, bare in winter.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Realistic broadleaf',\n form: 'broadleaf',\n trunk: { length: 5, radius: 0.28, taper: 0.35, sides: 12, sections: 10, lengthVariation: 0.15, bend: 0.1 },\n branches: [\n { count: 8, start: 0.4, end: 0.95, angle: 48, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.5, taper: 0.5, sides: 8, sections: 6, bend: 0.15, gravity: 0.05 },\n { count: 5, start: 0.25, end: 1, angle: 40, angleVariation: 0.25, spiral: 120, length: 0.5, lengthVariation: 0.25, radius: 0.55, taper: 0.5, sides: 5, sections: 4, bend: 0.15, gravity: 0.1 },\n { count: 3, start: 0.3, end: 1, angle: 35, angleVariation: 0.3, spiral: 140, length: 0.5, lengthVariation: 0.3, radius: 0.6, taper: 0.5, sides: 3, sections: 2, bend: 0.1, gravity: 0.15 },\n ],\n leaves: { count: 6, shape: 'card', size: 0.7, sizeVariation: 0.25, start: 0.2, angle: 45 },\n materials: {\n shading: 'standard',\n bark: { color: '#c9bba8', roughness: 0.95, map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n leaf: { roughness: 0.65, map: TEXTURES.leaf, alphaTest: 0.4 },\n },\n season: SEASON_PROFILES.deciduous,\n wind: { trunk: 0.15, branches: 0.45, leaves: 0.8, frequency: 1 },\n variation: { color: 0.1, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Realistic conifer: a straight trunk with dense, drooping whorls that shrink towards the top\n * (the conifer Form), covered in needle-spray cards. Evergreen Season Profile.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Realistic conifer',\n form: 'conifer',\n trunk: { length: 7, radius: 0.24, taper: 0.08, sides: 10, sections: 10, lengthVariation: 0.12, bend: 0.03 },\n branches: [\n { count: 34, start: 0.12, end: 0.97, angle: 88, angleVariation: 0.1, spiral: 137.5, length: 0.38, lengthVariation: 0.15, radius: 0.22, taper: 0.25, sides: 5, sections: 4, bend: 0.08, gravity: 0.12 },\n { count: 6, start: 0.15, end: 1, angle: 55, angleVariation: 0.2, spiral: 180, length: 0.45, lengthVariation: 0.2, radius: 0.5, taper: 0.4, sides: 3, sections: 2, bend: 0.05, gravity: 0.1 },\n ],\n leaves: { count: 8, shape: 'card', size: 0.8, sizeVariation: 0.2, start: 0, angle: 35 },\n materials: {\n shading: 'standard',\n bark: { color: '#b0a090', roughness: 0.95, map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n leaf: { roughness: 0.7, map: TEXTURES.needles, alphaTest: 0.4 },\n },\n season: SEASON_PROFILES.evergreen,\n wind: { trunk: 0.08, branches: 0.3, leaves: 0.4, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The realistic Style. */\nconst realistic: TreeStyle = { name: 'realistic', broadleaf, conifer };\nexport default realistic;\n"],"mappings":";;;;AAUA,IAAa,WAAW;CACtB,MAAM;CACN,YAAY;CACZ,MAAM;CACN,SAAS;AACX;;;;;AAMA,IAAa,YAA4B;CACvC,eAAA;CACA,MAAM;CACN,MAAM;CACN,OAAO;EAAE,QAAQ;EAAG,QAAQ;EAAM,OAAO;EAAM,OAAO;EAAI,UAAU;EAAI,iBAAiB;EAAM,MAAM;CAAI;CACzG,UAAU;EACR;GAAE,OAAO;GAAG,OAAO;GAAK,KAAK;GAAM,OAAO;GAAI,gBAAgB;GAAK,QAAQ;GAAO,QAAQ;GAAK,iBAAiB;GAAK,QAAQ;GAAK,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAM,SAAS;EAAK;EAC/L;GAAE,OAAO;GAAG,OAAO;GAAM,KAAK;GAAG,OAAO;GAAI,gBAAgB;GAAM,QAAQ;GAAK,QAAQ;GAAK,iBAAiB;GAAM,QAAQ;GAAM,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAM,SAAS;EAAI;EAC7L;GAAE,OAAO;GAAG,OAAO;GAAK,KAAK;GAAG,OAAO;GAAI,gBAAgB;GAAK,QAAQ;GAAK,QAAQ;GAAK,iBAAiB;GAAK,QAAQ;GAAK,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAK,SAAS;EAAK;CAC3L;CACA,QAAQ;EAAE,OAAO;EAAG,OAAO;EAAQ,MAAM;EAAK,eAAe;EAAM,OAAO;EAAK,OAAO;CAAG;CACzF,WAAW;EACT,SAAS;EACT,MAAM;GAAE,OAAO;GAAW,WAAW;GAAM,KA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AK;CACpD,SAAS,CAAC;AACZ;;AAGA,IAAM,YAAuB;CAAE,MAAM;CAAa;CAAW;AAAQ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TreeStyle } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The built-in Styles, each a lazily loaded chunk (`@casmo/tree.js/styles/<name>`).
|
|
4
|
+
* To add a Style: one line here (plus its vite entry and package.json export).
|
|
5
|
+
*/
|
|
6
|
+
export declare const STYLE_LOADERS: {
|
|
7
|
+
'low-poly': () => Promise<typeof import("./low-poly")>;
|
|
8
|
+
stylized: () => Promise<typeof import("./stylized")>;
|
|
9
|
+
realistic: () => Promise<typeof import("./realistic")>;
|
|
10
|
+
};
|
|
11
|
+
/** Name of a built-in Style, e.g. 'low-poly'. */
|
|
12
|
+
export type StyleName = keyof typeof STYLE_LOADERS;
|
|
13
|
+
/** Names of all built-in Styles. */
|
|
14
|
+
export declare const STYLE_NAMES: StyleName[];
|
|
15
|
+
/** Downloads a built-in Style (dynamic import) and resolves to it. Rejects for an unknown name. */
|
|
16
|
+
export declare function loadStyle(name: StyleName): Promise<TreeStyle>;
|
|
17
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/styles/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;CAIuC,CAAC;AAElE,iDAAiD;AACjD,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,aAAa,CAAC;AAEnD,oCAAoC;AACpC,eAAO,MAAM,WAAW,EAAiC,SAAS,EAAE,CAAC;AAErE,mGAAmG;AACnG,wBAAsB,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAInE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type TreeDefinition } from '../../definition/types';
|
|
2
|
+
import type { TreeStyle } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Stylized broadleaf: a curvy trunk with a round crown of big, soft foliage clumps.
|
|
5
|
+
* Flowers pink in early spring, then follows the deciduous year.
|
|
6
|
+
*/
|
|
7
|
+
export declare const broadleaf: TreeDefinition;
|
|
8
|
+
/**
|
|
9
|
+
* Stylized conifer: a straight trunk with soft, upturned whorls that shrink towards the top
|
|
10
|
+
* (the conifer Form), each carrying a few rounded clumps, so the tree reads as a stack of puffs.
|
|
11
|
+
* Evergreen: it only darkens a little in winter.
|
|
12
|
+
*/
|
|
13
|
+
export declare const conifer: TreeDefinition;
|
|
14
|
+
/** The stylized Style. */
|
|
15
|
+
declare const stylized: TreeStyle;
|
|
16
|
+
export default stylized;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/styles/stylized/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEnH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AA4C1C;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,cAmBvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,cAkBrB,CAAC;AAEF,0BAA0B;AAC1B,QAAA,MAAM,QAAQ,EAAE,SAAoD,CAAC;AACrE,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import "../types-BZjHhNz7.js";
|
|
2
|
+
import { t as SEASON_PROFILES } from "../profiles-BAiyeFlh.js";
|
|
3
|
+
// src/styles/stylized/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Deciduous with blossom: bright, saturated colours for the toon look. Pink blossom covers
|
|
6
|
+
* most of the crown in early spring (Season 0 .. ~0.12, opening in the last days of winter),
|
|
7
|
+
* then the leaves take over: fresh green, summer green, orange and red, bare in winter.
|
|
8
|
+
* Drop the blossom with `extendDefinition(broadleaf, { season: { blossom: [{ t: 0, value: 0 }] } })`.
|
|
9
|
+
*/
|
|
10
|
+
var blossoming = {
|
|
11
|
+
leafColor: [
|
|
12
|
+
{
|
|
13
|
+
t: 0,
|
|
14
|
+
value: "#a5d65a"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
t: .2,
|
|
18
|
+
value: "#55a83c"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
t: .5,
|
|
22
|
+
value: "#55a83c"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
t: .58,
|
|
26
|
+
value: "#f0a530"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
t: .68,
|
|
30
|
+
value: "#d9502e"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
t: .97,
|
|
34
|
+
value: "#d9502e"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
t: 1,
|
|
38
|
+
value: "#a5d65a"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
leafCoverage: SEASON_PROFILES.deciduous.leafCoverage,
|
|
42
|
+
blossom: [
|
|
43
|
+
{
|
|
44
|
+
t: 0,
|
|
45
|
+
value: .75
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
t: .08,
|
|
49
|
+
value: .75
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
t: .15,
|
|
53
|
+
value: 0
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
t: .95,
|
|
57
|
+
value: 0
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
t: 1,
|
|
61
|
+
value: .75
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
blossomColor: "#ffb3d1"
|
|
65
|
+
};
|
|
66
|
+
/** Evergreen in toon colours: full all year, a little darker in winter. */
|
|
67
|
+
var evergreen = {
|
|
68
|
+
leafColor: [
|
|
69
|
+
{
|
|
70
|
+
t: 0,
|
|
71
|
+
value: "#4f9a4a"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
t: .25,
|
|
75
|
+
value: "#3c8a45"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
t: .55,
|
|
79
|
+
value: "#3c8a45"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
t: .75,
|
|
83
|
+
value: "#2e6b40"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
t: .92,
|
|
87
|
+
value: "#2e6b40"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
t: 1,
|
|
91
|
+
value: "#4f9a4a"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
leafCoverage: [{
|
|
95
|
+
t: 0,
|
|
96
|
+
value: 1
|
|
97
|
+
}],
|
|
98
|
+
blossom: [{
|
|
99
|
+
t: 0,
|
|
100
|
+
value: 0
|
|
101
|
+
}],
|
|
102
|
+
blossomColor: "#ffb3d1"
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Stylized broadleaf: a curvy trunk with a round crown of big, soft foliage clumps.
|
|
106
|
+
* Flowers pink in early spring, then follows the deciduous year.
|
|
107
|
+
*/
|
|
108
|
+
var broadleaf = {
|
|
109
|
+
schemaVersion: 2,
|
|
110
|
+
name: "Stylized broadleaf",
|
|
111
|
+
form: "broadleaf",
|
|
112
|
+
trunk: {
|
|
113
|
+
length: 3.2,
|
|
114
|
+
radius: .24,
|
|
115
|
+
taper: .55,
|
|
116
|
+
sides: 10,
|
|
117
|
+
sections: 8,
|
|
118
|
+
lengthVariation: .15,
|
|
119
|
+
bend: .25
|
|
120
|
+
},
|
|
121
|
+
branches: [{
|
|
122
|
+
count: 6,
|
|
123
|
+
start: .45,
|
|
124
|
+
end: .9,
|
|
125
|
+
angle: 48,
|
|
126
|
+
angleVariation: .2,
|
|
127
|
+
spiral: 137.5,
|
|
128
|
+
length: .5,
|
|
129
|
+
lengthVariation: .2,
|
|
130
|
+
radius: .55,
|
|
131
|
+
taper: .5,
|
|
132
|
+
sides: 8,
|
|
133
|
+
sections: 5,
|
|
134
|
+
bend: .25,
|
|
135
|
+
gravity: .05
|
|
136
|
+
}, {
|
|
137
|
+
count: 3,
|
|
138
|
+
start: .4,
|
|
139
|
+
end: 1,
|
|
140
|
+
angle: 40,
|
|
141
|
+
angleVariation: .25,
|
|
142
|
+
spiral: 120,
|
|
143
|
+
length: .5,
|
|
144
|
+
lengthVariation: .25,
|
|
145
|
+
radius: .6,
|
|
146
|
+
taper: .45,
|
|
147
|
+
sides: 6,
|
|
148
|
+
sections: 3,
|
|
149
|
+
bend: .2,
|
|
150
|
+
gravity: 0
|
|
151
|
+
}],
|
|
152
|
+
leaves: {
|
|
153
|
+
count: 2,
|
|
154
|
+
shape: "puff",
|
|
155
|
+
size: 1.1,
|
|
156
|
+
sizeVariation: .3,
|
|
157
|
+
start: .6,
|
|
158
|
+
angle: 30
|
|
159
|
+
},
|
|
160
|
+
materials: {
|
|
161
|
+
shading: "toon",
|
|
162
|
+
bark: {
|
|
163
|
+
color: "#8a5a3b",
|
|
164
|
+
roughness: 1,
|
|
165
|
+
map: null,
|
|
166
|
+
normalMap: null
|
|
167
|
+
},
|
|
168
|
+
leaf: {
|
|
169
|
+
roughness: 1,
|
|
170
|
+
map: null,
|
|
171
|
+
alphaTest: .5
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
season: blossoming,
|
|
175
|
+
wind: {
|
|
176
|
+
trunk: .15,
|
|
177
|
+
branches: .45,
|
|
178
|
+
leaves: .6,
|
|
179
|
+
frequency: 1
|
|
180
|
+
},
|
|
181
|
+
variation: {
|
|
182
|
+
color: .1,
|
|
183
|
+
growth: .1,
|
|
184
|
+
season: .05
|
|
185
|
+
},
|
|
186
|
+
sculpts: []
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Stylized conifer: a straight trunk with soft, upturned whorls that shrink towards the top
|
|
190
|
+
* (the conifer Form), each carrying a few rounded clumps, so the tree reads as a stack of puffs.
|
|
191
|
+
* Evergreen: it only darkens a little in winter.
|
|
192
|
+
*/
|
|
193
|
+
var conifer = {
|
|
194
|
+
schemaVersion: 2,
|
|
195
|
+
name: "Stylized conifer",
|
|
196
|
+
form: "conifer",
|
|
197
|
+
trunk: {
|
|
198
|
+
length: 5,
|
|
199
|
+
radius: .2,
|
|
200
|
+
taper: .2,
|
|
201
|
+
sides: 8,
|
|
202
|
+
sections: 6,
|
|
203
|
+
lengthVariation: .15,
|
|
204
|
+
bend: .05
|
|
205
|
+
},
|
|
206
|
+
branches: [{
|
|
207
|
+
count: 18,
|
|
208
|
+
start: .15,
|
|
209
|
+
end: .97,
|
|
210
|
+
angle: 85,
|
|
211
|
+
angleVariation: .1,
|
|
212
|
+
spiral: 137.5,
|
|
213
|
+
length: .5,
|
|
214
|
+
lengthVariation: .1,
|
|
215
|
+
radius: .4,
|
|
216
|
+
taper: .35,
|
|
217
|
+
sides: 5,
|
|
218
|
+
sections: 3,
|
|
219
|
+
bend: .1,
|
|
220
|
+
gravity: .05
|
|
221
|
+
}],
|
|
222
|
+
leaves: {
|
|
223
|
+
count: 4,
|
|
224
|
+
shape: "puff",
|
|
225
|
+
size: .6,
|
|
226
|
+
sizeVariation: .2,
|
|
227
|
+
start: .1,
|
|
228
|
+
angle: 20
|
|
229
|
+
},
|
|
230
|
+
materials: {
|
|
231
|
+
shading: "toon",
|
|
232
|
+
bark: {
|
|
233
|
+
color: "#6e4a35",
|
|
234
|
+
roughness: 1,
|
|
235
|
+
map: null,
|
|
236
|
+
normalMap: null
|
|
237
|
+
},
|
|
238
|
+
leaf: {
|
|
239
|
+
roughness: 1,
|
|
240
|
+
map: null,
|
|
241
|
+
alphaTest: .5
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
season: evergreen,
|
|
245
|
+
wind: {
|
|
246
|
+
trunk: .1,
|
|
247
|
+
branches: .3,
|
|
248
|
+
leaves: .4,
|
|
249
|
+
frequency: .8
|
|
250
|
+
},
|
|
251
|
+
variation: {
|
|
252
|
+
color: .08,
|
|
253
|
+
growth: .1,
|
|
254
|
+
season: .05
|
|
255
|
+
},
|
|
256
|
+
sculpts: []
|
|
257
|
+
};
|
|
258
|
+
/** The stylized Style. */
|
|
259
|
+
var stylized = {
|
|
260
|
+
name: "stylized",
|
|
261
|
+
broadleaf,
|
|
262
|
+
conifer
|
|
263
|
+
};
|
|
264
|
+
export { broadleaf, conifer, stylized as default };
|
|
265
|
+
|
|
266
|
+
//# sourceMappingURL=stylized.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylized.js","names":[],"sources":["../../src/styles/stylized/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/stylized: soft toon shading, rounded leaf clumps, blossom in early spring, no image files.\n// Pure data (no library code beyond shared constants), so it stays a tiny chunk fetched only when imported.\nimport { CURRENT_SCHEMA_VERSION, type SeasonProfileDefinition, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport type { TreeStyle } from '../types';\n\n/**\n * Deciduous with blossom: bright, saturated colours for the toon look. Pink blossom covers\n * most of the crown in early spring (Season 0 .. ~0.12, opening in the last days of winter),\n * then the leaves take over: fresh green, summer green, orange and red, bare in winter.\n * Drop the blossom with `extendDefinition(broadleaf, { season: { blossom: [{ t: 0, value: 0 }] } })`.\n */\nconst blossoming: SeasonProfileDefinition = {\n leafColor: [\n { t: 0, value: '#a5d65a' },\n { t: 0.2, value: '#55a83c' },\n { t: 0.5, value: '#55a83c' },\n { t: 0.58, value: '#f0a530' },\n { t: 0.68, value: '#d9502e' },\n { t: 0.97, value: '#d9502e' },\n { t: 1, value: '#a5d65a' },\n ],\n leafCoverage: SEASON_PROFILES.deciduous.leafCoverage,\n blossom: [\n { t: 0, value: 0.75 },\n { t: 0.08, value: 0.75 },\n { t: 0.15, value: 0 },\n { t: 0.95, value: 0 },\n { t: 1, value: 0.75 },\n ],\n blossomColor: '#ffb3d1',\n};\n\n/** Evergreen in toon colours: full all year, a little darker in winter. */\nconst evergreen: SeasonProfileDefinition = {\n leafColor: [\n { t: 0, value: '#4f9a4a' },\n { t: 0.25, value: '#3c8a45' },\n { t: 0.55, value: '#3c8a45' },\n { t: 0.75, value: '#2e6b40' },\n { t: 0.92, value: '#2e6b40' },\n { t: 1, value: '#4f9a4a' },\n ],\n leafCoverage: [{ t: 0, value: 1 }],\n blossom: [{ t: 0, value: 0 }],\n blossomColor: '#ffb3d1',\n};\n\n/**\n * Stylized broadleaf: a curvy trunk with a round crown of big, soft foliage clumps.\n * Flowers pink in early spring, then follows the deciduous year.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Stylized broadleaf',\n form: 'broadleaf',\n trunk: { length: 3.2, radius: 0.24, taper: 0.55, sides: 10, sections: 8, lengthVariation: 0.15, bend: 0.25 },\n branches: [\n { count: 6, start: 0.45, end: 0.9, angle: 48, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.55, taper: 0.5, sides: 8, sections: 5, bend: 0.25, gravity: 0.05 },\n { count: 3, start: 0.4, end: 1, angle: 40, angleVariation: 0.25, spiral: 120, length: 0.5, lengthVariation: 0.25, radius: 0.6, taper: 0.45, sides: 6, sections: 3, bend: 0.2, gravity: 0 },\n ],\n leaves: { count: 2, shape: 'puff', size: 1.1, sizeVariation: 0.3, start: 0.6, angle: 30 },\n materials: {\n shading: 'toon',\n bark: { color: '#8a5a3b', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: blossoming,\n wind: { trunk: 0.15, branches: 0.45, leaves: 0.6, frequency: 1 },\n variation: { color: 0.1, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Stylized conifer: a straight trunk with soft, upturned whorls that shrink towards the top\n * (the conifer Form), each carrying a few rounded clumps, so the tree reads as a stack of puffs.\n * Evergreen: it only darkens a little in winter.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Stylized conifer',\n form: 'conifer',\n trunk: { length: 5, radius: 0.2, taper: 0.2, sides: 8, sections: 6, lengthVariation: 0.15, bend: 0.05 },\n branches: [\n { count: 18, start: 0.15, end: 0.97, angle: 85, angleVariation: 0.1, spiral: 137.5, length: 0.5, lengthVariation: 0.1, radius: 0.4, taper: 0.35, sides: 5, sections: 3, bend: 0.1, gravity: 0.05 },\n ],\n leaves: { count: 4, shape: 'puff', size: 0.6, sizeVariation: 0.2, start: 0.1, angle: 20 },\n materials: {\n shading: 'toon',\n bark: { color: '#6e4a35', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: evergreen,\n wind: { trunk: 0.1, branches: 0.3, leaves: 0.4, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The stylized Style. */\nconst stylized: TreeStyle = { name: 'stylized', broadleaf, conifer };\nexport default stylized;\n"],"mappings":";;;;;;;;;AAYA,IAAM,aAAsC;CAC1C,WAAW;EACT;GAAE,GAAG;GAAG,OAAO;EAAU;EACzB;GAAE,GAAG;GAAK,OAAO;EAAU;EAC3B;GAAE,GAAG;GAAK,OAAO;EAAU;EAC3B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAG,OAAO;EAAU;CAC3B;CACA,cAAc,gBAAgB,UAAU;CACxC,SAAS;EACP;GAAE,GAAG;GAAG,OAAO;EAAK;EACpB;GAAE,GAAG;GAAM,OAAO;EAAK;EACvB;GAAE,GAAG;GAAM,OAAO;EAAE;EACpB;GAAE,GAAG;GAAM,OAAO;EAAE;EACpB;GAAE,GAAG;GAAG,OAAO;EAAK;CACtB;CACA,cAAc;AACh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AU;EAAM,QAAQ;EAAK,WAAW;CAAE;CAC/D,WAAW;EAAE,OAAO;EAAK,QAAQ;EAAK,QAAQ;CAAK;CACnD,SAAS,CAAC;AACZ;;;;;;AAOA,IAAa,UAA0B;CACrC,eAAA;CACA,MAAM;CACN,MAAM;CACN,OAAO;EAAE,QAAQ;EAAG,QAAQ;EAAK,OAAO;EAAK,OAAO;EAAG,UAAU;EAAG,iBAAiB;EAAM,MAAM;CAAK;CACtG,UAAU,CACR;EAAE,OAAO;EAAI,OAAO;EAAM,KAAK;EAAM,OAAO;EAAI,gBAAgB;EAAK,QAAQ;EAAO,QAAQ;EAAK,iBAAiB;EAAK,QAAQ;EAAK,OAAO;EAAM,OAAO;EAAG,UAAU;EAAG,MAAM;EAAK,SAAS;CAAK,CACnM;CACA,QAAQ;EAAE,OAAO;EAAG,OAAO;EAAQ,MAAM;EAAK,eAAe;EAAK,OAAO;EAAK,OAAO;CAAG;CACxF,WAAW;EACT,SAAS;EACT,MAAM;GAAE,OAAO;GAAW,WAAW;GAAG,KAAK;GAAM,WAAW;EAAK;EACnE,MAAM;GAAE,WAAW;GAAG,KAAK;GAAM,WAAW;EAAI;CAClD;CACA,QAAQ;CACR,MAAM;EAAE,OAAO;EAAK,UAAU;EAAK,QAAQ;EAAK,WAAW;CAAI;CAC/D,WAAW;EAAE,OAAO;EAAM,QAAQ;EAAK,QAAQ;CAAK;CACpD,SAAS,CAAC;AACZ;;AAGA,IAAM,WAAsB;CAAE,MAAM;CAAY;CAAW;AAAQ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TreeDefinition } from '../definition';
|
|
2
|
+
/**
|
|
3
|
+
* A Style: a visual look shipped with the library, as one ready-made Tree Definition per Form.
|
|
4
|
+
* Each built-in Style is its own subpath (`@casmo/tree.js/styles/<name>`), loaded with a dynamic
|
|
5
|
+
* `import()`, whose default export is the Style and whose named exports are its Definitions.
|
|
6
|
+
*/
|
|
7
|
+
export interface TreeStyle {
|
|
8
|
+
name: string;
|
|
9
|
+
broadleaf: TreeDefinition;
|
|
10
|
+
conifer: TreeDefinition;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/styles/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;CACzB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Texture } from 'three/webgpu';
|
|
2
|
+
/**
|
|
3
|
+
* The URL of the package's bundled textures (the realistic Style's bark and leaf cards), as
|
|
4
|
+
* shipped in `dist/textures/`. Relative texture URLs in a Definition resolve against it unless
|
|
5
|
+
* the app sets its own `basePath`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_TEXTURE_BASE_PATH: string;
|
|
8
|
+
/**
|
|
9
|
+
* Where tree textures are loaded from. Texture URLs in a Tree Definition (`materials.bark.map`,
|
|
10
|
+
* `materials.bark.normalMap`, `materials.leaf.map`) are either absolute (`https://…`, `/…`,
|
|
11
|
+
* `data:`, `blob:`), used as they are, or relative (`realistic/bark.png`), resolved against
|
|
12
|
+
* `basePath`.
|
|
13
|
+
*/
|
|
14
|
+
export interface TextureOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Base path or URL for relative texture URLs, e.g. `'https://cdn.example.com/tree-textures/'`
|
|
17
|
+
* after copying `node_modules/@casmo/tree.js/dist/textures/` there. Default: the package's own
|
|
18
|
+
* `dist/textures/` (`DEFAULT_TEXTURE_BASE_PATH`).
|
|
19
|
+
*/
|
|
20
|
+
basePath?: string;
|
|
21
|
+
/** Per-texture overrides, keyed by the URL as written in the Definition (e.g. `'realistic/bark.png'`). */
|
|
22
|
+
urls?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sets the app-wide texture options (base path / URL overrides) used by every tree created
|
|
26
|
+
* afterwards. Options passed to `createTree(…, { textures })` take precedence.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setTextureOptions(options: TextureOptions): void;
|
|
29
|
+
/** The app-wide texture options set with `setTextureOptions`. */
|
|
30
|
+
export declare function getTextureOptions(): TextureOptions;
|
|
31
|
+
/** The URL a Definition's texture URL is loaded from, after URL overrides and the base path. */
|
|
32
|
+
export declare function resolveTextureUrl(url: string, options?: TextureOptions): string;
|
|
33
|
+
/** What a texture holds: colour (sRGB) or data such as a normal map (linear). */
|
|
34
|
+
export type TextureKind = 'color' | 'data';
|
|
35
|
+
/**
|
|
36
|
+
* Loads a texture from an already resolved URL. Textures are shared: the same URL and kind
|
|
37
|
+
* give the same `Texture` (trees don't dispose them). `texture.name` is the URL. The image
|
|
38
|
+
* loads asynchronously; `textureReady(texture)` resolves once it is there. Outside a browser
|
|
39
|
+
* (no DOM, e.g. Node tests) the texture is created without an image.
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadTexture(url: string, kind: TextureKind): Texture;
|
|
42
|
+
/** Resolves when a texture from `loadTexture` has its image (rejects if it failed to load). */
|
|
43
|
+
export declare function textureReady(texture: Texture): Promise<void>;
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/textures/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,OAAO,EAAiB,MAAM,cAAc,CAAC;AAcpG;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAA+C,CAAC;AAExF;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0GAA0G;IAC1G,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAE/D;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,IAAI,cAAc,CAElD;AAID,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,MAAM,CAMnF;AAED,iFAAiF;AACjF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAK3C;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CA2BnE;AAED,+FAA+F;AAC/F,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|