webgpu-stage 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 +10 -2
- package/lib/atmosphere.d.ts +100 -0
- package/lib/atmosphere.d.ts.map +1 -0
- package/lib/atmosphere.js +367 -0
- package/lib/atmosphere.js.map +1 -0
- package/lib/boot.d.ts +20 -0
- package/lib/boot.d.ts.map +1 -0
- package/lib/boot.js +85 -0
- package/lib/boot.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/look.d.ts +154 -0
- package/lib/look.d.ts.map +1 -0
- package/lib/look.js +420 -0
- package/lib/look.js.map +1 -0
- package/lib/pipeline.d.ts +36 -0
- package/lib/pipeline.d.ts.map +1 -0
- package/lib/pipeline.js +285 -0
- package/lib/pipeline.js.map +1 -0
- package/lib/pipelines.d.ts +10 -0
- package/lib/pipelines.d.ts.map +1 -0
- package/lib/pipelines.js +141 -0
- package/lib/pipelines.js.map +1 -0
- package/lib/sunshadow.d.ts +52 -0
- package/lib/sunshadow.d.ts.map +1 -0
- package/lib/sunshadow.js +150 -0
- package/lib/sunshadow.js.map +1 -0
- package/lib/tsl.d.ts +20 -0
- package/lib/tsl.d.ts.map +1 -0
- package/lib/tsl.js +98 -0
- package/lib/tsl.js.map +1 -0
- package/package.json +58 -3
package/lib/boot.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// WebGPU renderer initialization (with reversed depth, adapter limits, and async pipeline hooks).
|
|
2
|
+
import * as THREE from "three/webgpu";
|
|
3
|
+
import { makePipelinesAsync } from "./pipelines.js";
|
|
4
|
+
export const REVERSED_DEPTH = typeof location === "undefined" || !new URLSearchParams(location.search).has("plaindepth");
|
|
5
|
+
/**
|
|
6
|
+
* Initialize `THREE.WebGPURenderer` on `canvas`, or return `null` (cloning `canvas` so
|
|
7
|
+
* a caller with a WebGL2 fallback can still acquire a WebGL2 context).
|
|
8
|
+
*/
|
|
9
|
+
export async function initWebGpuRenderer(canvas, options = {}) {
|
|
10
|
+
if (typeof navigator === "undefined" || !("gpu" in navigator))
|
|
11
|
+
return null;
|
|
12
|
+
let adapter = null;
|
|
13
|
+
try {
|
|
14
|
+
adapter = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
adapter = null;
|
|
18
|
+
}
|
|
19
|
+
if (!adapter)
|
|
20
|
+
return null;
|
|
21
|
+
let renderer = null;
|
|
22
|
+
const giveUp = (why) => {
|
|
23
|
+
console.warn("[webgpu] not available here:", why);
|
|
24
|
+
try {
|
|
25
|
+
renderer?.dispose();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Ignore partial init dispose failures.
|
|
29
|
+
}
|
|
30
|
+
canvas.replaceWith(canvas.cloneNode(false));
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
try {
|
|
34
|
+
renderer = new THREE.WebGPURenderer({
|
|
35
|
+
canvas,
|
|
36
|
+
antialias: options.antialias ?? true,
|
|
37
|
+
powerPreference: "high-performance",
|
|
38
|
+
trackTimestamp: options.timestamps ?? false,
|
|
39
|
+
reversedDepthBuffer: REVERSED_DEPTH,
|
|
40
|
+
requiredLimits: {
|
|
41
|
+
maxSampledTexturesPerShaderStage: adapter.limits.maxSampledTexturesPerShaderStage,
|
|
42
|
+
maxSamplersPerShaderStage: adapter.limits.maxSamplersPerShaderStage,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
await renderer.init();
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
return giveUp(err);
|
|
49
|
+
}
|
|
50
|
+
if (!renderer.backend.isWebGPUBackend) {
|
|
51
|
+
return giveUp("three chose its WebGL2 backend");
|
|
52
|
+
}
|
|
53
|
+
const whenLost = renderer.onDeviceLost.bind(renderer);
|
|
54
|
+
renderer.onDeviceLost = (info) => {
|
|
55
|
+
whenLost(info);
|
|
56
|
+
if (info.reason !== "destroyed") {
|
|
57
|
+
options.onDeviceLost?.(`${info.api} device lost: ${info.message || info.reason || "no reason given"}`);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
makePipelinesAsync(renderer);
|
|
61
|
+
const info = adapter.info;
|
|
62
|
+
const chip = [info?.vendor, info?.architecture].filter(Boolean).join(" ");
|
|
63
|
+
const backendLabel = chip ? `WebGPU · ${chip}` : "WebGPU";
|
|
64
|
+
return {
|
|
65
|
+
renderer,
|
|
66
|
+
backendLabel,
|
|
67
|
+
dispose: () => {
|
|
68
|
+
renderer?.setAnimationLoop(null);
|
|
69
|
+
renderer?.dispose();
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Pure-WebGPU boot helper that throws if WebGPU is unavailable. */
|
|
74
|
+
export async function bootWebGpu(canvas, options = {}) {
|
|
75
|
+
const boot = await initWebGpuRenderer(canvas, options);
|
|
76
|
+
if (!boot) {
|
|
77
|
+
throw new Error("WebGPU is not available in this browser.");
|
|
78
|
+
}
|
|
79
|
+
boot.renderer.setPixelRatio(Math.min(typeof devicePixelRatio === "number" ? devicePixelRatio : 1, 2));
|
|
80
|
+
if (typeof innerWidth === "number" && innerWidth > 0 && innerHeight > 0) {
|
|
81
|
+
boot.renderer.setSize(innerWidth, innerHeight, false);
|
|
82
|
+
}
|
|
83
|
+
return boot;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=boot.js.map
|
package/lib/boot.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAElG,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,CAAC,MAAM,cAAc,GACzB,O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Q,EAAE,OAAO,EAAE,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAyB,EACzB,OAAO,GAAsB,EAAE;IAE/B,MAAM,IAAI,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,GAAG,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;QACxE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// WebGPU renderer initialization (with reversed depth, adapter limits, and async pipeline hooks).\n\nimport * as THREE from \"three/webgpu\";\nimport { makePipelinesAsync } from \"./pipelines.ts\";\n\nexport const REVERSED_DEPTH =\n typeof location === \"undefined\" || !new URLSearchParams(location.search).has(\"plaindepth\");\n\nexport interface WebGpuBoot {\n renderer: THREE.WebGPURenderer;\n backendLabel: string;\n dispose: () => void;\n}\n\nexport interface WebGpuBootOptions {\n antialias?: boolean;\n timestamps?: boolean;\n onDeviceLost?: (reason: string) => void;\n}\n\n/**\n * Initialize `THREE.WebGPURenderer` on `canvas`, or return `null` (cloning `canvas` so\n * a caller with a WebGL2 fallback can still acquire a WebGL2 context).\n */\nexport async function initWebGpuRenderer(\n canvas: HTMLCanvasElement,\n options: WebGpuBootOptions = {},\n): Promise<WebGpuBoot | null> {\n if (typeof navigator === \"undefined\" || !(\"gpu\" in navigator)) return null;\n let adapter: GPUAdapter | null = null;\n try {\n adapter = await navigator.gpu.requestAdapter({ powerPreference: \"high-performance\" });\n } catch {\n adapter = null;\n }\n if (!adapter) return null;\n\n let renderer: THREE.WebGPURenderer | null = null;\n const giveUp = (why: unknown): null => {\n console.warn(\"[webgpu] not available here:\", why);\n try {\n renderer?.dispose();\n } catch {\n // Ignore partial init dispose failures.\n }\n canvas.replaceWith(canvas.cloneNode(false));\n return null;\n };\n\n try {\n renderer = new THREE.WebGPURenderer({\n canvas,\n antialias: options.antialias ?? true,\n powerPreference: \"high-performance\",\n trackTimestamp: options.timestamps ?? false,\n reversedDepthBuffer: REVERSED_DEPTH,\n requiredLimits: {\n maxSampledTexturesPerShaderStage: adapter.limits.maxSampledTexturesPerShaderStage,\n maxSamplersPerShaderStage: adapter.limits.maxSamplersPerShaderStage,\n },\n } as ConstructorParameters<typeof THREE.WebGPURenderer>[0]);\n await renderer.init();\n } catch (err) {\n return giveUp(err);\n }\n\n if (!(renderer.backend as { isWebGPUBackend?: boolean }).isWebGPUBackend) {\n return giveUp(\"three chose its WebGL2 backend\");\n }\n\n const whenLost = renderer.onDeviceLost.bind(renderer);\n renderer.onDeviceLost = (info) => {\n whenLost(info);\n if (info.reason !== \"destroyed\") {\n options.onDeviceLost?.(`${info.api} device lost: ${info.message || info.reason || \"no reason given\"}`);\n }\n };\n\n makePipelinesAsync(renderer);\n\n const info = adapter.info;\n const chip = [info?.vendor, info?.architecture].filter(Boolean).join(\" \");\n const backendLabel = chip ? `WebGPU · ${chip}` : \"WebGPU\";\n\n return {\n renderer,\n backendLabel,\n dispose: () => {\n renderer?.setAnimationLoop(null);\n renderer?.dispose();\n },\n };\n}\n\n/** Pure-WebGPU boot helper that throws if WebGPU is unavailable. */\nexport async function bootWebGpu(\n canvas: HTMLCanvasElement,\n options: WebGpuBootOptions = {},\n): Promise<WebGpuBoot> {\n const boot = await initWebGpuRenderer(canvas, options);\n if (!boot) {\n throw new Error(\"WebGPU is not available in this browser.\");\n }\n boot.renderer.setPixelRatio(Math.min(typeof devicePixelRatio === \"number\" ? devicePixelRatio : 1, 2));\n if (typeof innerWidth === \"number\" && innerWidth > 0 && innerHeight > 0) {\n boot.renderer.setSize(innerWidth, innerHeight, false);\n }\n return boot;\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { REVERSED_DEPTH, bootWebGpu, initWebGpuRenderer, type WebGpuBoot, type WebGpuBootOptions, } from "./boot.js";
|
|
2
|
+
export { BENCH, SAND_GRAIN, SAND_SPECK, benchGate, hash21Tsl, makeDummyRgbaTex, smoothFieldTsl, swappableTexture, textureKind, typedWgslFn, uBenchEager, wgslSandGrainFn, type SwappableTexture, } from "./tsl.js";
|
|
3
|
+
export { gpuSettled, makePipelinesAsync, pipelinesOf, type AsyncPipelines } from "./pipelines.js";
|
|
4
|
+
export { EARLY_LIGHT, LOOK_GRADES, PARK_DEFAULT_LOOK, PLEIN_AIR, bakeGroundHeightsAndCanopy, colour, graded, installPaperGrain, makeClassicLook, makeCloudTexture, makeRidgeTexture, noiseTexture, relightCloudTexture, resolveLook, resolveVenueLooks, seeded, tileNoise, type CourseLook, type Grade, type Look, type LookGrade, type PaperGrainOptions, type Skyline, type Style, type Tint, type VenueLook, } from "./look.js";
|
|
5
|
+
export { buildTslSky, createSkyDomeMesh, createTslAtmosphere, wgslCanopyDappleFn, wgslSunShadowEvalFn, wgslTreeShadowUvFn, type AtmosphereFrameSync, type AtmosphereInit, type SkyDomeMeshOptions, type TslAtmosphere, } from "./atmosphere.js";
|
|
6
|
+
export { SunShadowPass, VisibilityGuard, snapOrthoShadowCamera, type ShadowCasterActor, type SnapOrthoShadowCameraOptions, type SunShadowAtmosphereTarget, } from "./sunshadow.js";
|
|
7
|
+
export { closeFocusTsl, createWebGpuPipeline, finishTsl, softForegroundTsl, wgslContactShadowEvalFn, type PipelineAtmosphereInputs, type WebGpuPipeline, } from "./pipeline.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,iBAAiB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,WAAW,EACX,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EACL,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,0BAA0B,EAC1B,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,MAAM,EACN,SAAS,EACT,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,SAAS,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,GAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { REVERSED_DEPTH, bootWebGpu, initWebGpuRenderer, } from "./boot.js";
|
|
2
|
+
export { BENCH, SAND_GRAIN, SAND_SPECK, benchGate, hash21Tsl, makeDummyRgbaTex, smoothFieldTsl, swappableTexture, textureKind, typedWgslFn, uBenchEager, wgslSandGrainFn, } from "./tsl.js";
|
|
3
|
+
export { gpuSettled, makePipelinesAsync, pipelinesOf } from "./pipelines.js";
|
|
4
|
+
export { EARLY_LIGHT, LOOK_GRADES, PARK_DEFAULT_LOOK, PLEIN_AIR, bakeGroundHeightsAndCanopy, colour, graded, installPaperGrain, makeClassicLook, makeCloudTexture, makeRidgeTexture, noiseTexture, relightCloudTexture, resolveLook, resolveVenueLooks, seeded, tileNoise, } from "./look.js";
|
|
5
|
+
export { buildTslSky, createSkyDomeMesh, createTslAtmosphere, wgslCanopyDappleFn, wgslSunShadowEvalFn, wgslTreeShadowUvFn, } from "./atmosphere.js";
|
|
6
|
+
export { SunShadowPass, VisibilityGuard, snapOrthoShadowCamera, } from "./sunshadow.js";
|
|
7
|
+
export { closeFocusTsl, createWebGpuPipeline, finishTsl, softForegroundTsl, wgslContactShadowEvalFn, } from "./pipeline.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,kBAAkB,GAGnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,WAAW,EACX,eAAe,GAEhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAClG,OAAO,EACL,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,0BAA0B,EAC1B,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,MAAM,EACN,SAAS,GAUV,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GAKnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,eAAe,EACf,qBAAqB,GAItB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EACjB,uBAAuB,GAGxB,MAAM,eAAe,CAAC","sourcesContent":["export {\n REVERSED_DEPTH,\n bootWebGpu,\n initWebGpuRenderer,\n type WebGpuBoot,\n type WebGpuBootOptions,\n} from \"./boot.ts\";\nexport {\n BENCH,\n SAND_GRAIN,\n SAND_SPECK,\n benchGate,\n hash21Tsl,\n makeDummyRgbaTex,\n smoothFieldTsl,\n swappableTexture,\n textureKind,\n typedWgslFn,\n uBenchEager,\n wgslSandGrainFn,\n type SwappableTexture,\n} from \"./tsl.ts\";\nexport { gpuSettled, makePipelinesAsync, pipelinesOf, type AsyncPipelines } from \"./pipelines.ts\";\nexport {\n EARLY_LIGHT,\n LOOK_GRADES,\n PARK_DEFAULT_LOOK,\n PLEIN_AIR,\n bakeGroundHeightsAndCanopy,\n colour,\n graded,\n installPaperGrain,\n makeClassicLook,\n makeCloudTexture,\n makeRidgeTexture,\n noiseTexture,\n relightCloudTexture,\n resolveLook,\n resolveVenueLooks,\n seeded,\n tileNoise,\n type CourseLook,\n type Grade,\n type Look,\n type LookGrade,\n type PaperGrainOptions,\n type Skyline,\n type Style,\n type Tint,\n type VenueLook,\n} from \"./look.ts\";\nexport {\n buildTslSky,\n createSkyDomeMesh,\n createTslAtmosphere,\n wgslCanopyDappleFn,\n wgslSunShadowEvalFn,\n wgslTreeShadowUvFn,\n type AtmosphereFrameSync,\n type AtmosphereInit,\n type SkyDomeMeshOptions,\n type TslAtmosphere,\n} from \"./atmosphere.ts\";\nexport {\n SunShadowPass,\n VisibilityGuard,\n snapOrthoShadowCamera,\n type ShadowCasterActor,\n type SnapOrthoShadowCameraOptions,\n type SunShadowAtmosphereTarget,\n} from \"./sunshadow.ts\";\nexport {\n closeFocusTsl,\n createWebGpuPipeline,\n finishTsl,\n softForegroundTsl,\n wgslContactShadowEvalFn,\n type PipelineAtmosphereInputs,\n type WebGpuPipeline,\n} from \"./pipeline.ts\";\n"]}
|
package/lib/look.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
export type Tint = [number, number, number];
|
|
3
|
+
export interface Skyline {
|
|
4
|
+
near?: number[];
|
|
5
|
+
far?: number[];
|
|
6
|
+
perViewpoint?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface VenueLook {
|
|
9
|
+
palette: string[];
|
|
10
|
+
trunk: string;
|
|
11
|
+
paleTrunk: string;
|
|
12
|
+
broadleaf: string[];
|
|
13
|
+
conifer: string[];
|
|
14
|
+
shrub: string[];
|
|
15
|
+
roughHeight: [number, number, number];
|
|
16
|
+
horizon: number;
|
|
17
|
+
ridge?: Skyline;
|
|
18
|
+
}
|
|
19
|
+
export type CourseLook = VenueLook;
|
|
20
|
+
export interface Grade {
|
|
21
|
+
warmth: number;
|
|
22
|
+
saturation: number;
|
|
23
|
+
lift: number;
|
|
24
|
+
}
|
|
25
|
+
export interface LookGrade {
|
|
26
|
+
shadow: [number, number, number];
|
|
27
|
+
light: [number, number, number];
|
|
28
|
+
contrast: number;
|
|
29
|
+
saturation: number;
|
|
30
|
+
}
|
|
31
|
+
export interface Style {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
grade: Grade;
|
|
35
|
+
sun: [number, number, number];
|
|
36
|
+
sunTint: Tint;
|
|
37
|
+
shadeTint: Tint;
|
|
38
|
+
treeShadeTint: Tint;
|
|
39
|
+
lipTint: Tint;
|
|
40
|
+
warmTint: Tint;
|
|
41
|
+
haze: string;
|
|
42
|
+
hazeSun: string;
|
|
43
|
+
skyTop: string;
|
|
44
|
+
lights: {
|
|
45
|
+
sky: string;
|
|
46
|
+
ground: string;
|
|
47
|
+
skyStrength: number;
|
|
48
|
+
sun: string;
|
|
49
|
+
sunStrength: number;
|
|
50
|
+
};
|
|
51
|
+
ground: Look["ground"];
|
|
52
|
+
crowns: Pick<Look["trees"], "jitter" | "steps" | "dabSize" | "dabs" | "dabKind" | "far">;
|
|
53
|
+
sky: Omit<Look["sky"], "hills" | "ridge">;
|
|
54
|
+
tufts: {
|
|
55
|
+
tip: Tint;
|
|
56
|
+
height: number;
|
|
57
|
+
};
|
|
58
|
+
paper: number;
|
|
59
|
+
}
|
|
60
|
+
export interface Look {
|
|
61
|
+
id: string;
|
|
62
|
+
name: string;
|
|
63
|
+
styled: boolean;
|
|
64
|
+
palette: string[];
|
|
65
|
+
sun: [number, number, number];
|
|
66
|
+
sunTint: Tint;
|
|
67
|
+
shadeTint: Tint;
|
|
68
|
+
treeShadeTint: Tint;
|
|
69
|
+
lipTint: Tint;
|
|
70
|
+
warmTint: Tint;
|
|
71
|
+
haze: string;
|
|
72
|
+
hazeSun: string;
|
|
73
|
+
skyTop: string;
|
|
74
|
+
lights: {
|
|
75
|
+
sky: string;
|
|
76
|
+
ground: string;
|
|
77
|
+
skyStrength: number;
|
|
78
|
+
sun: string;
|
|
79
|
+
sunStrength: number;
|
|
80
|
+
};
|
|
81
|
+
ground: {
|
|
82
|
+
macro: number;
|
|
83
|
+
grain: number;
|
|
84
|
+
grainKind: "strokes" | "speckle";
|
|
85
|
+
stripes: [number, number];
|
|
86
|
+
sheen: number;
|
|
87
|
+
shadeBlur: number;
|
|
88
|
+
shadeDark: number;
|
|
89
|
+
};
|
|
90
|
+
trees: {
|
|
91
|
+
crown: "facet" | "dab";
|
|
92
|
+
trunk: string;
|
|
93
|
+
paleTrunk: string;
|
|
94
|
+
broadleaf: string[];
|
|
95
|
+
conifer: string[];
|
|
96
|
+
shrub: string[];
|
|
97
|
+
jitter: number;
|
|
98
|
+
steps: number;
|
|
99
|
+
dabSize: number;
|
|
100
|
+
dabs: number;
|
|
101
|
+
dabKind: "brush" | "leaves";
|
|
102
|
+
far: string;
|
|
103
|
+
};
|
|
104
|
+
sky: {
|
|
105
|
+
cloud: number;
|
|
106
|
+
cloudSoft: number;
|
|
107
|
+
cloudLit: string;
|
|
108
|
+
cloudShade: string;
|
|
109
|
+
hills: number;
|
|
110
|
+
ridge?: Skyline;
|
|
111
|
+
hillFar: string;
|
|
112
|
+
hillNear: string;
|
|
113
|
+
disc: number;
|
|
114
|
+
glow: number;
|
|
115
|
+
sunColor: string;
|
|
116
|
+
};
|
|
117
|
+
grass: {
|
|
118
|
+
tufts: boolean;
|
|
119
|
+
tip: Tint;
|
|
120
|
+
heights: [number, number, number];
|
|
121
|
+
};
|
|
122
|
+
paper: number;
|
|
123
|
+
}
|
|
124
|
+
export declare const EARLY_LIGHT: Style;
|
|
125
|
+
export declare const PLEIN_AIR: Style;
|
|
126
|
+
export declare const LOOK_GRADES: Record<string, LookGrade>;
|
|
127
|
+
export declare const PARK_DEFAULT_LOOK: VenueLook;
|
|
128
|
+
export declare const colour: (hex: string) => THREE.Color;
|
|
129
|
+
export declare function graded(hex: string, grade: Grade): string;
|
|
130
|
+
export declare function resolveLook(venue: VenueLook, style: Style): Look;
|
|
131
|
+
export declare function makeClassicLook(venue: VenueLook): Look;
|
|
132
|
+
export declare function resolveVenueLooks(venue: VenueLook): Look[];
|
|
133
|
+
export declare function seeded(seed: number): () => number;
|
|
134
|
+
export declare function tileNoise(size: number, cells: number, seed: number): Float32Array;
|
|
135
|
+
export declare function noiseTexture(): THREE.DataTexture;
|
|
136
|
+
export declare function relightCloudTexture(tex: THREE.DataTexture, sunX: number, sunZ: number): void;
|
|
137
|
+
export declare function makeCloudTexture(sunX: number, sunZ: number, size?: number): THREE.DataTexture;
|
|
138
|
+
export declare function makeRidgeTexture(look: Pick<Look, "sky">): THREE.DataTexture;
|
|
139
|
+
/**
|
|
140
|
+
* Bake terrain hollow/crest concavity (R) and tree canopy darkness (G) into an RGBA8 DataTexture.
|
|
141
|
+
*/
|
|
142
|
+
export declare function bakeGroundHeightsAndCanopy(heights: Float32Array, nx: number, nz: number, spacing: number, trees: readonly {
|
|
143
|
+
x: number;
|
|
144
|
+
z: number;
|
|
145
|
+
crownRadius: number;
|
|
146
|
+
}[], x0: number, z0: number): THREE.DataTexture;
|
|
147
|
+
export interface PaperGrainOptions {
|
|
148
|
+
container?: HTMLElement;
|
|
149
|
+
after?: Element | null;
|
|
150
|
+
id?: string;
|
|
151
|
+
zIndex?: number | null;
|
|
152
|
+
}
|
|
153
|
+
export declare function installPaperGrain(paperStrength: number, target?: HTMLElement | PaperGrainOptions): () => void;
|
|
154
|
+
//# sourceMappingURL=look.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"look.d.ts","sourceRoot":"","sources":["../src/look.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,EA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