@hology/core 0.0.179 → 0.0.180

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.
@@ -41,15 +41,30 @@ export declare enum SerializedParamType {
41
41
  Curve = 22,
42
42
  ColorLayer = 23,
43
43
  MaskLayer = 24,
44
- Prefab = 25
44
+ Prefab = 25,
45
+ PrefabActor = 26
45
46
  }
46
47
  export type CustomParamValue = {
47
48
  type: SerializedParamType;
48
49
  value: unknown;
50
+ /**
51
+ * When true, this value explicitly overrides any default.
52
+ * When false or undefined, the parameter uses its default value.
53
+ * Only meaningful in contexts where overrides are supported
54
+ * (prefab instances, actor params with optional).
55
+ */
56
+ override?: boolean;
49
57
  } | {
50
58
  type: SerializedParamType.Array;
51
59
  element: SerializedParamType;
52
60
  value: unknown[];
61
+ /**
62
+ * When true, this value explicitly overrides any default.
63
+ * When false or undefined, the parameter uses its default value.
64
+ * Only meaningful in contexts where overrides are supported
65
+ * (prefab instances, actor params with optional).
66
+ */
67
+ override?: boolean;
53
68
  };
54
69
  /**
55
70
  * This serialized float param value take take multiple forms
@@ -161,7 +176,28 @@ export type Asset = {
161
176
  };
162
177
  /** Prefab settings only for asset type prefab */
163
178
  prefab?: {
179
+ /**
180
+ * Objects that make up the prefab. These are the canonical structural data
181
+ * for the prefab asset. Structure (components, child actors) lives in the
182
+ * prefab and cannot be changed per-instance.
183
+ */
164
184
  objects: SceneObject[];
185
+ /**
186
+ * Optional: the local id (within `objects`) of the single actor that the
187
+ * prefab exposes as its identity. When set, the prefab exposes exactly one
188
+ * actor. Prefab instances behave like instances of that actor type for the
189
+ * purposes of typed references and parameter overrides.
190
+ *
191
+ * Important semantics:
192
+ * - This id is local to the prefab asset's object graph and must not be
193
+ * treated as a global actor id.
194
+ * - A prefab may expose zero or one actor. Multiple exposed actors are not
195
+ * supported.
196
+ * - External references should point to the prefab instance id (not this
197
+ * internal actor id). At runtime, resolving a reference to a prefab
198
+ * instance returns the exposed actor instance inside the prefab.
199
+ */
200
+ mainActorId?: string;
165
201
  };
166
202
  components?: AttachedComponent[];
167
203
  /** Texture settings only for asset type texture */
@@ -213,4 +249,58 @@ export interface SceneBlobV0 {
213
249
  data: string;
214
250
  sceneId: string;
215
251
  }
252
+ /**
253
+ * A lightweight reference that may point to either a concrete actor id or a
254
+ * prefab instance id. Gameplay code should resolve this transparently:
255
+ * - If it points to an actor id, return that actor.
256
+ * - If it points to a prefab instance id, return the exposed actor instance
257
+ * inside the prefab (if any).
258
+ *
259
+ * Important: Prefab assets internally identify actors using local ids. External
260
+ * references must never store those internal ids directly; they should store
261
+ * the global actor id or the prefab instance id instead.
262
+ */
263
+ export type ActorReference = {
264
+ type: 'actor';
265
+ id: string;
266
+ } | {
267
+ type: 'prefab';
268
+ id: string;
269
+ };
270
+ /**
271
+ * Representation of a prefab instance within a scene. Prefab instances are
272
+ * stable identities that reference a prefab asset and may provide data-only
273
+ * overrides for the prefab's exposed actor.
274
+ *
275
+ * - `params` maps actor parameter paths to serialized values. Only
276
+ * parameter values are allowed to vary per-instance; structural changes are
277
+ * not permitted here.
278
+ */
279
+ export type PrefabInstanceSettings = {
280
+ /**
281
+ * Map from actor parameter path -> serialized value. Keys are editor-specific
282
+ * parameter path strings (for example, a path to the exposed actor's param).
283
+ * Values are serialized using the existing CustomParamValue format where
284
+ * appropriate, or primitives for simple types.
285
+ */
286
+ params?: Record<string, CustomParamValue>;
287
+ /**
288
+ * Per-inner-component overrides for the exposed actor. Stored in the same
289
+ * shape as `ActorSettings.innerParams` so it mirrors actor-local inner
290
+ * parameter groups.
291
+ *
292
+ * Example:
293
+ * [ { path: ['gun','mesh'], params: { color: { type: SerializedParamType.Color, value: '#fff' } } } ]
294
+ */
295
+ innerParams?: {
296
+ path: string[];
297
+ params: Record<string, CustomParamValue>;
298
+ }[];
299
+ /**
300
+ * Optional denormalized copy of the prefab asset's mainActorId to make
301
+ * lookups inexpensive. This is informational and can be derived from the
302
+ * prefab asset; it is not authoritative for prefab structure.
303
+ */
304
+ mainActorId?: string;
305
+ };
216
306
  //# sourceMappingURL=model.d.ts.map
@@ -1,4 +1,4 @@
1
- export var DetailTier;!function(e){e[e.low=0]="low",e[e.medium=1]="medium",e[e.high=2]="high"}(DetailTier||(DetailTier={}));export var SerializedParamType;!function(e){e[e.FloatNode=0]="FloatNode",e[e.Number=1]="Number",e[e.Texture=2]="Texture",e[e.Sampler2DNode=3]="Sampler2DNode",e[e.Boolean=4]="Boolean",e[e.BooleanNode=5]="BooleanNode",e[e.Vector2=6]="Vector2",e[e.Vec2Node=7]="Vec2Node",e[e.Vector3=8]="Vector3",e[e.Vec3Node=9]="Vec3Node",e[e.Color=10]="Color",e[e.RgbNode=11]="RgbNode",e[e.String=12]="String",e[e.BaseActor=13]="BaseActor",e[e.Euler=14]="Euler",e[e.Object3D=15]="Object3D",e[e.Material=16]="Material",e[e.AudioBuffer=17]="AudioBuffer",e[e.Vector4=18]="Vector4",e[e.Vec4Node=19]="Vec4Node",e[e.VisualEffect=20]="VisualEffect",e[e.Array=21]="Array",e[e.Curve=22]="Curve",e[e.ColorLayer=23]="ColorLayer",e[e.MaskLayer=24]="MaskLayer",e[e.Prefab=25]="Prefab"}(SerializedParamType||(SerializedParamType={}));/*
1
+ export var DetailTier;!function(e){e[e.low=0]="low",e[e.medium=1]="medium",e[e.high=2]="high"}(DetailTier||(DetailTier={}));export var SerializedParamType;!function(e){e[e.FloatNode=0]="FloatNode",e[e.Number=1]="Number",e[e.Texture=2]="Texture",e[e.Sampler2DNode=3]="Sampler2DNode",e[e.Boolean=4]="Boolean",e[e.BooleanNode=5]="BooleanNode",e[e.Vector2=6]="Vector2",e[e.Vec2Node=7]="Vec2Node",e[e.Vector3=8]="Vector3",e[e.Vec3Node=9]="Vec3Node",e[e.Color=10]="Color",e[e.RgbNode=11]="RgbNode",e[e.String=12]="String",e[e.BaseActor=13]="BaseActor",e[e.Euler=14]="Euler",e[e.Object3D=15]="Object3D",e[e.Material=16]="Material",e[e.AudioBuffer=17]="AudioBuffer",e[e.Vector4=18]="Vector4",e[e.Vec4Node=19]="Vec4Node",e[e.VisualEffect=20]="VisualEffect",e[e.Array=21]="Array",e[e.Curve=22]="Curve",e[e.ColorLayer=23]="ColorLayer",e[e.MaskLayer=24]="MaskLayer",e[e.Prefab=25]="Prefab",e[e.PrefabActor=26]="PrefabActor"}(SerializedParamType||(SerializedParamType={}));/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,11 +1,16 @@
1
1
  import { Object3D } from "three";
2
- import { Asset } from "../model";
3
2
  import { BaseActor } from "../../gameplay/actors/actor.js";
3
+ import { Asset } from "../model";
4
4
  export declare class Prefab {
5
5
  asset: Asset;
6
6
  }
7
7
  export declare class PrefabInstance {
8
8
  object: Object3D;
9
9
  actors: BaseActor[];
10
+ mainActor: BaseActor | null;
11
+ }
12
+ export declare class PrefabOf<T extends BaseActor> {
13
+ readonly prefab: Prefab;
14
+ constructor(prefab: Prefab);
10
15
  }
11
16
  //# sourceMappingURL=prefab.d.ts.map
@@ -1,4 +1,4 @@
1
- export class Prefab{constructor(s){this.asset=s}}export class PrefabInstance{}/*
1
+ export class Prefab{constructor(s){this.asset=s}}export class PrefabInstance{}export class PrefabOf{constructor(s){this.prefab=s}}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -4,10 +4,10 @@ import { BaseActor } from '../gameplay/actors/actor.js';
4
4
  import { Color, Euler, Material, Object3D, Texture, Vector2, Vector3, Vector4 } from 'three';
5
5
  import { BooleanNode, FloatNode, RgbNode, Sampler2DNode, Vec2Node, Vec3Node, Vec4Node } from '../shader-nodes/index.js';
6
6
  import { VisualEffect } from '../effects/vfx/vfx-param.js';
7
- import { Prefab } from '../scene/objects/prefab.js';
7
+ import { Prefab, PrefabOf } from '../scene/objects/prefab.js';
8
8
  import { Curve2 } from '../utils/curve.js';
9
9
  import { ColorLayer, MaskLayer } from './color-layer.js';
10
- export type ParameterType = Type<FloatNode | Number | Texture | Sampler2DNode | Boolean | BooleanNode | Vector2 | Vec2Node | Vector3 | Vec3Node | Vector4 | Vec4Node | Color | RgbNode | String | BaseActor | Euler | Object3D | Material | VisualEffect | Prefab | Curve2 | ColorLayer | MaskLayer>;
10
+ export type ParameterType = Type<FloatNode | Number | Texture | Sampler2DNode | Boolean | BooleanNode | Vector2 | Vec2Node | Vector3 | Vec3Node | Vector4 | Vec4Node | Color | RgbNode | String | BaseActor | Euler | Object3D | Material | VisualEffect | Prefab | PrefabOf<BaseActor> | Curve2 | ColorLayer | MaskLayer>;
11
11
  export type ParameterOption<T> = {
12
12
  name: string;
13
13
  value: T;
@@ -24,6 +24,24 @@ export interface ParameterOptions {
24
24
  help?: string;
25
25
  /** Only show this parameter when the specified properties have the required values */
26
26
  requires?: Record<string, unknown>;
27
+ /**
28
+ * When true, enables override mode for this parameter.
29
+ * The parameter will show an override checkbox in the editor,
30
+ * allowing the user to explicitly opt-in to overriding the default value.
31
+ */
32
+ optional?: boolean;
33
+ /**
34
+ * Restrict prefabs to be possible to select to those that have a main actor
35
+ * that inherits from the given actor class.
36
+ * This option should be used together with the property type PrefabOf<T>
37
+ * The property value can then be using in world.spawnActor which instantiates
38
+ * the prefab and returns the actor with a correct type.
39
+ *
40
+ * Example:
41
+ * @Parameter({prefabOf: BaseActor})
42
+ * prefab: PrefabOf<BaseActor>
43
+ */
44
+ prefabOf?: Type<BaseActor>;
27
45
  }
28
46
  export interface PropertyParameter {
29
47
  name: string;
@@ -1,4 +1,4 @@
1
- import"reflect-metadata";import{reflect as t,decorateProperty as e}from"@plumier/reflect";import{ArrayMap as r}from"../utils/collections.js";Symbol("format");class o{constructor(t){this.options=t,this.isParameterDecorator=!0}}new Map;const a=new r;export function Parameter(t){return function(r,n,c){if(null!=r){a.push(r.constructor,{name:n,options:t??{}});try{e(new o(t))(r,n,c)}catch(t){console.warn("Failed to decorate method ",r,n,c)}}}}export function extractShaderParameters(t){if(null==t)return[];const e=a.get(t).map(({name:e,options:r})=>{const o=Reflect.getMetadata("design:type",t.prototype,e),a=r.type??o;return r.array=o===Array,{name:e,type:a,options:r}});return[...extractShaderParameters(Object.getPrototypeOf(t)).filter(t=>e.every(e=>e.name!==t.name)),...e]}export function ParameterCategory(t){}/*
1
+ import"reflect-metadata";import{reflect as t,decorateProperty as e}from"@plumier/reflect";import{ArrayMap as r}from"../utils/collections.js";Symbol("format");class o{constructor(t){this.options=t,this.isParameterDecorator=!0}}new Map;const a=new r;export function Parameter(t){return function(r,n,c){if(null!=r){a.push(r.constructor,{name:n,options:t??{}});try{e(new o(t))(r,n,c)}catch(t){console.warn("Failed to decorate method ",r,n,c)}}}}export function extractShaderParameters(t){if(null==t)return[];const e=a.get(t).map(({name:e,options:r})=>{const o=Reflect.getMetadata("design:type",t.prototype,e),a=r.type??o,n=Reflect.getMetadata("prefab:type",t.prototype,e);return r.prefabOf??(r.prefabOf=n),r.array=o===Array,{name:e,type:a,options:r}});return[...extractShaderParameters(Object.getPrototypeOf(t)).filter(t=>e.every(e=>e.name!==t.name)),...e]}export function ParameterCategory(t){}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hology/core",
3
- "version": "0.0.179",
3
+ "version": "0.0.180",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",