genshin-engine 3.8.1 → 3.9.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/dist/index.d.ts +85 -15
- package/dist/index.js +227 -65
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BufferAttribute, BufferGeometry, Camera, CanvasTexture, Color, ColorRepresentation, Data3DTexture, DataTexture, DirectionalLight,
|
|
2
|
-
import { MeshBasicNodeMaterial, MeshToonNodeMaterial, MeshToonNodeMaterialParameters, Node, RenderPipeline, RenderTarget, Renderer,
|
|
1
|
+
import { BufferAttribute, BufferGeometry, Camera, CanvasTexture, Color, ColorRepresentation, Data3DTexture, DataTexture, DirectionalLight, Frustum, HemisphereLight, InstancedBufferGeometry, Matrix4, OrthographicCamera, Scene, Sprite, Texture, ToneMapping, Vector2, Vector3, Vector3Like } from "three";
|
|
2
|
+
import { MeshBasicNodeMaterial, MeshPhysicalNodeMaterial, MeshToonNodeMaterial, MeshToonNodeMaterialParameters, Node, RenderPipeline, RenderTarget, Renderer, TextureNode, UniformNode, WebGPURenderer } from "three/webgpu";
|
|
3
3
|
import { CSMShadowNode } from "three/examples/jsm/csm/CSMShadowNode.js";
|
|
4
4
|
import BloomNode from "three/examples/jsm/tsl/display/BloomNode.js";
|
|
5
5
|
import GodraysNode from "three/examples/jsm/tsl/display/GodraysNode.js";
|
|
@@ -20,24 +20,41 @@ export interface CloudSprite {
|
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/atmosphere/SkyKeyframe.d.ts
|
|
22
22
|
export interface SkyKeyframe {
|
|
23
|
+
cloudLitBackColor?: Color;
|
|
23
24
|
cloudLitColor: Color;
|
|
25
|
+
cloudShadeBackColor?: Color;
|
|
24
26
|
cloudShadeColor: Color;
|
|
27
|
+
haloColor?: Color;
|
|
25
28
|
hemisphereGroundColor: Color;
|
|
26
29
|
hemisphereIntensity: number;
|
|
27
30
|
hemisphereSkyColor: Color;
|
|
31
|
+
horizonBackColor?: Color;
|
|
28
32
|
horizonColor: Color;
|
|
29
33
|
lightColor: Color;
|
|
30
34
|
lightIntensity: number;
|
|
31
35
|
minutes: number;
|
|
32
36
|
starIntensity: number;
|
|
37
|
+
sunHaloColor?: Color;
|
|
38
|
+
zenithBackColor?: Color;
|
|
33
39
|
zenithColor: Color;
|
|
34
40
|
}
|
|
35
41
|
//#endregion
|
|
42
|
+
//#region src/atmosphere/SkyShape.d.ts
|
|
43
|
+
export interface SkyShape {
|
|
44
|
+
frontBackBlend: number;
|
|
45
|
+
haloHeight: number;
|
|
46
|
+
horizonBand: number;
|
|
47
|
+
moonSize: number;
|
|
48
|
+
sunHaloSize: number;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
36
51
|
//#region src/atmosphere/SkyState.d.ts
|
|
37
52
|
export interface SkyState extends Omit<SkyKeyframe, "minutes"> {
|
|
38
53
|
fogColor?: Color;
|
|
54
|
+
fogDensity?: number;
|
|
39
55
|
lightDirection: Vector3;
|
|
40
56
|
moonDirection: Vector3;
|
|
57
|
+
shape?: SkyShape;
|
|
41
58
|
sunDirection: Vector3;
|
|
42
59
|
}
|
|
43
60
|
//#endregion
|
|
@@ -45,14 +62,27 @@ export interface SkyState extends Omit<SkyKeyframe, "minutes"> {
|
|
|
45
62
|
export interface SkyUniforms {
|
|
46
63
|
cloudCoverage: UniformNode<"float", number>;
|
|
47
64
|
cloudDrift: UniformNode<"vec2", Vector2>;
|
|
65
|
+
cloudFrontBackBlend: UniformNode<"float", number>;
|
|
66
|
+
cloudLitBackColor: UniformNode<"color", Color>;
|
|
48
67
|
cloudLitColor: UniformNode<"color", Color>;
|
|
68
|
+
cloudShadeBackColor: UniformNode<"color", Color>;
|
|
49
69
|
cloudShadeColor: UniformNode<"color", Color>;
|
|
70
|
+
cloudSunBrighten: UniformNode<"float", number>;
|
|
71
|
+
frontBackBlend: UniformNode<"float", number>;
|
|
72
|
+
haloColor: UniformNode<"color", Color>;
|
|
73
|
+
haloHeight: UniformNode<"float", number>;
|
|
74
|
+
horizonBackColor: UniformNode<"color", Color>;
|
|
50
75
|
horizonBand: UniformNode<"float", number>;
|
|
51
76
|
horizonColor: UniformNode<"color", Color>;
|
|
52
77
|
lightColor: UniformNode<"color", Color>;
|
|
53
78
|
moonDirection: UniformNode<"vec3", Vector3>;
|
|
79
|
+
moonGlowColor: UniformNode<"color", Color>;
|
|
80
|
+
moonSize: UniformNode<"float", number>;
|
|
54
81
|
starIntensity: UniformNode<"float", number>;
|
|
55
82
|
sunDirection: UniformNode<"vec3", Vector3>;
|
|
83
|
+
sunHaloColor: UniformNode<"color", Color>;
|
|
84
|
+
sunHaloSize: UniformNode<"float", number>;
|
|
85
|
+
zenithBackColor: UniformNode<"color", Color>;
|
|
56
86
|
zenithColor: UniformNode<"color", Color>;
|
|
57
87
|
}
|
|
58
88
|
//#endregion
|
|
@@ -117,15 +147,36 @@ export declare const applySkyState: (skyState: SkyState, { fogUniforms, godraysL
|
|
|
117
147
|
//#region src/atmosphere/computeSunDirection.d.ts
|
|
118
148
|
export declare const computeSunDirection: (minutes: number, tilt: number, sunDirection: Vector3) => Vector3;
|
|
119
149
|
//#endregion
|
|
150
|
+
//#region src/atmosphere/constants.d.ts
|
|
151
|
+
export declare const DEFAULT_SKY_SHAPE: Readonly<SkyShape>;
|
|
152
|
+
export declare const DEFAULT_SKY_GRADIENT: {
|
|
153
|
+
green: number[];
|
|
154
|
+
red: number[];
|
|
155
|
+
};
|
|
156
|
+
//#endregion
|
|
120
157
|
//#region src/atmosphere/createCloudAtlasTexture.d.ts
|
|
121
158
|
export declare const getCloudAtlasColumns: (spriteCount: number) => number;
|
|
122
159
|
export declare const createCloudAtlasTexture: (sprites: readonly CloudSprite[], cellSize: number) => CanvasTexture<OffscreenCanvas>;
|
|
123
160
|
//#endregion
|
|
124
|
-
//#region src/atmosphere/
|
|
125
|
-
export declare const
|
|
126
|
-
|
|
161
|
+
//#region src/atmosphere/createCloudBandSprite.d.ts
|
|
162
|
+
export declare const createCloudBandSprite: (atlas: Texture, clouds: readonly {
|
|
163
|
+
position: [number, number, number];
|
|
164
|
+
spriteIndex: number;
|
|
165
|
+
width: number;
|
|
166
|
+
}[], { aspect, spriteCount }: {
|
|
167
|
+
aspect: number;
|
|
127
168
|
spriteCount: number;
|
|
128
|
-
},
|
|
169
|
+
}, skyUniforms: SkyUniforms) => {
|
|
170
|
+
dispose: () => void;
|
|
171
|
+
places: [number, number, number][];
|
|
172
|
+
sprite: Sprite;
|
|
173
|
+
};
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/atmosphere/createSkyGradientTexture.d.ts
|
|
176
|
+
export declare const createSkyGradientTexture: ({ green, red }: {
|
|
177
|
+
green: readonly number[];
|
|
178
|
+
red: readonly number[];
|
|
179
|
+
}) => DataTexture;
|
|
129
180
|
//#endregion
|
|
130
181
|
//#region src/atmosphere/createSkyState.d.ts
|
|
131
182
|
export declare const createSkyState: () => SkyState;
|
|
@@ -136,6 +187,9 @@ export declare const createSkyUniforms: () => SkyUniforms;
|
|
|
136
187
|
//#region src/atmosphere/createSunLight.d.ts
|
|
137
188
|
export declare const createSunLight: ({ cascadeCount, maxFar, shadowMapSize }: SunLightOptions) => SunLight;
|
|
138
189
|
//#endregion
|
|
190
|
+
//#region src/atmosphere/orderByViewDepth.d.ts
|
|
191
|
+
export declare const orderByViewDepth: (places: readonly (readonly number[])[], { elements }: Matrix4) => number[];
|
|
192
|
+
//#endregion
|
|
139
193
|
//#region src/atmosphere/placeCloudBand.d.ts
|
|
140
194
|
export declare const placeCloudBand: ({ count, distanceRange: [near, far], heightRange: [low, high], seed, widthRange: [narrow, wide] }: CloudBandOptions, spriteCount: number) => {
|
|
141
195
|
position: [number, number, number];
|
|
@@ -173,18 +227,12 @@ export interface LatheStackOptions {
|
|
|
173
227
|
sections: LatheSection[];
|
|
174
228
|
}
|
|
175
229
|
//#endregion
|
|
176
|
-
//#region src/kits/architecture/
|
|
177
|
-
export
|
|
178
|
-
contours: [number, number][][];
|
|
179
|
-
depth: [number, number];
|
|
180
|
-
}
|
|
230
|
+
//#region src/kits/architecture/createBoxesGeometry.d.ts
|
|
231
|
+
export declare const createBoxesGeometry: (boxes: readonly (readonly number[])[]) => BufferGeometry;
|
|
181
232
|
//#endregion
|
|
182
233
|
//#region src/kits/architecture/createLatheStackGeometry.d.ts
|
|
183
234
|
export declare const createLatheStackGeometry: ({ isFaceted, radialSegments, sections }: LatheStackOptions) => BufferGeometry;
|
|
184
235
|
//#endregion
|
|
185
|
-
//#region src/kits/architecture/createSilhouetteGeometry.d.ts
|
|
186
|
-
export declare const createSilhouetteGeometry: ({ contours, depth: [front, back] }: SilhouetteOptions) => ExtrudeGeometry;
|
|
187
|
-
//#endregion
|
|
188
236
|
//#region src/kits/statue/createStatueGeometry.d.ts
|
|
189
237
|
export declare const createStatueGeometry: () => BufferGeometry;
|
|
190
238
|
//#endregion
|
|
@@ -244,12 +292,25 @@ export interface RampOptions {
|
|
|
244
292
|
terminator: number;
|
|
245
293
|
}
|
|
246
294
|
//#endregion
|
|
295
|
+
//#region src/materials/addSmoothLoop.d.ts
|
|
296
|
+
export declare const addSmoothLoop: (path: Path2D, points: readonly (readonly [number, number])[]) => void;
|
|
297
|
+
//#endregion
|
|
247
298
|
//#region src/materials/computeRampValues.d.ts
|
|
248
299
|
export declare const computeRampValues: ({ resolution, softness, terminator }: RampOptions) => Uint8Array;
|
|
249
300
|
//#endregion
|
|
250
301
|
//#region src/materials/createRampTexture.d.ts
|
|
251
302
|
export declare const createRampTexture: (rampOptions: RampOptions) => DataTexture;
|
|
252
303
|
//#endregion
|
|
304
|
+
//#region src/nodes/StoneMaterialOptions.d.ts
|
|
305
|
+
export interface StoneMaterialOptions {
|
|
306
|
+
albedo: string;
|
|
307
|
+
rimColor: readonly number[];
|
|
308
|
+
rimPower: number;
|
|
309
|
+
rimStrength: number;
|
|
310
|
+
smoothness: number;
|
|
311
|
+
specularColor: readonly number[];
|
|
312
|
+
}
|
|
313
|
+
//#endregion
|
|
253
314
|
//#region src/nodes/ToonMaterialOptions.d.ts
|
|
254
315
|
export interface ToonMaterialOptions {
|
|
255
316
|
color?: ColorRepresentation;
|
|
@@ -303,8 +364,14 @@ export declare const createLightUniforms: () => LightUniforms;
|
|
|
303
364
|
//#region src/nodes/createRimNode.d.ts
|
|
304
365
|
export declare const createRimNode: ({ rimColor, rimStrength, sunDirection }: LightUniforms) => Node<"vec3">;
|
|
305
366
|
//#endregion
|
|
367
|
+
//#region src/nodes/createSkyColorNode.d.ts
|
|
368
|
+
export declare const createSkyColorNode: ({ frontBackBlend, haloColor, haloHeight, horizonBackColor, horizonBand, horizonColor, sunDirection, sunHaloColor, sunHaloSize, zenithBackColor, zenithColor }: SkyUniforms, gradient: Texture, direction: Node<"vec3">) => Node<"vec3">;
|
|
369
|
+
//#endregion
|
|
306
370
|
//#region src/nodes/createSkyNode.d.ts
|
|
307
|
-
export declare const createSkyNode: (
|
|
371
|
+
export declare const createSkyNode: (uniforms: SkyUniforms, gradient: Texture) => Node<"vec3">;
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/nodes/createStoneMaterial.d.ts
|
|
374
|
+
export declare const createStoneMaterial: ({ albedo, rimColor, rimPower, rimStrength, smoothness, specularColor }: StoneMaterialOptions, glowNode?: Node<"vec3">) => MeshPhysicalNodeMaterial;
|
|
308
375
|
//#endregion
|
|
309
376
|
//#region src/nodes/createToonMaterial.d.ts
|
|
310
377
|
export declare const createToonMaterial: ({ color, isOutlined, isVertexColors, lightUniforms, rampTexture }: ToonMaterialOptions) => ToonNodeMaterial;
|
|
@@ -387,6 +454,9 @@ export declare const createPostUniforms: () => PostUniforms;
|
|
|
387
454
|
//#region src/post/toSceneColor.d.ts
|
|
388
455
|
export declare const toSceneColor: (displayColor: Color) => Color;
|
|
389
456
|
//#endregion
|
|
457
|
+
//#region src/post/toneMapNeutral.d.ts
|
|
458
|
+
export declare const toneMapNeutral: ([red, green, blue]: [number, number, number]) => [number, number, number];
|
|
459
|
+
//#endregion
|
|
390
460
|
//#region src/random/createSeededRandom.d.ts
|
|
391
461
|
export declare const createSeededRandom: (seed: number) => (() => number);
|
|
392
462
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Box3, BufferAttribute, BufferGeometry, CanvasTexture, Color, CylinderGeometry, Data3DTexture, DataTexture, DirectionalLight, DoubleSide,
|
|
2
|
-
import { Fn, If, attribute, cameraFar, cameraNear, cameraPosition, cameraViewMatrix, cos, exp, exp2, float, getViewPosition, hash, instanceIndex, max, mix, modelViewMatrix, modelWorldMatrix, mrt, mx_cell_noise_float, mx_fractal_noise_float, mx_noise_float, normalView, normalWorldGeometry, output, perspectiveDepthToViewZ, positionGeometry, positionLocal, positionView, positionViewDirection, positionWorld, pow, reflect, renderOutput, screenUV, sin, smoothstep, step, texture, texture3D, time, uniform, uv, varying, vec2, vec3, vec4, velocity, viewportDepthTexture, viewportSharedTexture } from "three/tsl";
|
|
3
|
-
import { MeshBasicNodeMaterial, MeshToonNodeMaterial, RenderPipeline, RenderTarget, SpriteNodeMaterial, ToonOutlinePassNode, WebGPURenderer } from "three/webgpu";
|
|
1
|
+
import { Box3, BoxGeometry, BufferAttribute, BufferGeometry, CanvasTexture, ClampToEdgeWrapping, Color, CylinderGeometry, Data3DTexture, DataTexture, DirectionalLight, DoubleSide, HalfFloatType, InstancedBufferAttribute, InstancedBufferGeometry, LatheGeometry, LinearFilter, MathUtils, Matrix4, NeutralToneMapping, NoColorSpace, OrthographicCamera, Quaternion, RGBAFormat, RedFormat, Sprite, UnsignedByteType, Vector2, Vector3 } from "three";
|
|
2
|
+
import { Fn, If, abs, asin, attribute, cameraFar, cameraNear, cameraPosition, cameraViewMatrix, clamp, color, cos, exp, exp2, float, getViewPosition, hash, instanceIndex, instancedBufferAttribute, max, min, mix, modelViewMatrix, modelWorldMatrix, mrt, mx_cell_noise_float, mx_fractal_noise_float, mx_noise_float, normalView, normalWorldGeometry, output, perspectiveDepthToViewZ, positionGeometry, positionLocal, positionView, positionViewDirection, positionWorld, pow, reflect, renderOutput, saturate, screenUV, sin, smoothstep, step, texture, texture3D, time, uniform, uv, varying, vec2, vec3, vec4, velocity, viewportDepthTexture, viewportSharedTexture } from "three/tsl";
|
|
3
|
+
import { MeshBasicNodeMaterial, MeshPhysicalNodeMaterial, MeshToonNodeMaterial, RenderPipeline, RenderTarget, SpriteNodeMaterial, ToonOutlinePassNode, WebGPURenderer } from "three/webgpu";
|
|
4
4
|
import { CSMShadowNode } from "three/examples/jsm/csm/CSMShadowNode.js";
|
|
5
5
|
import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
6
6
|
import { voronoi2d } from "three/examples/jsm/tsl/math/voronoiNoise.js";
|
|
@@ -11,15 +11,29 @@ import { godrays } from "three/examples/jsm/tsl/display/GodraysNode.js";
|
|
|
11
11
|
import { lut3D } from "three/examples/jsm/tsl/display/Lut3DNode.js";
|
|
12
12
|
import { smaa } from "three/examples/jsm/tsl/display/SMAANode.js";
|
|
13
13
|
import { traa } from "three/examples/jsm/tsl/display/TRAANode.js";
|
|
14
|
-
//#region src/
|
|
14
|
+
//#region src/atmosphere/constants.ts
|
|
15
|
+
const DEFAULT_SKY_SHAPE = {
|
|
16
|
+
frontBackBlend: 1,
|
|
17
|
+
haloHeight: 1,
|
|
18
|
+
horizonBand: .45,
|
|
19
|
+
moonSize: 1,
|
|
20
|
+
sunHaloSize: 1
|
|
21
|
+
};
|
|
22
|
+
const DEFAULT_SAMPLE_COUNT = 33;
|
|
23
|
+
const DEFAULT_SKY_GRADIENT = {
|
|
24
|
+
green: Array.from({ length: DEFAULT_SAMPLE_COUNT }, () => 0),
|
|
25
|
+
red: Array.from({ length: DEFAULT_SAMPLE_COUNT }, (_, index) => {
|
|
26
|
+
const share = index / 32;
|
|
27
|
+
return 1 - share * share * (3 - 2 * share);
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/post/toneMapNeutral.ts
|
|
15
32
|
const TOE_END = .08;
|
|
16
33
|
const TOE_OFFSET = .04;
|
|
17
34
|
const COMPRESSION_START = .76;
|
|
18
35
|
const DESATURATION = .15;
|
|
19
|
-
const
|
|
20
|
-
const SLOPE_NUDGE = 1e-4;
|
|
21
|
-
const SCENE_CHANNEL_LIMIT = 1.5;
|
|
22
|
-
const toneMap = ([red, green, blue]) => {
|
|
36
|
+
const toneMapNeutral = ([red, green, blue]) => {
|
|
23
37
|
const lowest = Math.min(red, green, blue);
|
|
24
38
|
const offset = lowest < TOE_END ? lowest - 6.25 * lowest * lowest : TOE_OFFSET;
|
|
25
39
|
const offsetColor = [
|
|
@@ -34,6 +48,11 @@ const toneMap = ([red, green, blue]) => {
|
|
|
34
48
|
const whiteShare = 1 - 1 / (DESATURATION * (peak - newPeak) + 1);
|
|
35
49
|
return offsetColor.map((channel) => channel * newPeak / peak + (newPeak - channel * newPeak / peak) * whiteShare);
|
|
36
50
|
};
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/post/toSceneColor.ts
|
|
53
|
+
const INVERSE_STEP_COUNT = 16;
|
|
54
|
+
const SLOPE_NUDGE = 1e-4;
|
|
55
|
+
const SCENE_CHANNEL_LIMIT = 1.5;
|
|
37
56
|
const toSceneColor = (displayColor) => {
|
|
38
57
|
const target = [
|
|
39
58
|
displayColor.r,
|
|
@@ -43,11 +62,11 @@ const toSceneColor = (displayColor) => {
|
|
|
43
62
|
let input = [...target];
|
|
44
63
|
for (let step = 0; step < INVERSE_STEP_COUNT; step++) {
|
|
45
64
|
const current = input;
|
|
46
|
-
const output =
|
|
65
|
+
const output = toneMapNeutral(current);
|
|
47
66
|
input = current.map((channel, index) => {
|
|
48
67
|
const nudged = [...current];
|
|
49
68
|
nudged[index] = channel + SLOPE_NUDGE;
|
|
50
|
-
const slope = ((
|
|
69
|
+
const slope = ((toneMapNeutral(nudged)[index] ?? 0) - (output[index] ?? 0)) / SLOPE_NUDGE;
|
|
51
70
|
return Math.min(Math.max(channel + ((target[index] ?? 0) - (output[index] ?? 0)) / slope, 0), SCENE_CHANNEL_LIMIT);
|
|
52
71
|
});
|
|
53
72
|
}
|
|
@@ -57,6 +76,7 @@ const toSceneColor = (displayColor) => {
|
|
|
57
76
|
//#region src/atmosphere/applySkyState.ts
|
|
58
77
|
const GODRAYS_REDRAW_COSINE = Math.cos(.6 * Math.PI / 180);
|
|
59
78
|
const godraysDirection = new Vector3();
|
|
79
|
+
const BLACK = new Color(0, 0, 0);
|
|
60
80
|
const applySkyState = (skyState, { fogUniforms, godraysLight, hemisphere, light, lightDistance, lightUniforms, postUniforms, skyUniforms }) => {
|
|
61
81
|
const { horizonColor, lightColor, lightDirection } = skyState;
|
|
62
82
|
light.position.copy(light.target.position).addScaledVector(lightDirection, lightDistance);
|
|
@@ -74,12 +94,24 @@ const applySkyState = (skyState, { fogUniforms, godraysLight, hemisphere, light,
|
|
|
74
94
|
postUniforms.godraysColor.value.copy(lightColor);
|
|
75
95
|
skyUniforms.cloudLitColor.value.copy(toSceneColor(skyState.cloudLitColor));
|
|
76
96
|
skyUniforms.cloudShadeColor.value.copy(toSceneColor(skyState.cloudShadeColor));
|
|
97
|
+
skyUniforms.cloudLitBackColor.value.copy(toSceneColor(skyState.cloudLitBackColor ?? skyState.cloudLitColor));
|
|
98
|
+
skyUniforms.cloudShadeBackColor.value.copy(toSceneColor(skyState.cloudShadeBackColor ?? skyState.cloudShadeColor));
|
|
77
99
|
skyUniforms.horizonColor.value.copy(toSceneColor(horizonColor));
|
|
100
|
+
skyUniforms.horizonBackColor.value.copy(toSceneColor(skyState.horizonBackColor ?? horizonColor));
|
|
101
|
+
skyUniforms.zenithBackColor.value.copy(toSceneColor(skyState.zenithBackColor ?? skyState.zenithColor));
|
|
102
|
+
skyUniforms.haloColor.value.copy(toSceneColor(skyState.haloColor ?? BLACK));
|
|
103
|
+
skyUniforms.sunHaloColor.value.copy(toSceneColor(skyState.sunHaloColor ?? BLACK));
|
|
78
104
|
skyUniforms.lightColor.value.copy(lightColor);
|
|
79
105
|
skyUniforms.moonDirection.value.copy(skyState.moonDirection);
|
|
80
106
|
skyUniforms.starIntensity.value = skyState.starIntensity;
|
|
81
107
|
skyUniforms.sunDirection.value.copy(skyState.sunDirection);
|
|
82
108
|
skyUniforms.zenithColor.value.copy(toSceneColor(skyState.zenithColor));
|
|
109
|
+
const { frontBackBlend, haloHeight, horizonBand, moonSize, sunHaloSize } = skyState.shape ?? DEFAULT_SKY_SHAPE;
|
|
110
|
+
skyUniforms.frontBackBlend.value = frontBackBlend;
|
|
111
|
+
skyUniforms.haloHeight.value = haloHeight;
|
|
112
|
+
skyUniforms.horizonBand.value = horizonBand;
|
|
113
|
+
skyUniforms.moonSize.value = moonSize;
|
|
114
|
+
skyUniforms.sunHaloSize.value = sunHaloSize;
|
|
83
115
|
godraysDirection.subVectors(godraysLight.position, godraysLight.target.position).normalize();
|
|
84
116
|
if (godraysDirection.dot(lightDirection) >= GODRAYS_REDRAW_COSINE) return;
|
|
85
117
|
godraysLight.position.copy(godraysLight.target.position).addScaledVector(lightDirection, lightDistance);
|
|
@@ -97,7 +129,21 @@ const computeSunDirection = (minutes, tilt, sunDirection) => {
|
|
|
97
129
|
return sunDirection.set(Math.sin(hourAngle), height * Math.cos(tilt), height * Math.sin(tilt));
|
|
98
130
|
};
|
|
99
131
|
//#endregion
|
|
132
|
+
//#region src/materials/addSmoothLoop.ts
|
|
133
|
+
const addSmoothLoop = (path, points) => {
|
|
134
|
+
if (points.length < 3) return;
|
|
135
|
+
const readMidpoint = (index) => {
|
|
136
|
+
const [startX = 0, startY = 0] = points[index % points.length] ?? [];
|
|
137
|
+
const [endX = 0, endY = 0] = points[(index + 1) % points.length] ?? [];
|
|
138
|
+
return [(startX + endX) / 2, (startY + endY) / 2];
|
|
139
|
+
};
|
|
140
|
+
path.moveTo(...readMidpoint(points.length - 1));
|
|
141
|
+
for (const [index, [x, y]] of points.entries()) path.quadraticCurveTo(x, y, ...readMidpoint(index));
|
|
142
|
+
path.closePath();
|
|
143
|
+
};
|
|
144
|
+
//#endregion
|
|
100
145
|
//#region src/atmosphere/createCloudAtlasTexture.ts
|
|
146
|
+
const EDGE_BLUR_SHARE = .012;
|
|
101
147
|
const getCloudAtlasColumns = (spriteCount) => Math.ceil(Math.sqrt(spriteCount));
|
|
102
148
|
const createCloudAtlasTexture = (sprites, cellSize) => {
|
|
103
149
|
const columns = getCloudAtlasColumns(sprites.length);
|
|
@@ -105,15 +151,11 @@ const createCloudAtlasTexture = (sprites, cellSize) => {
|
|
|
105
151
|
const context = canvas.getContext("2d");
|
|
106
152
|
if (context) {
|
|
107
153
|
context.globalCompositeOperation = "lighter";
|
|
154
|
+
context.filter = `blur(${cellSize * EDGE_BLUR_SHARE}px)`;
|
|
108
155
|
const fill = (loops, column, row, style) => {
|
|
109
156
|
const path = new Path2D();
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const toCanvas = ([x, y]) => [(column + x) * cellSize, (row + 1 - y) * cellSize];
|
|
113
|
-
path.moveTo(...toCanvas(first));
|
|
114
|
-
for (const point of rest) path.lineTo(...toCanvas(point));
|
|
115
|
-
path.closePath();
|
|
116
|
-
}
|
|
157
|
+
const toCanvas = ([x, y]) => [(column + x) * cellSize, (row + 1 - y) * cellSize];
|
|
158
|
+
for (const loop of loops) addSmoothLoop(path, loop.map((point) => toCanvas(point)));
|
|
117
159
|
context.fillStyle = style;
|
|
118
160
|
context.fill(path, "evenodd");
|
|
119
161
|
};
|
|
@@ -132,21 +174,88 @@ const createCloudAtlasTexture = (sprites, cellSize) => {
|
|
|
132
174
|
return texture;
|
|
133
175
|
};
|
|
134
176
|
//#endregion
|
|
135
|
-
//#region src/atmosphere/
|
|
136
|
-
const
|
|
177
|
+
//#region src/atmosphere/orderByViewDepth.ts
|
|
178
|
+
const orderByViewDepth = (places, { elements }) => {
|
|
179
|
+
const depths = places.map(([x = 0, y = 0, z = 0]) => elements[2] * x + elements[6] * y + elements[10] * z + elements[14]);
|
|
180
|
+
return depths.map((_, index) => index).toSorted((first, second) => (depths[first] ?? 0) - (depths[second] ?? 0));
|
|
181
|
+
};
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/atmosphere/createCloudBandSprite.ts
|
|
184
|
+
const BELOW_FADE_START = .1;
|
|
185
|
+
const BELOW_FADE_SCALE = 5;
|
|
186
|
+
const COVERAGE_LIGHT_SHARE = .4;
|
|
187
|
+
const EDGE_FADE_START = .15;
|
|
188
|
+
const EDGE_FADE_END = .85;
|
|
189
|
+
const DROPPED_COVERAGE = .01;
|
|
190
|
+
const createCloudBandSprite = (atlas, clouds, { aspect, spriteCount }, skyUniforms) => {
|
|
191
|
+
const { cloudCoverage, cloudFrontBackBlend, cloudLitBackColor, cloudLitColor, cloudShadeBackColor, cloudShadeColor, cloudSunBrighten, sunDirection } = skyUniforms;
|
|
137
192
|
const columns = getCloudAtlasColumns(spriteCount);
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const
|
|
193
|
+
const places = clouds.map(({ position }) => [...position]);
|
|
194
|
+
const cloudScales = clouds.map(({ width }) => [width, width / aspect]);
|
|
195
|
+
const cloudCells = clouds.map(({ spriteIndex }) => [spriteIndex % columns, columns - 1 - Math.floor(spriteIndex / columns)]);
|
|
196
|
+
const positions = new InstancedBufferAttribute(new Float32Array(clouds.length * 3), 3);
|
|
197
|
+
const scales = new InstancedBufferAttribute(new Float32Array(clouds.length * 2), 2);
|
|
198
|
+
const cells = new InstancedBufferAttribute(new Float32Array(clouds.length * 2), 2);
|
|
199
|
+
const mask = texture(atlas, uv().add(instancedBufferAttribute(cells)).div(columns));
|
|
200
|
+
const place = instancedBufferAttribute(positions);
|
|
201
|
+
const direction = place.sub(cameraPosition).normalize();
|
|
202
|
+
const elevation = asin(clamp(direction.y, -1, 1)).mul(2 / Math.PI);
|
|
203
|
+
const sunCosine = direction.dot(sunDirection);
|
|
204
|
+
const toward = pow(max(sunCosine.mul(cloudFrontBackBlend).add(float(1).sub(cloudFrontBackBlend)), 0), 3);
|
|
205
|
+
const lit = mix(cloudLitBackColor, cloudLitColor, toward);
|
|
206
|
+
const shade = mix(cloudShadeBackColor, cloudShadeColor, toward);
|
|
207
|
+
const cloudColor = mix(shade, lit, mask.g).add(lit.mul(cloudCoverage.mul(COVERAGE_LIGHT_SHARE))).mul(float(1).add(cloudSunBrighten.mul(sunCosine.mul(.5).add(.5))));
|
|
142
208
|
const material = new SpriteNodeMaterial({
|
|
143
209
|
depthWrite: false,
|
|
144
210
|
transparent: true
|
|
145
211
|
});
|
|
146
|
-
material.
|
|
147
|
-
material.
|
|
148
|
-
material.
|
|
149
|
-
|
|
212
|
+
material.positionNode = place;
|
|
213
|
+
material.scaleNode = instancedBufferAttribute(scales);
|
|
214
|
+
material.colorNode = cloudColor;
|
|
215
|
+
material.opacityNode = smoothstep(EDGE_FADE_START, EDGE_FADE_END, mask.r).mul(smoothstep(0, 1, saturate(elevation.add(BELOW_FADE_START).mul(BELOW_FADE_SCALE))));
|
|
216
|
+
material.alphaTest = DROPPED_COVERAGE;
|
|
217
|
+
const sprite = new Sprite(material);
|
|
218
|
+
sprite.center.set(.5, 0);
|
|
219
|
+
sprite.count = clouds.length;
|
|
220
|
+
sprite.frustumCulled = false;
|
|
221
|
+
const modelViewMatrix = new Matrix4();
|
|
222
|
+
sprite.onBeforeRender = (_renderer, _scene, camera) => {
|
|
223
|
+
modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, sprite.matrixWorld);
|
|
224
|
+
for (const [instance, cloud] of orderByViewDepth(places, modelViewMatrix).entries()) {
|
|
225
|
+
positions.set(places[cloud] ?? [], instance * 3);
|
|
226
|
+
scales.set(cloudScales[cloud] ?? [], instance * 2);
|
|
227
|
+
cells.set(cloudCells[cloud] ?? [], instance * 2);
|
|
228
|
+
}
|
|
229
|
+
positions.needsUpdate = true;
|
|
230
|
+
scales.needsUpdate = true;
|
|
231
|
+
cells.needsUpdate = true;
|
|
232
|
+
};
|
|
233
|
+
return {
|
|
234
|
+
dispose: () => {
|
|
235
|
+
material.dispose();
|
|
236
|
+
},
|
|
237
|
+
places,
|
|
238
|
+
sprite
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/atmosphere/createSkyGradientTexture.ts
|
|
243
|
+
const BYTE = 255;
|
|
244
|
+
const createSkyGradientTexture = ({ green, red }) => {
|
|
245
|
+
const width = Math.max(red.length, green.length, 1);
|
|
246
|
+
const data = new Uint8Array(width * 4);
|
|
247
|
+
for (let index = 0; index < width; index++) {
|
|
248
|
+
data[index * 4] = Math.round((red[index] ?? 0) * BYTE);
|
|
249
|
+
data[index * 4 + 1] = Math.round((green[index] ?? 0) * BYTE);
|
|
250
|
+
data[index * 4 + 3] = BYTE;
|
|
251
|
+
}
|
|
252
|
+
const texture = new DataTexture(data, width, 1, RGBAFormat, UnsignedByteType);
|
|
253
|
+
texture.magFilter = LinearFilter;
|
|
254
|
+
texture.minFilter = LinearFilter;
|
|
255
|
+
texture.wrapS = ClampToEdgeWrapping;
|
|
256
|
+
texture.wrapT = ClampToEdgeWrapping;
|
|
257
|
+
texture.needsUpdate = true;
|
|
258
|
+
return texture;
|
|
150
259
|
};
|
|
151
260
|
//#endregion
|
|
152
261
|
//#region src/atmosphere/createSkyState.ts
|
|
@@ -170,14 +279,27 @@ const createSkyState = () => ({
|
|
|
170
279
|
const createSkyUniforms = () => ({
|
|
171
280
|
cloudCoverage: uniform(0),
|
|
172
281
|
cloudDrift: uniform(new Vector2()),
|
|
282
|
+
cloudFrontBackBlend: uniform(1),
|
|
283
|
+
cloudLitBackColor: uniform(new Color()),
|
|
173
284
|
cloudLitColor: uniform(new Color()),
|
|
285
|
+
cloudShadeBackColor: uniform(new Color()),
|
|
174
286
|
cloudShadeColor: uniform(new Color()),
|
|
175
|
-
|
|
287
|
+
cloudSunBrighten: uniform(0),
|
|
288
|
+
frontBackBlend: uniform(DEFAULT_SKY_SHAPE.frontBackBlend),
|
|
289
|
+
haloColor: uniform(new Color(0, 0, 0)),
|
|
290
|
+
haloHeight: uniform(DEFAULT_SKY_SHAPE.haloHeight),
|
|
291
|
+
horizonBackColor: uniform(new Color()),
|
|
292
|
+
horizonBand: uniform(DEFAULT_SKY_SHAPE.horizonBand),
|
|
176
293
|
horizonColor: uniform(new Color()),
|
|
177
294
|
lightColor: uniform(new Color()),
|
|
178
295
|
moonDirection: uniform(new Vector3(0, -1, 0)),
|
|
296
|
+
moonGlowColor: uniform(new Color(0, 0, 0)),
|
|
297
|
+
moonSize: uniform(DEFAULT_SKY_SHAPE.moonSize),
|
|
179
298
|
starIntensity: uniform(0),
|
|
180
299
|
sunDirection: uniform(new Vector3(0, 1, 0)),
|
|
300
|
+
sunHaloColor: uniform(new Color(0, 0, 0)),
|
|
301
|
+
sunHaloSize: uniform(DEFAULT_SKY_SHAPE.sunHaloSize),
|
|
302
|
+
zenithBackColor: uniform(new Color()),
|
|
181
303
|
zenithColor: uniform(new Color())
|
|
182
304
|
});
|
|
183
305
|
//#endregion
|
|
@@ -268,6 +390,14 @@ const advanceGameClock = (gameClock, deltaSeconds) => {
|
|
|
268
390
|
gameClock.minutes = (gameClock.minutes + deltaSeconds * gameClock.minutesPerSecond) % MINUTES_PER_DAY;
|
|
269
391
|
};
|
|
270
392
|
//#endregion
|
|
393
|
+
//#region src/kits/architecture/createBoxesGeometry.ts
|
|
394
|
+
const createBoxesGeometry = (boxes) => {
|
|
395
|
+
const parts = boxes.map(([minX = 0, minY = 0, minZ = 0, maxX = 0, maxY = 0, maxZ = 0]) => new BoxGeometry(maxX - minX, maxY - minY, maxZ - minZ).translate((minX + maxX) / 2, (minY + maxY) / 2, (minZ + maxZ) / 2));
|
|
396
|
+
const geometry = mergeGeometries(parts) ?? new BufferGeometry();
|
|
397
|
+
for (const part of parts) part.dispose();
|
|
398
|
+
return geometry;
|
|
399
|
+
};
|
|
400
|
+
//#endregion
|
|
271
401
|
//#region src/kits/architecture/createLatheStackGeometry.ts
|
|
272
402
|
const createLatheStackGeometry = ({ isFaceted, radialSegments, sections }) => {
|
|
273
403
|
let footHeight = 0;
|
|
@@ -282,20 +412,6 @@ const createLatheStackGeometry = ({ isFaceted, radialSegments, sections }) => {
|
|
|
282
412
|
return stackGeometry;
|
|
283
413
|
};
|
|
284
414
|
//#endregion
|
|
285
|
-
//#region src/kits/architecture/createSilhouetteGeometry.ts
|
|
286
|
-
const createSilhouetteGeometry = ({ contours, depth: [front, back] }) => {
|
|
287
|
-
const shapePath = new ShapePath();
|
|
288
|
-
for (const [first, ...rest] of contours) {
|
|
289
|
-
if (!first) continue;
|
|
290
|
-
shapePath.moveTo(...first);
|
|
291
|
-
for (const point of rest) shapePath.lineTo(...point);
|
|
292
|
-
}
|
|
293
|
-
return new ExtrudeGeometry(shapePath.toShapes(), {
|
|
294
|
-
bevelEnabled: false,
|
|
295
|
-
depth: back - front
|
|
296
|
-
}).translate(0, 0, front);
|
|
297
|
-
};
|
|
298
|
-
//#endregion
|
|
299
415
|
//#region src/kits/statue/createStatueGeometry.ts
|
|
300
416
|
const PLINTH_SIDES = 8;
|
|
301
417
|
const FIGURE_SEGMENTS = 24;
|
|
@@ -598,11 +714,37 @@ const createLightUniforms = () => ({
|
|
|
598
714
|
sunDirection: uniform(new Vector3(0, 1, 0))
|
|
599
715
|
});
|
|
600
716
|
//#endregion
|
|
717
|
+
//#region src/nodes/createSkyColorNode.ts
|
|
718
|
+
const LEAST_DIVISOR$1 = 1e-4;
|
|
719
|
+
const HALO_TOWARD_START = .3;
|
|
720
|
+
const HALO_TOWARD_SPAN = .7;
|
|
721
|
+
const HALO_SUN_HEIGHT_START = .2;
|
|
722
|
+
const HALO_SUN_HEIGHT_SPAN = .3;
|
|
723
|
+
const SUN_HALO_MIDDLE_SPREAD = .1;
|
|
724
|
+
const SUN_HALO_MIDDLE_WEIGHT = .12;
|
|
725
|
+
const SUN_HALO_OUTER_SPREAD = .01;
|
|
726
|
+
const SUN_HALO_OUTER_WEIGHT = .03;
|
|
727
|
+
const createSkyColorNode = ({ frontBackBlend, haloColor, haloHeight, horizonBackColor, horizonBand, horizonColor, sunDirection, sunHaloColor, sunHaloSize, zenithBackColor, zenithColor }, gradient, direction) => {
|
|
728
|
+
const height = direction.y;
|
|
729
|
+
const elevation = abs(asin(clamp(height, -1, 1)).mul(2 / Math.PI));
|
|
730
|
+
const sunCosine = direction.dot(sunDirection);
|
|
731
|
+
const toward = pow(max(sunCosine.mul(frontBackBlend).add(float(1).sub(frontBackBlend)), 0), 3);
|
|
732
|
+
const top = mix(zenithBackColor, zenithColor, toward);
|
|
733
|
+
const bottom = mix(horizonBackColor, horizonColor, toward);
|
|
734
|
+
const bottomShare = texture(gradient, vec2(elevation.div(max(horizonBand, LEAST_DIVISOR$1)), .5)).r;
|
|
735
|
+
const haloShare = texture(gradient, vec2(elevation.div(max(haloHeight, LEAST_DIVISOR$1)), .5)).g;
|
|
736
|
+
const sunSide = saturate(sunCosine.mul(.5).add(.5));
|
|
737
|
+
const towardSun = smoothstep(0, 1, max(sunSide.sub(HALO_TOWARD_START).div(HALO_TOWARD_SPAN), 0));
|
|
738
|
+
const sunUp = smoothstep(0, 1, saturate(abs(sunDirection.y).sub(HALO_SUN_HEIGHT_START).div(HALO_SUN_HEIGHT_SPAN)));
|
|
739
|
+
const halo = haloColor.mul(haloShare).mul(sunUp.mul(float(1).sub(towardSun)).add(towardSun));
|
|
740
|
+
const spread = sunHaloSize.mul(abs(height));
|
|
741
|
+
const sunHalo = min(pow(sunSide, spread), 1).add(min(pow(sunSide, spread.mul(SUN_HALO_MIDDLE_SPREAD)), 1).mul(SUN_HALO_MIDDLE_WEIGHT)).add(min(pow(sunSide, spread.mul(SUN_HALO_OUTER_SPREAD)), 1).mul(SUN_HALO_OUTER_WEIGHT)).mul(smoothstep(0, 1, max(sunSide.sub(.5).mul(2), 0)));
|
|
742
|
+
return mix(top, bottom, bottomShare).add(halo).add(sunHaloColor.mul(sunHalo));
|
|
743
|
+
};
|
|
744
|
+
//#endregion
|
|
601
745
|
//#region src/nodes/createSkyNode.ts
|
|
602
746
|
const SUN_DISC_COSINE = Math.cos(.035);
|
|
603
747
|
const MOON_DISC_COSINE = Math.cos(.05);
|
|
604
|
-
const SUN_GLOW_POWER = 12;
|
|
605
|
-
const HORIZON_GLOW_POWER = 3;
|
|
606
748
|
const SUN_DISC_BRIGHTNESS = 6;
|
|
607
749
|
const CLOUD_SCALE = 1.6;
|
|
608
750
|
const CLOUD_MIN_HEIGHT = .04;
|
|
@@ -610,26 +752,46 @@ const CLOUD_EDGE = .04;
|
|
|
610
752
|
const CLOUD_SHADE_DEPTH = .18;
|
|
611
753
|
const STAR_SCALE = 420;
|
|
612
754
|
const STAR_THRESHOLD = .9975;
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
755
|
+
const LEAST_DIVISOR = 1e-4;
|
|
756
|
+
const MOON_GLOW_SPREAD = .1;
|
|
757
|
+
const MOON_GLOW_POWER = 6;
|
|
758
|
+
const createSkyNode = (uniforms, gradient) => {
|
|
759
|
+
const { cloudCoverage, cloudDrift, cloudLitColor, cloudShadeColor, lightColor, moonDirection, moonGlowColor, moonSize, starIntensity, sunDirection } = uniforms;
|
|
760
|
+
return Fn(() => {
|
|
761
|
+
const direction = normalWorldGeometry.normalize();
|
|
762
|
+
const height = direction.y;
|
|
763
|
+
const sunCosine = direction.dot(sunDirection);
|
|
764
|
+
const gradientColor = createSkyColorNode(uniforms, gradient, direction);
|
|
765
|
+
const moonCosine = saturate(direction.dot(moonDirection));
|
|
766
|
+
const moonGlow = pow(max(moonCosine.sub(1).div(max(moonSize.mul(MOON_GLOW_SPREAD), LEAST_DIVISOR)).add(1), 0), MOON_GLOW_POWER);
|
|
767
|
+
const sunVisibility = smoothstep(-.1, .05, sunDirection.y);
|
|
768
|
+
const sunDisc = smoothstep(SUN_DISC_COSINE - 5e-4, SUN_DISC_COSINE, sunCosine).mul(sunVisibility);
|
|
769
|
+
const moonDisc = smoothstep(MOON_DISC_COSINE - 5e-4, MOON_DISC_COSINE, direction.dot(moonDirection)).mul(smoothstep(-.05, .05, moonDirection.y));
|
|
770
|
+
const stars = smoothstep(STAR_THRESHOLD, 1, mx_cell_noise_float(direction.mul(STAR_SCALE))).mul(starIntensity).mul(smoothstep(0, .1, height));
|
|
771
|
+
const cloudPosition = direction.xz.div(max(height, CLOUD_MIN_HEIGHT)).mul(CLOUD_SCALE).add(cloudDrift);
|
|
772
|
+
const cloudNoise = mx_fractal_noise_float(vec3(cloudPosition, 0), 4, 2, .5).mul(.5).add(.5);
|
|
773
|
+
const cloudThreshold = float(1).sub(cloudCoverage);
|
|
774
|
+
const cloudDensity = smoothstep(cloudThreshold, cloudThreshold.add(CLOUD_EDGE), cloudNoise).mul(smoothstep(0, .12, height));
|
|
775
|
+
const cloudShade = smoothstep(cloudThreshold.add(CLOUD_SHADE_DEPTH), cloudThreshold.add(.22), cloudNoise);
|
|
776
|
+
const cloudColor = mix(cloudLitColor, cloudShadeColor, cloudShade);
|
|
777
|
+
const sky = gradientColor.add(moonGlowColor.mul(moonGlow)).add(vec3(stars)).add(vec3(.85, .88, 1).mul(moonDisc)).add(lightColor.mul(sunDisc.mul(SUN_DISC_BRIGHTNESS)));
|
|
778
|
+
return mix(sky, cloudColor, cloudDensity);
|
|
779
|
+
})();
|
|
780
|
+
};
|
|
781
|
+
//#endregion
|
|
782
|
+
//#region src/nodes/createStoneMaterial.ts
|
|
783
|
+
const createStoneMaterial = ({ albedo, rimColor, rimPower, rimStrength, smoothness, specularColor }, glowNode = vec3(0)) => {
|
|
784
|
+
const material = new MeshPhysicalNodeMaterial({
|
|
785
|
+
color: new Color(albedo),
|
|
786
|
+
metalness: 0,
|
|
787
|
+
roughness: 1 - smoothness,
|
|
788
|
+
specularColor: new Color().fromArray(specularColor),
|
|
789
|
+
specularIntensity: 1
|
|
790
|
+
});
|
|
791
|
+
const fresnel = float(1).sub(normalView.dot(positionViewDirection).saturate()).pow(rimPower);
|
|
792
|
+
material.emissiveNode = color(new Color().fromArray(rimColor)).mul(fresnel.mul(rimStrength)).add(glowNode);
|
|
793
|
+
return material;
|
|
794
|
+
};
|
|
633
795
|
//#endregion
|
|
634
796
|
//#region src/nodes/createWaterMaterial.ts
|
|
635
797
|
const RIPPLE_SCALE = .08;
|
|
@@ -1417,4 +1579,4 @@ const computeOutlineDistance = (outline, x, z) => {
|
|
|
1417
1579
|
return isInside ? 0 : Math.sqrt(nearestSquared);
|
|
1418
1580
|
};
|
|
1419
1581
|
//#endregion
|
|
1420
|
-
export { AntialiasingMode, GAME_MINUTES_PER_SECOND, GENSHIN_TONE_MAPPING, MINUTES_PER_DAY, QualityTier, QualityTierSettingsMap, TERRAIN_LAYER, TILE_INDEX_OFFSET, TILE_INDEX_SPAN, ToonNodeMaterial, advanceGameClock, applySkyState, computeGradeLut, computeGrassBlade, computeLeafCards, computeOriginShift, computeOutlineDistance, computeRampValues, computeSunDirection, computeTerrainIndices, computeTerrainTile, computeTreeSkeleton, createCausticsNode, createCloudAtlasTexture,
|
|
1582
|
+
export { AntialiasingMode, DEFAULT_SKY_GRADIENT, DEFAULT_SKY_SHAPE, GAME_MINUTES_PER_SECOND, GENSHIN_TONE_MAPPING, MINUTES_PER_DAY, QualityTier, QualityTierSettingsMap, TERRAIN_LAYER, TILE_INDEX_OFFSET, TILE_INDEX_SPAN, ToonNodeMaterial, addSmoothLoop, advanceGameClock, applySkyState, computeGradeLut, computeGrassBlade, computeLeafCards, computeOriginShift, computeOutlineDistance, computeRampValues, computeSunDirection, computeTerrainIndices, computeTerrainTile, computeTreeSkeleton, createBoxesGeometry, createCausticsNode, createCloudAtlasTexture, createCloudBandSprite, createFogUniforms, createGenshinRenderer, createGodraysLight, createGradeLutTexture, createGrassGeometry, createGrassMaterial, createGroundCapture, createHeightFogNode, createLatheStackGeometry, createLeafMaterial, createLightUniforms, createPostPipeline, createPostUniforms, createRampTexture, createRimNode, createSeededRandom, createSimplexNoise, createSkyColorNode, createSkyGradientTexture, createSkyNode, createSkyState, createSkyUniforms, createStatueGeometry, createStoneMaterial, createSunLight, createTerrainMaterial, createTerrainSelection, createTerrainTileGeometry, createTileStreamer, createToonMaterial, createTreeGeometry, createUnderwaterFogState, createWaterMaterial, createWaterUniforms, createWindNode, createWindUniforms, getCloudAtlasColumns, getParentTerrainTileKey, getScreenDirection, getTerrainTileColumn, getTerrainTileKey, getTerrainTileLevel, getTerrainTileRow, orderByViewDepth, placeCloudBand, renderGroundCapture, resolveTerrainDraws, sampleSkyState, selectTerrainTiles, toSceneColor, toneMapNeutral, updateUnderwaterFog };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genshin-engine",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "An anime-style open-world engine for the browser on three.js WebGPU — toon materials, outlines, post-processing, streamed terrain and parametric world kits, as plain TypeScript and TSL modules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anime",
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@arethetypeswrong/core": "^0.18.5",
|
|
56
|
-
"@esposter/configuration": "3.
|
|
57
|
-
"@esposter/shared-node": "3.
|
|
58
|
-
"@types/node": "^26.6.
|
|
56
|
+
"@esposter/configuration": "3.9.0",
|
|
57
|
+
"@esposter/shared-node": "3.9.0",
|
|
58
|
+
"@types/node": "^26.6.4",
|
|
59
59
|
"@types/three": "^0.186.0",
|
|
60
|
-
"publint": "^0.3.
|
|
60
|
+
"publint": "^0.3.25",
|
|
61
61
|
"tsdown": "^0.23.0",
|
|
62
62
|
"vitest": "^5.0.3"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"three": "^0.186.1"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "f9f6208c35e6cff4ed33910623c798cd88f09301"
|
|
68
68
|
}
|