@adatechnology/game-interactables-three 0.2.0 → 0.2.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/dist/index.d.ts +7 -10
- package/dist/index.global.js +6 -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
|
@@ -821,7 +821,7 @@ void main() {
|
|
|
821
821
|
};
|
|
822
822
|
}
|
|
823
823
|
|
|
824
|
-
// ../game-shapes/dist/chunk-
|
|
824
|
+
// ../game-shapes/dist/chunk-M5N2SHNL.js
|
|
825
825
|
var __defProp2 = Object.defineProperty;
|
|
826
826
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
827
827
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -2239,8 +2239,8 @@ void main() {
|
|
|
2239
2239
|
groups: []
|
|
2240
2240
|
};
|
|
2241
2241
|
}
|
|
2242
|
-
function make(
|
|
2243
|
-
switch (kind) {
|
|
2242
|
+
function make(p) {
|
|
2243
|
+
switch (p.kind) {
|
|
2244
2244
|
case "box": {
|
|
2245
2245
|
const size = p.size ?? [1, 1, 1];
|
|
2246
2246
|
const segments = p.segments ?? [1, 1, 1];
|
|
@@ -2269,7 +2269,7 @@ void main() {
|
|
|
2269
2269
|
case "mesh":
|
|
2270
2270
|
return mesh(p);
|
|
2271
2271
|
default:
|
|
2272
|
-
throw new Error(`game-shapes: unknown primitive kind "${String(kind)}"`);
|
|
2272
|
+
throw new Error(`game-shapes: unknown primitive kind "${String(p.kind)}"`);
|
|
2273
2273
|
}
|
|
2274
2274
|
}
|
|
2275
2275
|
var templates = /* @__PURE__ */ new Map();
|
|
@@ -2277,7 +2277,7 @@ void main() {
|
|
|
2277
2277
|
var stats = { hits: 0, misses: 0 };
|
|
2278
2278
|
function buildPrimitive(node, options = {}) {
|
|
2279
2279
|
const parameters = primitiveParameters(node, options);
|
|
2280
|
-
if (node.kind === "mesh" || templateLimit === 0) return make(node
|
|
2280
|
+
if (node.kind === "mesh" || templateLimit === 0) return make({ ...node, ...parameters });
|
|
2281
2281
|
const key = `${node.kind}:${canonicalJson(parameters)}`;
|
|
2282
2282
|
const cached = templates.get(key);
|
|
2283
2283
|
if (cached) {
|
|
@@ -2287,7 +2287,7 @@ void main() {
|
|
|
2287
2287
|
return cached;
|
|
2288
2288
|
}
|
|
2289
2289
|
stats.misses++;
|
|
2290
|
-
const built = make(node
|
|
2290
|
+
const built = make({ ...node, ...parameters });
|
|
2291
2291
|
templates.set(key, built);
|
|
2292
2292
|
if (templates.size > templateLimit) templates.delete(templates.keys().next().value);
|
|
2293
2293
|
return built;
|