@needle-tools/engine 3.31.0 → 3.31.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/CHANGELOG.md +3 -0
- package/dist/needle-engine.js +462 -456
- package/dist/needle-engine.light.js +829 -823
- package/dist/needle-engine.light.min.js +24 -24
- package/dist/needle-engine.light.umd.cjs +42 -42
- package/dist/needle-engine.min.js +25 -25
- package/dist/needle-engine.umd.cjs +42 -42
- package/lib/engine/engine_addressables.d.ts +3 -3
- package/lib/engine/engine_addressables.js +14 -16
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +17 -3
- package/lib/engine/engine_gameobject.js +20 -2
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.d.ts +2 -2
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine-components/Component.d.ts +3 -3
- package/lib/engine-components/Component.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_addressables.ts +20 -22
- package/src/engine/engine_gameobject.ts +38 -8
- package/src/engine/engine_networking_instantiate.ts +3 -3
- package/src/engine-components/Component.ts +3 -3
|
@@ -28,21 +28,50 @@ export enum HideFlags {
|
|
|
28
28
|
HideAndDontSave = DontSave | NotEditable | HideInHierarchy, // 0x0000003D
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
export type IInstantiateOptions = {
|
|
32
|
+
idProvider?: UIDProvider;
|
|
33
|
+
//** parent guid or object */
|
|
34
|
+
parent?: string | Object3D;
|
|
35
|
+
position?: Vector3;
|
|
36
|
+
/** for duplicatable parenting */
|
|
37
|
+
keepWorldPosition?: boolean;
|
|
38
|
+
rotation?: Quaternion;
|
|
39
|
+
scale?: Vector3;
|
|
40
|
+
/** if the instantiated object should be visible */
|
|
41
|
+
visible?: boolean;
|
|
42
|
+
context?: Context;
|
|
43
|
+
}
|
|
31
44
|
|
|
32
|
-
export class InstantiateOptions {
|
|
45
|
+
export class InstantiateOptions implements IInstantiateOptions {
|
|
33
46
|
idProvider?: UIDProvider | undefined;
|
|
34
|
-
|
|
35
|
-
//** parent guid */
|
|
36
47
|
parent?: string | undefined | Object3D;
|
|
37
|
-
/** for duplicatable parenting */
|
|
38
48
|
keepWorldPosition?: boolean
|
|
39
49
|
position?: Vector3 | undefined;
|
|
40
50
|
rotation?: Quaternion | undefined;
|
|
41
51
|
scale?: Vector3 | undefined;
|
|
42
|
-
|
|
43
52
|
visible?: boolean | undefined;
|
|
44
|
-
|
|
45
53
|
context?: Context | undefined;
|
|
54
|
+
|
|
55
|
+
clone(){
|
|
56
|
+
const clone = new InstantiateOptions();
|
|
57
|
+
clone.idProvider = this.idProvider;
|
|
58
|
+
clone.parent = this.parent;
|
|
59
|
+
clone.keepWorldPosition = this.keepWorldPosition;
|
|
60
|
+
clone.position = this.position?.clone();
|
|
61
|
+
clone.rotation = this.rotation?.clone();
|
|
62
|
+
clone.scale = this.scale?.clone();
|
|
63
|
+
return clone;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Copy fields from another object, clone field references */
|
|
67
|
+
cloneAssign(other: InstantiateOptions | IInstantiateOptions){
|
|
68
|
+
this.idProvider = other.idProvider;
|
|
69
|
+
this.parent = other.parent;
|
|
70
|
+
this.keepWorldPosition = other.keepWorldPosition;
|
|
71
|
+
this.position = other.position?.clone();
|
|
72
|
+
this.rotation = other.rotation?.clone();
|
|
73
|
+
this.scale = other.scale?.clone();
|
|
74
|
+
}
|
|
46
75
|
}
|
|
47
76
|
|
|
48
77
|
|
|
@@ -237,7 +266,7 @@ declare class NewGameObjectReferenceInfo {
|
|
|
237
266
|
clone: Object3D;
|
|
238
267
|
}
|
|
239
268
|
|
|
240
|
-
export function instantiate(instance: GameObject | Object3D | null, opts:
|
|
269
|
+
export function instantiate(instance: GameObject | Object3D | null, opts: IInstantiateOptions | null = null): GameObject | null {
|
|
241
270
|
if (instance === null) return null;
|
|
242
271
|
|
|
243
272
|
let options: InstantiateOptions | null = null;
|
|
@@ -256,6 +285,7 @@ export function instantiate(instance: GameObject | Object3D | null, opts: Instan
|
|
|
256
285
|
// }
|
|
257
286
|
}
|
|
258
287
|
}
|
|
288
|
+
console.log(options?.position)
|
|
259
289
|
|
|
260
290
|
let context = Context.Current;
|
|
261
291
|
if (options?.context) context = options.context;
|
|
@@ -311,7 +341,7 @@ export function instantiate(instance: GameObject | Object3D | null, opts: Instan
|
|
|
311
341
|
|
|
312
342
|
|
|
313
343
|
function internalInstantiate(
|
|
314
|
-
context: Context, instance: GameObject | Object3D, opts: InstantiateOptions | null,
|
|
344
|
+
context: Context, instance: GameObject | Object3D, opts: IInstantiateOptions | InstantiateOptions | null,
|
|
315
345
|
componentsList: Array<Component>,
|
|
316
346
|
newGameObjectsMap: { [key: string]: NewGameObjectReferenceInfo },
|
|
317
347
|
skinnedMeshesMap: { [key: string]: NewGameObjectReferenceInfo }
|
|
@@ -11,7 +11,7 @@ import { v5 } from 'uuid';
|
|
|
11
11
|
import type { UIDProvider } from "./engine_types.js";
|
|
12
12
|
import type { IModel } from "./engine_networking_types.js";
|
|
13
13
|
import { SendQueue } from "./engine_networking_types.js";
|
|
14
|
-
import { destroy, findByGuid, instantiate } from "./engine_gameobject.js";
|
|
14
|
+
import { IInstantiateOptions, destroy, findByGuid, instantiate } from "./engine_gameobject.js";
|
|
15
15
|
import { Object3D } from "three";
|
|
16
16
|
import { InstantiateOptions } from "./engine_gameobject.js";
|
|
17
17
|
import { ContextEvent, ContextRegistry } from "../engine/engine_context_registry.js";
|
|
@@ -182,7 +182,7 @@ class NewInstanceModel implements IModel {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
export function syncInstantiate(object: GameObject | Object3D, opts:
|
|
185
|
+
export function syncInstantiate(object: GameObject | Object3D, opts: IInstantiateOptions, hostData?: HostData, save?: boolean): GameObject | null {
|
|
186
186
|
|
|
187
187
|
const obj: GameObject = object as GameObject;
|
|
188
188
|
|
|
@@ -285,7 +285,7 @@ export function beginListenInstantiate(context: Context) {
|
|
|
285
285
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
function instantiateSeeded(obj: GameObject, opts:
|
|
288
|
+
function instantiateSeeded(obj: GameObject, opts: IInstantiateOptions | null): { instance: GameObject | null, seed: number } {
|
|
289
289
|
const seed = generateSeed();
|
|
290
290
|
const options = opts ?? new InstantiateOptions();
|
|
291
291
|
options.idProvider = new InstantiateIdProvider(seed);
|
|
@@ -6,7 +6,7 @@ import * as main from "../engine/engine_mainloop_utils.js";
|
|
|
6
6
|
import { syncDestroy, syncInstantiate } from "../engine/engine_networking_instantiate.js";
|
|
7
7
|
import type { ConstructorConcrete, SourceIdentifier, IComponent, IGameObject, Constructor, GuidsMap, Collision, ICollider } from "../engine/engine_types.js";
|
|
8
8
|
import { addNewComponent, destroyComponentInstance, findObjectOfType, findObjectsOfType, getComponent, getComponentInChildren, getComponentInParent, getComponents, getComponentsInChildren, getComponentsInParent, getOrAddComponent, moveComponentInstance, removeComponent } from "../engine/engine_components.js";
|
|
9
|
-
import { findByGuid, destroy, InstantiateOptions, instantiate, HideFlags, foreachComponent, markAsInstancedRendered, isActiveInHierarchy, isActiveSelf, isUsingInstancing, setActive, isDestroyed } from "../engine/engine_gameobject.js";
|
|
9
|
+
import { findByGuid, destroy, InstantiateOptions, instantiate, HideFlags, foreachComponent, markAsInstancedRendered, isActiveInHierarchy, isActiveSelf, isUsingInstancing, setActive, isDestroyed, IInstantiateOptions } from "../engine/engine_gameobject.js";
|
|
10
10
|
|
|
11
11
|
import { Euler, Object3D, Quaternion, Scene, Vector3 } from "three";
|
|
12
12
|
import { showBalloonWarning, isDevEnvironment } from "../engine/debug/index.js";
|
|
@@ -72,7 +72,7 @@ export abstract class GameObject extends Object3D implements Object3D, IGameObje
|
|
|
72
72
|
* @param instance object to instantiate
|
|
73
73
|
* @param opts options for the instantiation
|
|
74
74
|
*/
|
|
75
|
-
public static instantiateSynced(instance: GameObject | Object3D | null, opts:
|
|
75
|
+
public static instantiateSynced(instance: GameObject | Object3D | null, opts: IInstantiateOptions): GameObject | null {
|
|
76
76
|
if (!instance) return null;
|
|
77
77
|
return syncInstantiate(instance as any, opts) as GameObject | null;
|
|
78
78
|
}
|
|
@@ -81,7 +81,7 @@ export abstract class GameObject extends Object3D implements Object3D, IGameObje
|
|
|
81
81
|
* @param instance object to instantiate
|
|
82
82
|
* @param opts options for the instantiation (e.g. with what parent, position, etc.)
|
|
83
83
|
*/
|
|
84
|
-
public static instantiate(instance: GameObject | Object3D | null, opts:
|
|
84
|
+
public static instantiate(instance: GameObject | Object3D | null, opts: IInstantiateOptions | null = null): GameObject | null {
|
|
85
85
|
return instantiate(instance, opts) as GameObject | null;
|
|
86
86
|
}
|
|
87
87
|
|