@umicat/three-sdk 1.23.0 → 1.25.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/SceneLoader3D.d.ts +11 -0
- package/dist/SceneLoader3D.js +1 -1
- package/dist/editor/EditorDesignPlayer3D.js +89 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/SceneLoader3D.d.ts
CHANGED
|
@@ -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
|
*
|
package/dist/SceneLoader3D.js
CHANGED
|
@@ -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';
|
|
@@ -535,6 +535,20 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
535
535
|
// is here because the thing most likely to break on a rebuild is not the
|
|
536
536
|
// geometry (visibly wrong) but the instance SWAP: a gizmo still pointing at
|
|
537
537
|
// the disposed mesh renders its handles and moves nothing.
|
|
538
|
+
// Test-only — which entities are selected, and where one is. Both exist for
|
|
539
|
+
// the ground-marquee regression: the claim there is "the ground did NOT
|
|
540
|
+
// move AND both Parts got selected", and neither half is observable from
|
|
541
|
+
// the host protocol alone (a drag that moves nothing posts nothing).
|
|
542
|
+
globalThis.__umicatSelectedIds =
|
|
543
|
+
() => [...multiSelected].map((o) => entityByObject.get(o)).filter((id) => !!id);
|
|
544
|
+
globalThis.__umicatEntityWorldPos =
|
|
545
|
+
(entityId) => {
|
|
546
|
+
const o = objectByEntity.get(entityId);
|
|
547
|
+
if (!o)
|
|
548
|
+
return null;
|
|
549
|
+
const p = o.getWorldPosition(new THREE.Vector3());
|
|
550
|
+
return { x: p.x, y: p.y, z: p.z };
|
|
551
|
+
};
|
|
538
552
|
globalThis.__umicatEntityMesh =
|
|
539
553
|
(entityId) => {
|
|
540
554
|
const o = objectByEntity.get(entityId);
|
|
@@ -1214,6 +1228,36 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1214
1228
|
catch { /* enhancement only */ }
|
|
1215
1229
|
return;
|
|
1216
1230
|
}
|
|
1231
|
+
// Drag-to-move applies ONLY to something already selected. Dragging from
|
|
1232
|
+
// an UNSELECTED entity starts a marquee instead, and a click that never
|
|
1233
|
+
// moves still selects it on release.
|
|
1234
|
+
//
|
|
1235
|
+
// Why: a plain left-drag used to mean "move whatever is under the
|
|
1236
|
+
// cursor", which made box-select unreachable in the most ordinary scene
|
|
1237
|
+
// there is. A baseplate-style ground is a real entity covering the whole
|
|
1238
|
+
// viewport, so there was no empty pixel to start a marquee from — the
|
|
1239
|
+
// ⌘/Ctrl path below was added for exactly that, and then nobody could
|
|
1240
|
+
// find it, which this codebase has already learned is the same as not
|
|
1241
|
+
// having it.
|
|
1242
|
+
//
|
|
1243
|
+
// No professional editor binds "move the object" to a bare left-drag:
|
|
1244
|
+
// Unity's scene view always rubber-bands and reserves movement for the
|
|
1245
|
+
// gizmo handles, Unreal gives left-drag to the camera, Blender box-selects
|
|
1246
|
+
// by default. Requiring a selection first is the cheapest rule that gets
|
|
1247
|
+
// the same guarantee — a marquee can always be started — while keeping
|
|
1248
|
+
// click-then-drag, which casual users expect and Roblox has.
|
|
1249
|
+
if (!multiSelected.has(hit.entityRoot)) {
|
|
1250
|
+
pendingClickHit = hit;
|
|
1251
|
+
marqueeCandidate = true;
|
|
1252
|
+
marqueeAdditive = false;
|
|
1253
|
+
marqueeStartX = e.clientX;
|
|
1254
|
+
marqueeStartY = e.clientY;
|
|
1255
|
+
try {
|
|
1256
|
+
renderer.domElement.setPointerCapture(e.pointerId);
|
|
1257
|
+
}
|
|
1258
|
+
catch { /* enhancement only */ }
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1217
1261
|
marqueeCandidate = false;
|
|
1218
1262
|
pendingClickHit = null;
|
|
1219
1263
|
const objectPos = hit.entityRoot.getWorldPosition(new THREE.Vector3());
|
|
@@ -1460,6 +1504,14 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1460
1504
|
if (hudSelectedId)
|
|
1461
1505
|
selectHudEntity(null);
|
|
1462
1506
|
}
|
|
1507
|
+
else if (!modifierHeldAtDown && pendingClickHit) {
|
|
1508
|
+
// A plain click on an unselected entity. It reaches here rather than
|
|
1509
|
+
// the drag path because selecting is now the precondition FOR
|
|
1510
|
+
// dragging — so the first click selects and the second gesture moves.
|
|
1511
|
+
applySelection([pendingClickHit.entityRoot], pendingClickHit.point);
|
|
1512
|
+
if (hudSelectedId)
|
|
1513
|
+
selectHudEntity(null);
|
|
1514
|
+
}
|
|
1463
1515
|
else if (!modifierHeldAtDown && scene) {
|
|
1464
1516
|
clearWorldSelection();
|
|
1465
1517
|
if (hudSelectedId)
|
|
@@ -1756,6 +1808,21 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1756
1808
|
disposeMeshInPlace(object);
|
|
1757
1809
|
object = swapEntityObject(object, fresh, m.entityId);
|
|
1758
1810
|
}
|
|
1811
|
+
if (m.patch?.water !== undefined) {
|
|
1812
|
+
// Colour and opacity could be patched in place, size cannot — one
|
|
1813
|
+
// rebuild path rather than two, same call this scene's load and the
|
|
1814
|
+
// live create both go through.
|
|
1815
|
+
const authored = sceneData?.entities.find((e) => e.id === m.entityId);
|
|
1816
|
+
if (!authored?.water)
|
|
1817
|
+
return done(`entity '${m.entityId}' is not water`);
|
|
1818
|
+
authored.water = { ...authored.water, ...m.patch.water };
|
|
1819
|
+
const fresh = makeWaterSurface(authored.water);
|
|
1820
|
+
fresh.position.copy(object.position);
|
|
1821
|
+
fresh.quaternion.copy(object.quaternion);
|
|
1822
|
+
fresh.scale.copy(object.scale);
|
|
1823
|
+
disposeMeshInPlace(object);
|
|
1824
|
+
object = swapEntityObject(object, fresh, m.entityId);
|
|
1825
|
+
}
|
|
1759
1826
|
if (m.patch?.heightfield !== undefined) {
|
|
1760
1827
|
// ADR-050 — a heightfield has no incremental edit: every patchable
|
|
1761
1828
|
// field (size, either resolution, material, colour) changes the vertex
|
|
@@ -1808,6 +1875,15 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1808
1875
|
if (error)
|
|
1809
1876
|
console.warn('[umicat/editor] 3D model drop failed:', m.entityId, error);
|
|
1810
1877
|
window.parent.postMessage({ type: 'umicat:editor:modelDropped3d', entityId: m.entityId, ok: !error, error, position }, '*');
|
|
1878
|
+
// Select what was just placed. Every editor does this, and since
|
|
1879
|
+
// drag-to-move now REQUIRES a selection, a freshly dropped entity that
|
|
1880
|
+
// was not selected could not be nudged without clicking it first —
|
|
1881
|
+
// which is a strange thing to ask of someone who just put it there.
|
|
1882
|
+
if (!error) {
|
|
1883
|
+
const placed = objectByEntity.get(m.entityId);
|
|
1884
|
+
if (placed)
|
|
1885
|
+
applySelection([placed]);
|
|
1886
|
+
}
|
|
1811
1887
|
};
|
|
1812
1888
|
if (!scene)
|
|
1813
1889
|
return done('no scene loaded yet');
|
|
@@ -1859,6 +1935,15 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1859
1935
|
if (error)
|
|
1860
1936
|
console.warn('[umicat/editor] 3D primitive drop failed:', m.entityId, error);
|
|
1861
1937
|
window.parent.postMessage({ type: 'umicat:editor:primitiveDropped3d', entityId: m.entityId, ok: !error, error, position, collider }, '*');
|
|
1938
|
+
// Select what was just placed. Every editor does this, and since
|
|
1939
|
+
// drag-to-move now REQUIRES a selection, a freshly dropped entity that
|
|
1940
|
+
// was not selected could not be nudged without clicking it first —
|
|
1941
|
+
// which is a strange thing to ask of someone who just put it there.
|
|
1942
|
+
if (!error) {
|
|
1943
|
+
const placed = objectByEntity.get(m.entityId);
|
|
1944
|
+
if (placed)
|
|
1945
|
+
applySelection([placed]);
|
|
1946
|
+
}
|
|
1862
1947
|
};
|
|
1863
1948
|
if (!scene)
|
|
1864
1949
|
return done('no scene loaded yet');
|
|
@@ -1959,6 +2044,9 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
|
|
|
1959
2044
|
object.castShadow = e.primitive.kind !== 'plane';
|
|
1960
2045
|
object.receiveShadow = true;
|
|
1961
2046
|
}
|
|
2047
|
+
else if (e.water) {
|
|
2048
|
+
object = makeWaterSurface(e.water);
|
|
2049
|
+
}
|
|
1962
2050
|
else if (e.heightfield) {
|
|
1963
2051
|
try {
|
|
1964
2052
|
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.
|
|
3
|
+
"version": "1.25.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",
|