@umicat/three-sdk 1.23.0 → 1.24.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.
@@ -128,6 +128,17 @@ export interface WaterVolume3D {
128
128
  min: Vec3;
129
129
  max: Vec3;
130
130
  }
131
+ /**
132
+ * The visible surface of a body of water: one translucent quad at the top of
133
+ * the volume.
134
+ *
135
+ * `depthWrite` off and `DoubleSide` on, both load-bearing. Writing depth would
136
+ * make the water hide everything behind it that draws later — the riverbed,
137
+ * anything submerged — which reads as water that is somehow opaque from one
138
+ * angle only. Single-sided would make it vanish the moment the camera dips
139
+ * below the surface, exactly when a swimming player is looking at it.
140
+ */
141
+ export declare function makeWaterSurface(w: NonNullable<Entity3D['water']>): THREE.Mesh;
131
142
  /**
132
143
  * ADR-050 — build one heightfield's surface and its collider grid.
133
144
  *
@@ -367,7 +367,7 @@ export function heightfieldGeometry(heights, n, size) {
367
367
  * angle only. Single-sided would make it vanish the moment the camera dips
368
368
  * below the surface, exactly when a swimming player is looking at it.
369
369
  */
370
- function makeWaterSurface(w) {
370
+ export function makeWaterSurface(w) {
371
371
  const geom = new THREE.PlaneGeometry(w.size.x, w.size.z);
372
372
  geom.rotateX(-Math.PI / 2);
373
373
  const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
3
- import { loadScene3D, loadModelAsset, makePrimitive, makeHeightfield, applyTransform } from '../SceneLoader3D.js';
3
+ import { loadScene3D, loadModelAsset, makePrimitive, makeHeightfield, makeWaterSurface, applyTransform } from '../SceneLoader3D.js';
4
4
  import { applySkin } from '../Skin.js';
5
5
  import { applyAttachments } from '../Attachments.js';
6
6
  import { singleModelManifest, defaultColliderForPrimitive, groundRestOffset } from '../scene3d.js';
@@ -1756,6 +1756,21 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1756
1756
  disposeMeshInPlace(object);
1757
1757
  object = swapEntityObject(object, fresh, m.entityId);
1758
1758
  }
1759
+ if (m.patch?.water !== undefined) {
1760
+ // Colour and opacity could be patched in place, size cannot — one
1761
+ // rebuild path rather than two, same call this scene's load and the
1762
+ // live create both go through.
1763
+ const authored = sceneData?.entities.find((e) => e.id === m.entityId);
1764
+ if (!authored?.water)
1765
+ return done(`entity '${m.entityId}' is not water`);
1766
+ authored.water = { ...authored.water, ...m.patch.water };
1767
+ const fresh = makeWaterSurface(authored.water);
1768
+ fresh.position.copy(object.position);
1769
+ fresh.quaternion.copy(object.quaternion);
1770
+ fresh.scale.copy(object.scale);
1771
+ disposeMeshInPlace(object);
1772
+ object = swapEntityObject(object, fresh, m.entityId);
1773
+ }
1759
1774
  if (m.patch?.heightfield !== undefined) {
1760
1775
  // ADR-050 — a heightfield has no incremental edit: every patchable
1761
1776
  // field (size, either resolution, material, colour) changes the vertex
@@ -1959,6 +1974,9 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1959
1974
  object.castShadow = e.primitive.kind !== 'plane';
1960
1975
  object.receiveShadow = true;
1961
1976
  }
1977
+ else if (e.water) {
1978
+ object = makeWaterSurface(e.water);
1979
+ }
1962
1980
  else if (e.heightfield) {
1963
1981
  try {
1964
1982
  object = (await makeHeightfield(e.heightfield, manifest, { assetBase: '' })).mesh;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { ThreeUmicat } from './ThreeUmicat.js';
2
2
  export type { UmicatInitOptions } from './ThreeUmicat.js';
3
3
  export * from './scene3d.js';
4
- export { loadScene3D, loadModelAsset, heightfieldGeometry, makeHeightfield, HEIGHTMAP_LIBRARY, HEIGHTMAP_DEFAULT_SIZE } from './SceneLoader3D.js';
4
+ export { loadScene3D, loadModelAsset, heightfieldGeometry, makeHeightfield, makeWaterSurface, HEIGHTMAP_LIBRARY, HEIGHTMAP_DEFAULT_SIZE } from './SceneLoader3D.js';
5
5
  export { CharacterController3D } from './CharacterController3D.js';
6
6
  export type { CharacterOptions, CharacterState, CharacterInput } from './CharacterController3D.js';
7
7
  export { CharacterAnimator } from './CharacterAnimator.js';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // that turns it into a three.js scene with physics, and the runtime glue.
6
6
  export { ThreeUmicat } from './ThreeUmicat.js';
7
7
  export * from './scene3d.js';
8
- export { loadScene3D, loadModelAsset, heightfieldGeometry, makeHeightfield, HEIGHTMAP_LIBRARY, HEIGHTMAP_DEFAULT_SIZE } from './SceneLoader3D.js';
8
+ export { loadScene3D, loadModelAsset, heightfieldGeometry, makeHeightfield, makeWaterSurface, HEIGHTMAP_LIBRARY, HEIGHTMAP_DEFAULT_SIZE } from './SceneLoader3D.js';
9
9
  export { CharacterController3D } from './CharacterController3D.js';
10
10
  export { CharacterAnimator } from './CharacterAnimator.js';
11
11
  export { Input3D } from './Input3D.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umicat/three-sdk",
3
- "version": "1.23.0",
3
+ "version": "1.24.0",
4
4
  "description": "Three.js runtime for Umicat games: the scene3d design format, its loader with physics, a kinematic character controller, and the Umicat platform via @umicat/platform-sdk.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",