@adatechnology/game-weather-three 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/index.d.ts +18 -1
- package/dist/index.global.js +11 -19
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +11 -19
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -33,8 +33,9 @@ picture.update(dt)
|
|
|
33
33
|
## Bench
|
|
34
34
|
|
|
35
35
|
`createWeatherTestModule({ visual: createWeatherVisual({ vfx: room.vfx }) })` (the module of `game-weather`) adds the picture to the weather bench: seven layers
|
|
36
|
-
(rain curtain, near rain and splashes, mist and ash, sky, lightning, headlights, heat haze; names in pt-BR and en), and a lamp rig
|
|
37
|
-
|
|
36
|
+
(rain curtain, near rain and splashes, mist and ash, sky, lightning, headlights, heat haze; names in pt-BR and en), and a lamp rig in front of the camera to show the headlights. The rig's car is not drawn here: pass
|
|
37
|
+
`vehicles: (THREE) => createVehiclesThree(THREE, { kit })` (game-vehicles-three, with the fleet installed) and it builds a fleet car (`rigVehicle`, default
|
|
38
|
+
`midsize_sedan`) under the lamps, so it follows the vehicles SDK; without it the rig has only the lamps and their beams. `layers: { sky: false }` keeps a room's own sky; the bench's own `fog` layer reaches the
|
|
38
39
|
renderer too. The fog layer gives back the fog the host had when it is switched off.
|
|
39
40
|
|
|
40
41
|
## Proof
|
package/dist/index.d.ts
CHANGED
|
@@ -313,9 +313,26 @@ type WeatherVisualOptions = Pick<WeatherRendererOptions, 'profile' | 'random' |
|
|
|
313
313
|
readonly vfx?: VfxWorld;
|
|
314
314
|
/** Where the lamp rig stands (the two headlights of the Workshop's car, to see the beams); `false` leaves it out. Default 2.5 m ahead of the test room camera, lamps toward it. */
|
|
315
315
|
readonly rig?: readonly [x: number, z: number, turn: number] | false;
|
|
316
|
+
/**
|
|
317
|
+
* The car the lamps are mounted on, built by the vehicles SDK for the host's three.js (`createVehiclesThree` of game-vehicles-three with the fleet installed), so the rig follows the fleet when it
|
|
318
|
+
* changes. Without it the rig has only the lamps and their beams: no car drawn here.
|
|
319
|
+
*/
|
|
320
|
+
readonly vehicles?: (THREE: ThreeLib) => RigVehicles;
|
|
321
|
+
/** Fleet id of the rig's car (default `midsize_sedan`). */
|
|
322
|
+
readonly rigVehicle?: string;
|
|
316
323
|
/** Which layers start on (all do by default); the room that is not about weather starts the sky and the fog off to keep its own look. */
|
|
317
324
|
readonly layers?: Partial<Record<WeatherLayerId, boolean>>;
|
|
318
325
|
};
|
|
326
|
+
/** What the rig needs of the vehicles SDK (`VehiclesThree` of game-vehicles-three): a car in the game frame (front on +z, wheels on y = 0) and its length. */
|
|
327
|
+
interface RigVehicles {
|
|
328
|
+
build(key: string, options?: {
|
|
329
|
+
quality?: 'high' | 'lite';
|
|
330
|
+
}): {
|
|
331
|
+
readonly group: THREE_NS.Object3D;
|
|
332
|
+
readonly length: number;
|
|
333
|
+
dispose(): void;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
319
336
|
/**
|
|
320
337
|
* The picture of the weather for the weather bench: `createWeatherTestModule({ visual: createWeatherVisual({ vfx: room.vfx }) })`. It draws the weather the bench shows with
|
|
321
338
|
* `createWeatherRenderer` on the room's scene and camera, switches each part with the bench layers and puts a lamp rig in front of the camera for the headlights.
|
|
@@ -328,4 +345,4 @@ type WeatherVisualText = {
|
|
|
328
345
|
};
|
|
329
346
|
declare const weatherVisualTextOf: (locale: string) => WeatherVisualText;
|
|
330
347
|
|
|
331
|
-
export { ASH, FOG_EXP_FROM, FOG_NEAR, FOG_ZONE_NEAR, type Fog, type FogValues, HEADLIGHTS, HEAT_HAZE, HEAT_HAZE_FRAGMENT, HEAT_HAZE_VERTEX, type HeadlightRules, type Headlights, type HeatHaze, LIGHTNING, type Lightning, MIST, type NearRain, type NearRainOptions, RAIN_CURTAIN, RAIN_CURTAIN_FRAGMENT, RAIN_CURTAIN_FULL_AT, RAIN_CURTAIN_PROFILES, RAIN_CURTAIN_VERTEX, type RainCurtain, type RainCurtainOptions, SKY_DAY, SKY_NIGHT, SPLASH_FROM_MM, type Sky, type ThreeLib, type Vec3, WEATHER_LAYERS, type WeatherLayerId, type WeatherProfileName, type WeatherRenderer, type WeatherRendererOptions, type WeatherSource, type WeatherVisualOptions, type WeatherVisualText, ZONE_FOG_DEFAULTS, ZONE_LIGHT, type ZoneFog, createFog, createHeadlights, createHeatHaze, createLightning, createNearRain, createRainCurtain, createSky, createWeatherRenderer, createWeatherVisual, defaultHeadlightRule, densityForFar, emitAirborne, fogOf, rainCurtainPositions, weatherVisualTextOf };
|
|
348
|
+
export { ASH, FOG_EXP_FROM, FOG_NEAR, FOG_ZONE_NEAR, type Fog, type FogValues, HEADLIGHTS, HEAT_HAZE, HEAT_HAZE_FRAGMENT, HEAT_HAZE_VERTEX, type HeadlightRules, type Headlights, type HeatHaze, LIGHTNING, type Lightning, MIST, type NearRain, type NearRainOptions, RAIN_CURTAIN, RAIN_CURTAIN_FRAGMENT, RAIN_CURTAIN_FULL_AT, RAIN_CURTAIN_PROFILES, RAIN_CURTAIN_VERTEX, type RainCurtain, type RainCurtainOptions, type RigVehicles, SKY_DAY, SKY_NIGHT, SPLASH_FROM_MM, type Sky, type ThreeLib, type Vec3, WEATHER_LAYERS, type WeatherLayerId, type WeatherProfileName, type WeatherRenderer, type WeatherRendererOptions, type WeatherSource, type WeatherVisualOptions, type WeatherVisualText, ZONE_FOG_DEFAULTS, ZONE_LIGHT, type ZoneFog, createFog, createHeadlights, createHeatHaze, createLightning, createNearRain, createRainCurtain, createSky, createWeatherRenderer, createWeatherVisual, defaultHeadlightRule, densityForFar, emitAirborne, fogOf, rainCurtainPositions, weatherVisualTextOf };
|
package/dist/index.global.js
CHANGED
|
@@ -2356,29 +2356,21 @@ var GameWeatherThree = (() => {
|
|
|
2356
2356
|
var weatherVisualTextOf = (locale) => TEXTS[locale] ?? TEXTS[locale.split("-")[0] ?? "en"] ?? TEXTS.en;
|
|
2357
2357
|
|
|
2358
2358
|
// src/bench/visual.ts
|
|
2359
|
+
var RIG_VEHICLE = "midsize_sedan";
|
|
2359
2360
|
var LAYER_ORDER = ["far_rain", "near_rain", "mist", "sky", "lightning", "headlights", "haze"];
|
|
2360
2361
|
var RIG_DEFAULT = [1.6, -2.5, 0];
|
|
2361
|
-
function buildRig(THREE) {
|
|
2362
|
+
function buildRig(THREE, vehicles, key) {
|
|
2362
2363
|
const group = new THREE.Group();
|
|
2363
2364
|
group.name = "weather-lamp-rig";
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
for (const side of [-1, 1]) {
|
|
2369
|
-
const lamp = new THREE.Mesh(lampGeometry, lens2);
|
|
2370
|
-
lamp.position.set(side * HEADLIGHTS.lamp[0], HEADLIGHTS.lamp[1], 2.11);
|
|
2371
|
-
group.add(lamp);
|
|
2365
|
+
const car = vehicles?.build(key, { quality: "lite" });
|
|
2366
|
+
if (car) {
|
|
2367
|
+
car.group.position.z = HEADLIGHTS.lamp[2] + 0.1 - car.length / 2;
|
|
2368
|
+
group.add(car.group);
|
|
2372
2369
|
}
|
|
2373
|
-
group.add(body);
|
|
2374
2370
|
return {
|
|
2375
2371
|
group,
|
|
2376
|
-
lens: lens2,
|
|
2377
2372
|
dispose() {
|
|
2378
|
-
|
|
2379
|
-
body.material.dispose();
|
|
2380
|
-
lampGeometry.dispose();
|
|
2381
|
-
lens2.dispose();
|
|
2373
|
+
car?.dispose();
|
|
2382
2374
|
}
|
|
2383
2375
|
};
|
|
2384
2376
|
}
|
|
@@ -2403,19 +2395,19 @@ var GameWeatherThree = (() => {
|
|
|
2403
2395
|
...options.headlights ? { headlights: options.headlights } : {},
|
|
2404
2396
|
...options.layers ? { layers: options.layers } : {}
|
|
2405
2397
|
});
|
|
2406
|
-
return attachRig(THREE, host, renderer, options.rig === void 0 ? RIG_DEFAULT : options.rig);
|
|
2398
|
+
return attachRig(THREE, host, renderer, options.rig === void 0 ? RIG_DEFAULT : options.rig, options.vehicles?.(THREE), options.rigVehicle ?? RIG_VEHICLE);
|
|
2407
2399
|
}
|
|
2408
2400
|
};
|
|
2409
2401
|
}
|
|
2410
|
-
function attachRig(THREE, host, renderer, place) {
|
|
2402
|
+
function attachRig(THREE, host, renderer, place, vehicles, key) {
|
|
2411
2403
|
const scene = host.scene;
|
|
2412
|
-
const rig = place === false ? void 0 : buildRig(THREE);
|
|
2404
|
+
const rig = place === false ? void 0 : buildRig(THREE, vehicles, key);
|
|
2413
2405
|
let detach;
|
|
2414
2406
|
if (rig && place) {
|
|
2415
2407
|
rig.group.position.set(place[0], 0, place[1]);
|
|
2416
2408
|
rig.group.rotation.y = place[2];
|
|
2417
2409
|
scene.add(rig.group);
|
|
2418
|
-
detach = renderer.headlights.attach(rig.group
|
|
2410
|
+
detach = renderer.headlights.attach(rig.group);
|
|
2419
2411
|
}
|
|
2420
2412
|
return {
|
|
2421
2413
|
update: (dt) => renderer.update(dt),
|