@adatechnology/game-interactables-three 0.2.0 → 0.2.2
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 +7 -10
- package/dist/index.global.js +7 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ interface HouseholdApi extends PropsApi {
|
|
|
37
37
|
}
|
|
38
38
|
/** Anything that can create a canvas (the global `document`, or a fake in tests). */
|
|
39
39
|
interface CanvasFactory {
|
|
40
|
-
createElement(tag: 'canvas'):
|
|
40
|
+
createElement(tag: 'canvas'): HTMLCanvasElement;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
interface EffectsOptions {
|
|
@@ -244,12 +244,7 @@ interface Rest {
|
|
|
244
244
|
scale: Vec3;
|
|
245
245
|
}
|
|
246
246
|
/** Remembers the rest transform of a part group in `userData.rest` (once). */
|
|
247
|
-
declare function rememberRest(group:
|
|
248
|
-
position: any;
|
|
249
|
-
quaternion: any;
|
|
250
|
-
scale: any;
|
|
251
|
-
userData: Record<string, any>;
|
|
252
|
-
}): Rest;
|
|
247
|
+
declare function rememberRest(group: Pick<ThreeNS.Object3D, 'position' | 'quaternion' | 'scale' | 'userData'>): Rest;
|
|
253
248
|
/**
|
|
254
249
|
* Poses `group` for a motion at `t`. The rest pose (position at the pivot, rotation `ry`) is saved in `group.userData.rest` the first
|
|
255
250
|
* time, so calling this every frame never drifts. The motion axis lives in the part frame (after `ry`).
|
|
@@ -283,7 +278,7 @@ interface ScreenOptions {
|
|
|
283
278
|
interface Screen {
|
|
284
279
|
material: ThreeNS.MeshStandardMaterial;
|
|
285
280
|
texture: ThreeNS.CanvasTexture;
|
|
286
|
-
canvas:
|
|
281
|
+
canvas: HTMLCanvasElement;
|
|
287
282
|
readonly on: boolean;
|
|
288
283
|
readonly channel: number;
|
|
289
284
|
setOn(on: boolean): void;
|
|
@@ -326,7 +321,7 @@ interface SwayHandle {
|
|
|
326
321
|
}
|
|
327
322
|
/** Patches a vertex shader so the vertices hang from the anchor line and swing with the shared uniforms. */
|
|
328
323
|
declare function patchSwayShader(shader: {
|
|
329
|
-
uniforms: Record<string,
|
|
324
|
+
uniforms: Record<string, ThreeNS.IUniform>;
|
|
330
325
|
vertexShader: string;
|
|
331
326
|
}, uniforms: SwayUniforms, amplitude: number): void;
|
|
332
327
|
/**
|
|
@@ -335,13 +330,15 @@ declare function patchSwayShader(shader: {
|
|
|
335
330
|
* directional / spot shadow maps and point-light shadow cubes follow the animation. Assign it to a mesh, and set
|
|
336
331
|
* `mesh.customDepthMaterial` / `mesh.customDistanceMaterial` from the material (or just use `attachSway`).
|
|
337
332
|
*/
|
|
338
|
-
|
|
333
|
+
/** A material `swayMaterial` made: it carries its sway handle and the shadow materials that follow it. */
|
|
334
|
+
type SwayMaterial = ThreeNS.Material & {
|
|
339
335
|
userData: {
|
|
340
336
|
sway: SwayHandle;
|
|
341
337
|
depthMaterial: ThreeNS.MeshDepthMaterial;
|
|
342
338
|
distanceMaterial: ThreeNS.MeshDistanceMaterial;
|
|
343
339
|
};
|
|
344
340
|
};
|
|
341
|
+
declare function swayMaterial(THREE: ThreeLib, base: ThreeNS.Material, options?: SwayOptions): SwayMaterial;
|
|
345
342
|
/**
|
|
346
343
|
* Makes a mesh sway: replaces its material with `swayMaterial(...)` and sets `customDepthMaterial` and `customDistanceMaterial`.
|
|
347
344
|
* `mesh.userData.sway` is the handle `syncObject` drives. Returns the handle.
|
package/dist/index.global.js
CHANGED
|
@@ -41,6 +41,7 @@ var GameInteractablesThree = (() => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
// ../game-contracts/dist/index.js
|
|
44
|
+
var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
|
|
44
45
|
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
45
46
|
var DEFERRED_QUEUE_ID = {
|
|
46
47
|
DESTRUCTION_EVENTS: "destruction.events",
|
|
@@ -821,7 +822,7 @@ void main() {
|
|
|
821
822
|
};
|
|
822
823
|
}
|
|
823
824
|
|
|
824
|
-
// ../game-shapes/dist/chunk-
|
|
825
|
+
// ../game-shapes/dist/chunk-M5N2SHNL.js
|
|
825
826
|
var __defProp2 = Object.defineProperty;
|
|
826
827
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
827
828
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -2239,8 +2240,8 @@ void main() {
|
|
|
2239
2240
|
groups: []
|
|
2240
2241
|
};
|
|
2241
2242
|
}
|
|
2242
|
-
function make(
|
|
2243
|
-
switch (kind) {
|
|
2243
|
+
function make(p) {
|
|
2244
|
+
switch (p.kind) {
|
|
2244
2245
|
case "box": {
|
|
2245
2246
|
const size = p.size ?? [1, 1, 1];
|
|
2246
2247
|
const segments = p.segments ?? [1, 1, 1];
|
|
@@ -2269,7 +2270,7 @@ void main() {
|
|
|
2269
2270
|
case "mesh":
|
|
2270
2271
|
return mesh(p);
|
|
2271
2272
|
default:
|
|
2272
|
-
throw new Error(`game-shapes: unknown primitive kind "${String(kind)}"`);
|
|
2273
|
+
throw new Error(`game-shapes: unknown primitive kind "${String(p.kind)}"`);
|
|
2273
2274
|
}
|
|
2274
2275
|
}
|
|
2275
2276
|
var templates = /* @__PURE__ */ new Map();
|
|
@@ -2277,7 +2278,7 @@ void main() {
|
|
|
2277
2278
|
var stats = { hits: 0, misses: 0 };
|
|
2278
2279
|
function buildPrimitive(node, options = {}) {
|
|
2279
2280
|
const parameters = primitiveParameters(node, options);
|
|
2280
|
-
if (node.kind === "mesh" || templateLimit === 0) return make(node
|
|
2281
|
+
if (node.kind === "mesh" || templateLimit === 0) return make({ ...node, ...parameters });
|
|
2281
2282
|
const key = `${node.kind}:${canonicalJson(parameters)}`;
|
|
2282
2283
|
const cached = templates.get(key);
|
|
2283
2284
|
if (cached) {
|
|
@@ -2287,7 +2288,7 @@ void main() {
|
|
|
2287
2288
|
return cached;
|
|
2288
2289
|
}
|
|
2289
2290
|
stats.misses++;
|
|
2290
|
-
const built = make(node
|
|
2291
|
+
const built = make({ ...node, ...parameters });
|
|
2291
2292
|
templates.set(key, built);
|
|
2292
2293
|
if (templates.size > templateLimit) templates.delete(templates.keys().next().value);
|
|
2293
2294
|
return built;
|