@needle-tools/engine 2.66.1-pre → 2.67.0-pre
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 +20 -0
- package/dist/needle-engine.js +34306 -26230
- package/dist/needle-engine.umd.cjs +743 -298
- package/lib/engine/api.d.ts +4 -0
- package/lib/engine/api.js +10 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +23 -7
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/debug/debug_overlay.js +7 -1
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/engine_addressables.js +2 -2
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_assetdatabase.d.ts +17 -51
- package/lib/engine/engine_assetdatabase.js +252 -126
- package/lib/engine/engine_assetdatabase.js.map +1 -1
- package/lib/engine/engine_components.js +13 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_components_internal.d.ts +8 -0
- package/lib/engine/engine_components_internal.js +29 -0
- package/lib/engine/engine_components_internal.js.map +1 -0
- package/lib/engine/engine_constants.d.ts +1 -0
- package/lib/engine/engine_constants.js +1 -0
- package/lib/engine/engine_constants.js.map +1 -1
- package/lib/engine/engine_context_registry.d.ts +2 -0
- package/lib/engine/engine_context_registry.js +6 -0
- package/lib/engine/engine_context_registry.js.map +1 -1
- package/lib/engine/engine_editor-sync.d.ts +9 -0
- package/lib/engine/engine_editor-sync.js +8 -0
- package/lib/engine/engine_editor-sync.js.map +1 -0
- package/lib/engine/engine_element_loading.js +1 -1
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_gameobject.js +15 -20
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.d.ts +2 -3
- package/lib/engine/engine_gltf_builtin_components.js +23 -6
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_networking_auto.d.ts +1 -0
- package/lib/engine/engine_networking_auto.js +42 -9
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_patcher.d.ts +8 -0
- package/lib/engine/engine_patcher.js +98 -0
- package/lib/engine/engine_patcher.js.map +1 -0
- package/lib/engine/engine_physics.d.ts +5 -1
- package/lib/engine/engine_physics.js +11 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_scenetools.js +0 -1
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_serialization_core.js +4 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_setup.d.ts +1 -1
- package/lib/engine/engine_setup.js +9 -5
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_texture.d.ts +6 -1
- package/lib/engine/engine_texture.js +39 -1
- package/lib/engine/engine_texture.js.map +1 -1
- package/lib/engine/engine_types.d.ts +4 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_utils.js +3 -2
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +0 -1
- package/lib/engine/extensions/NEEDLE_progressive.js +24 -26
- package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
- package/lib/engine/extensions/extensions.d.ts +4 -1
- package/lib/engine/extensions/extensions.js +16 -0
- package/lib/engine/extensions/extensions.js.map +1 -1
- package/lib/engine/extensions/usage_tracker.d.ts +12 -0
- package/lib/engine/extensions/usage_tracker.js +59 -0
- package/lib/engine/extensions/usage_tracker.js.map +1 -0
- package/lib/engine-components/AnimatorController.js +4 -0
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioSource.js +2 -1
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +6 -0
- package/lib/engine-components/Camera.js +70 -31
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/Component.d.ts +52 -0
- package/lib/engine-components/Component.js +55 -14
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/Networking.js +19 -0
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +2 -0
- package/lib/engine-components/OrbitControls.js +9 -0
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ParticleSystem.js +11 -1
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js +18 -6
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +1 -1
- package/lib/engine-components/Renderer.js +24 -6
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/Skybox.js +2 -0
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/SmoothFollow.js +1 -2
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/WebARCameraBackground.d.ts +19 -0
- package/lib/engine-components/WebARCameraBackground.js +185 -0
- package/lib/engine-components/WebARCameraBackground.js.map +1 -0
- package/lib/engine-components/WebXR.d.ts +4 -0
- package/lib/engine-components/WebXR.js +11 -8
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.js +1 -0
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +14 -6
- package/lib/engine-components/codegen/components.js +14 -6
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/js-extensions/Object3D.js +4 -1
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +13 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +46 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.d.ts +12 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.js +76 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +8 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +39 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +12 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +96 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +21 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js +87 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +7 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.js +30 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +11 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +70 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +16 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +52 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +11 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.js +57 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +29 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js +89 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +13 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +119 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -0
- package/lib/engine-components/postprocessing/Volume.d.ts +23 -0
- package/lib/engine-components/postprocessing/Volume.js +176 -0
- package/lib/engine-components/postprocessing/Volume.js.map +1 -0
- package/lib/engine-components/postprocessing/VolumeParameter.d.ts +21 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js +75 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -0
- package/lib/engine-components/postprocessing/VolumeProfile.d.ts +7 -0
- package/lib/engine-components/postprocessing/VolumeProfile.js +42 -0
- package/lib/engine-components/postprocessing/VolumeProfile.js.map +1 -0
- package/lib/engine-components/timeline/TimelineTracks.js +14 -15
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/ui/Text.js +28 -170
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +18 -0
- package/lib/engine-components-experimental/networking/PlayerSync.js +61 -7
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/lib/include/three/ARButton.d.ts +1 -1
- package/lib/include/three/ARButton.js +11 -19
- package/lib/include/three/ARButton.js.map +1 -1
- package/lib/include/three/VRButton.js +1 -4
- package/lib/include/three/VRButton.js.map +1 -1
- package/package.json +3 -2
- package/plugins/vite/drop-client.js +77 -0
- package/plugins/vite/drop.js +81 -0
- package/plugins/vite/editor-connection.js +121 -0
- package/plugins/vite/index.js +9 -4
- package/src/engine/api.ts +30 -1
- package/src/engine/codegen/register_types.js +25 -9
- package/src/engine/debug/debug_overlay.ts +7 -1
- package/src/engine/engine_addressables.ts +2 -2
- package/src/engine/engine_assetdatabase.ts +291 -184
- package/src/engine/engine_components.ts +20 -1
- package/src/engine/engine_components_internal.ts +30 -0
- package/src/engine/engine_constants.ts +4 -1
- package/src/engine/engine_context_registry.ts +7 -0
- package/src/engine/engine_editor-sync.ts +21 -0
- package/src/engine/engine_element_loading.ts +1 -1
- package/src/engine/engine_gameobject.ts +16 -21
- package/src/engine/engine_gltf_builtin_components.ts +30 -15
- package/src/engine/engine_networking_auto.ts +48 -11
- package/src/engine/engine_patcher.ts +113 -0
- package/src/engine/engine_physics.ts +15 -2
- package/src/engine/engine_scenetools.ts +0 -1
- package/src/engine/engine_serialization_core.ts +6 -0
- package/src/engine/engine_setup.ts +11 -5
- package/src/engine/engine_texture.ts +54 -5
- package/src/engine/engine_types.ts +6 -1
- package/src/engine/engine_utils.ts +6 -5
- package/src/engine/extensions/NEEDLE_progressive.ts +32 -32
- package/src/engine/extensions/extensions.ts +22 -1
- package/src/engine/extensions/usage_tracker.ts +91 -0
- package/src/engine-components/AnimatorController.ts +2 -0
- package/src/engine-components/AudioSource.ts +1 -1
- package/src/engine-components/Camera.ts +77 -37
- package/src/engine-components/Component.ts +74 -30
- package/src/engine-components/Networking.ts +9 -1
- package/src/engine-components/OrbitControls.ts +11 -2
- package/src/engine-components/ParticleSystem.ts +9 -1
- package/src/engine-components/ReflectionProbe.ts +17 -7
- package/src/engine-components/Renderer.ts +22 -5
- package/src/engine-components/Skybox.ts +2 -0
- package/src/engine-components/SmoothFollow.ts +4 -4
- package/src/engine-components/WebARCameraBackground.ts +215 -0
- package/src/engine-components/WebXR.ts +12 -8
- package/src/engine-components/WebXRAvatar.ts +1 -0
- package/src/engine-components/codegen/components.ts +14 -6
- package/src/engine-components/js-extensions/Object3D.ts +6 -1
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +52 -0
- package/src/engine-components/postprocessing/Effects/Bloom.ts +75 -0
- package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +36 -0
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +114 -0
- package/src/engine-components/postprocessing/Effects/DepthOfField.ts +90 -0
- package/src/engine-components/postprocessing/Effects/Pixelation.ts +28 -0
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +71 -0
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +55 -0
- package/src/engine-components/postprocessing/Effects/Vignette.ts +55 -0
- package/src/engine-components/postprocessing/PostProcessingEffect.ts +112 -0
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +148 -0
- package/src/engine-components/postprocessing/Volume.ts +194 -0
- package/src/engine-components/postprocessing/VolumeParameter.ts +85 -0
- package/src/engine-components/postprocessing/VolumeProfile.ts +40 -0
- package/src/engine-components/timeline/TimelineTracks.ts +16 -17
- package/src/engine-components/ui/Text.ts +37 -174
- package/src/engine-components-experimental/networking/PlayerSync.ts +68 -7
- package/src/include/three/ARButton.js +13 -24
- package/src/include/three/VRButton.js +1 -7
- package/lib/engine-components/Volume.d.ts +0 -34
- package/lib/engine-components/Volume.js +0 -140
- package/lib/engine-components/Volume.js.map +0 -1
- package/src/engine-components/Volume.ts +0 -141
|
@@ -23,6 +23,9 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
23
23
|
|
|
24
24
|
guid: string | undefined;
|
|
25
25
|
|
|
26
|
+
// Added to the threejs Object3D prototype
|
|
27
|
+
abstract destroy();
|
|
28
|
+
|
|
26
29
|
// The actual implementation / prototype of threejs is modified in js-extensions/Object3D
|
|
27
30
|
abstract get transform(): THREE.Object3D;
|
|
28
31
|
|
|
@@ -33,15 +36,21 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
33
36
|
public static setActive(go: THREE.Object3D, active: boolean, processStart: boolean = true) {
|
|
34
37
|
if (!go) return;
|
|
35
38
|
setActive(go, active);
|
|
39
|
+
|
|
40
|
+
// TODO: do we still need this?:
|
|
36
41
|
main.updateIsActive(go);
|
|
37
42
|
if (active && processStart)
|
|
38
43
|
main.processStart(Context.Current, go);
|
|
39
44
|
}
|
|
40
45
|
|
|
46
|
+
/** If the object is active (same as go.visible) */
|
|
41
47
|
public static isActiveSelf(go: THREE.Object3D): boolean {
|
|
42
48
|
return isActiveSelf(go);
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
/** If the object is active in the hierarchy (e.g. if any parent is invisible or not in the scene it will be false)
|
|
52
|
+
* @param go object to check
|
|
53
|
+
*/
|
|
45
54
|
public static isActiveInHierarchy(go: THREE.Object3D): boolean {
|
|
46
55
|
return isActiveInHierarchy(go);
|
|
47
56
|
}
|
|
@@ -52,19 +61,35 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
52
61
|
|
|
53
62
|
public static isUsingInstancing(instance: THREE.Object3D): boolean { return isUsingInstancing(instance); }
|
|
54
63
|
|
|
64
|
+
/** Run a callback for all components of the provided type on the provided object and its children (if recursive is true)
|
|
65
|
+
* @param instance object to run the method on
|
|
66
|
+
* @param cb callback to run on each component
|
|
67
|
+
* @param recursive if true, the method will be run on all children as well
|
|
68
|
+
*/
|
|
55
69
|
public static foreachComponent(instance: THREE.Object3D, cb: (comp: Component) => any, recursive: boolean = true): any {
|
|
56
70
|
return foreachComponent(instance, cb as (comp: IComponent) => any, recursive);
|
|
57
71
|
}
|
|
58
72
|
|
|
73
|
+
/** Creates a new instance of the provided object. The new instance will be created on all connected clients
|
|
74
|
+
* @param instance object to instantiate
|
|
75
|
+
* @param opts options for the instantiation
|
|
76
|
+
*/
|
|
59
77
|
public static instantiateSynced(instance: GameObject | Object3D | null, opts: InstantiateOptions): GameObject | null {
|
|
60
78
|
if (!instance) return null;
|
|
61
79
|
return syncInstantiate(instance as any, opts) as GameObject | null;
|
|
62
80
|
}
|
|
63
81
|
|
|
82
|
+
/** Creates a new instance of the provided object (like cloning it including all components and children)
|
|
83
|
+
* @param instance object to instantiate
|
|
84
|
+
* @param opts options for the instantiation (e.g. with what parent, position, etc.)
|
|
85
|
+
*/
|
|
64
86
|
public static instantiate(instance: GameObject | Object3D | null, opts: InstantiateOptions | null = null): GameObject | null {
|
|
65
87
|
return instantiate(instance, opts) as GameObject | null;
|
|
66
88
|
}
|
|
67
89
|
|
|
90
|
+
/** Destroys a object on all connected clients (if you are in a networked session)
|
|
91
|
+
* @param instance object to destroy
|
|
92
|
+
*/
|
|
68
93
|
public static destroySynced(instance: THREE.Object3D | Component, context?: Context, recursive: boolean = true) {
|
|
69
94
|
if (!instance) return;
|
|
70
95
|
const go = instance as GameObject;
|
|
@@ -72,6 +97,10 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
72
97
|
syncDestroy(go as any, context.connection, recursive);
|
|
73
98
|
}
|
|
74
99
|
|
|
100
|
+
/** Destroys a object
|
|
101
|
+
* @param instance object to destroy
|
|
102
|
+
* @param recursive if true, all children will be destroyed as well
|
|
103
|
+
*/
|
|
75
104
|
public static destroy(instance: THREE.Object3D | Component, recursive: boolean = true, isRoot: boolean = true) {
|
|
76
105
|
return destroy(instance, recursive, isRoot);
|
|
77
106
|
}
|
|
@@ -94,7 +123,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
94
123
|
if (context) {
|
|
95
124
|
GameObject.foreachComponent(instance, (comp: Component) => {
|
|
96
125
|
main.addScriptToArrays(comp, context!);
|
|
97
|
-
if(comp.__internalDidAwakeAndStart) return;
|
|
126
|
+
if (comp.__internalDidAwakeAndStart) return;
|
|
98
127
|
if (context!.new_script_start.includes(comp) === false) {
|
|
99
128
|
context!.new_script_start.push(comp as Behaviour);
|
|
100
129
|
}
|
|
@@ -118,24 +147,31 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
118
147
|
}, true);
|
|
119
148
|
}
|
|
120
149
|
|
|
150
|
+
/** Invokes a method on all components including children (if a method with that name exists) */
|
|
121
151
|
public static invokeOnChildren(go: THREE.Object3D | null | undefined, functionName: string, ...args: any) {
|
|
122
152
|
this.invoke(go, functionName, true, args);
|
|
123
153
|
}
|
|
124
154
|
|
|
155
|
+
/** Invokes a method on all components that have a method matching the provided name
|
|
156
|
+
* @param go object to invoke the method on all components
|
|
157
|
+
* @param functionName name of the method to invoke
|
|
158
|
+
*/
|
|
125
159
|
public static invoke(go: THREE.Object3D | null | undefined, functionName: string, children: boolean = false, ...args: any) {
|
|
126
160
|
if (!go) return;
|
|
127
|
-
|
|
128
|
-
// console.log(go);
|
|
129
161
|
this.foreachComponent(go, c => {
|
|
130
162
|
const fn = c[functionName];
|
|
131
163
|
if (fn && typeof fn === "function") {
|
|
132
|
-
|
|
133
|
-
// console.log(c, bound)
|
|
134
|
-
bound(...args)
|
|
164
|
+
fn?.call(c, ...args)
|
|
135
165
|
}
|
|
136
166
|
}, children);
|
|
137
167
|
}
|
|
138
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Adds a new component to the provided object
|
|
171
|
+
* @param go object to add the component to
|
|
172
|
+
* @param type type of the component to add
|
|
173
|
+
* @param callAwake if true, the component will be added and awake will be called immediately
|
|
174
|
+
*/
|
|
139
175
|
public static addNewComponent<T>(go: GameObject | THREE.Object3D, type: ConstructorConcrete<T>, callAwake: boolean = true): T {
|
|
140
176
|
const instance = new type();
|
|
141
177
|
//@ts-ignore
|
|
@@ -143,13 +179,31 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
143
179
|
return instance
|
|
144
180
|
}
|
|
145
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Moves a component to a new object
|
|
184
|
+
* BEWARE: this does MOVE a component. If you want to add a new component use `addNewComponent`
|
|
185
|
+
* @param go component to move the component to
|
|
186
|
+
* @param instance component to move to the GO
|
|
187
|
+
*/
|
|
146
188
|
public static addComponent(go: GameObject, instance: Component): void {
|
|
189
|
+
return this.moveComponent(go, instance);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Moves a component to a new object
|
|
194
|
+
* @param go component to move the component to
|
|
195
|
+
* @param instance component to move to the GO
|
|
196
|
+
*/
|
|
197
|
+
public static moveComponent(go: GameObject, instance: Component): void {
|
|
147
198
|
if (instance.gameObject == null) {
|
|
148
199
|
throw new Error("Did you mean to create a new component? Use addNewComponent");
|
|
149
200
|
}
|
|
150
201
|
moveComponentInstance(go, instance as any);
|
|
151
202
|
}
|
|
152
203
|
|
|
204
|
+
/** Removes a component from its object
|
|
205
|
+
* @param instance component to remove
|
|
206
|
+
*/
|
|
153
207
|
public static removeComponent(instance: Component): Component {
|
|
154
208
|
removeComponent(instance.gameObject, instance as any);
|
|
155
209
|
return instance;
|
|
@@ -159,6 +213,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
159
213
|
return getOrAddComponent<any>(go, typeName);
|
|
160
214
|
}
|
|
161
215
|
|
|
216
|
+
/** Gets a component on the provided object */
|
|
162
217
|
public static getComponent<T>(go: GameObject | THREE.Object3D | null, typeName: Constructor<T> | null): T | null {
|
|
163
218
|
if (go === null) return null;
|
|
164
219
|
// if names are minified we could also use the type store and work with strings everywhere
|
|
@@ -339,7 +394,7 @@ class Component implements IComponent, EventTarget {
|
|
|
339
394
|
onCollisionEnter?(col: Collision);
|
|
340
395
|
onCollisionExit?(col: Collision);
|
|
341
396
|
onCollisionStay?(col: Collision);
|
|
342
|
-
|
|
397
|
+
|
|
343
398
|
onTriggerEnter?(col: ICollider);
|
|
344
399
|
onTriggerStay?(col: ICollider);
|
|
345
400
|
onTriggerExit?(col: ICollider);
|
|
@@ -361,34 +416,33 @@ class Component implements IComponent, EventTarget {
|
|
|
361
416
|
this.__internalDestroy();
|
|
362
417
|
}
|
|
363
418
|
|
|
364
|
-
|
|
365
|
-
|
|
419
|
+
|
|
420
|
+
|
|
366
421
|
/** @internal */
|
|
367
422
|
protected __didAwake: boolean = false;
|
|
368
|
-
|
|
423
|
+
|
|
369
424
|
/** @internal */
|
|
370
425
|
private __didStart: boolean = false;
|
|
371
|
-
|
|
426
|
+
|
|
372
427
|
/** @internal */
|
|
373
428
|
protected __didEnable: boolean = false;
|
|
374
|
-
|
|
429
|
+
|
|
375
430
|
/** @internal */
|
|
376
431
|
protected __isEnabled: boolean | undefined = undefined;
|
|
377
|
-
|
|
432
|
+
|
|
378
433
|
/** @internal */
|
|
379
434
|
private __destroyed: boolean = false;
|
|
380
|
-
|
|
435
|
+
|
|
381
436
|
/** @internal */
|
|
382
437
|
get __internalDidAwakeAndStart() { return this.__didAwake && this.__didStart; }
|
|
383
438
|
|
|
384
|
-
|
|
439
|
+
|
|
385
440
|
/** @internal */
|
|
386
441
|
constructor() {
|
|
387
|
-
// super();
|
|
388
442
|
this.__internalNewInstanceCreated();
|
|
389
443
|
}
|
|
390
444
|
|
|
391
|
-
|
|
445
|
+
|
|
392
446
|
/** @internal */
|
|
393
447
|
__internalNewInstanceCreated() {
|
|
394
448
|
this.__didAwake = false;
|
|
@@ -396,21 +450,17 @@ class Component implements IComponent, EventTarget {
|
|
|
396
450
|
this.__didEnable = false;
|
|
397
451
|
this.__isEnabled = undefined;
|
|
398
452
|
this.__destroyed = false;
|
|
399
|
-
// this.__internalResetsCachedPhysicsData();
|
|
400
453
|
}
|
|
401
454
|
|
|
402
|
-
|
|
455
|
+
|
|
403
456
|
/** @internal */
|
|
404
457
|
__internalAwake() {
|
|
405
458
|
if (this.__didAwake) return;
|
|
406
|
-
// console.log("__internalAwake");
|
|
407
459
|
this.__didAwake = true;
|
|
408
|
-
// this.gameObject.test();
|
|
409
|
-
|
|
410
460
|
this.awake();
|
|
411
461
|
}
|
|
412
462
|
|
|
413
|
-
|
|
463
|
+
|
|
414
464
|
/** @internal */
|
|
415
465
|
__internalStart() {
|
|
416
466
|
if (this.__didStart) return;
|
|
@@ -418,14 +468,13 @@ class Component implements IComponent, EventTarget {
|
|
|
418
468
|
if (this.start) this.start();
|
|
419
469
|
}
|
|
420
470
|
|
|
421
|
-
|
|
471
|
+
|
|
422
472
|
/** @internal */
|
|
423
473
|
__internalEnable(): boolean {
|
|
424
474
|
if (this.__didEnable) return false;
|
|
425
475
|
// console.trace("INTERNAL ENABLE");
|
|
426
476
|
this.__didEnable = true;
|
|
427
477
|
this.onEnable();
|
|
428
|
-
// if we do this after processing the callback
|
|
429
478
|
this.__isEnabled = true;
|
|
430
479
|
return true;
|
|
431
480
|
}
|
|
@@ -434,10 +483,7 @@ class Component implements IComponent, EventTarget {
|
|
|
434
483
|
__internalDisable() {
|
|
435
484
|
if (!this.__didEnable) return;
|
|
436
485
|
this.__didEnable = false;
|
|
437
|
-
// this._collisionExitRoutine = undefined;
|
|
438
486
|
this.onDisable();
|
|
439
|
-
// this._collisions?.clear();
|
|
440
|
-
// if we do this after processing the callback
|
|
441
487
|
this.__isEnabled = false;
|
|
442
488
|
}
|
|
443
489
|
|
|
@@ -446,11 +492,9 @@ class Component implements IComponent, EventTarget {
|
|
|
446
492
|
if (this.__destroyed) return;
|
|
447
493
|
this.__destroyed = true;
|
|
448
494
|
this.destroy?.call(this);
|
|
449
|
-
// console.log("destroy", this);
|
|
450
495
|
destroyComponentInstance(this as any);
|
|
451
496
|
}
|
|
452
497
|
|
|
453
|
-
// isActiveAndEnabled: boolean = false;
|
|
454
498
|
|
|
455
499
|
get enabled(): boolean {
|
|
456
500
|
return this.__isEnabled ?? true; // if it has no enabled field it is always enabled
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
+
import { serializable } from "../engine/engine_serialization";
|
|
1
2
|
import { INetworkingWebsocketUrlProvider } from "../engine/engine_networking";
|
|
2
3
|
import { isLocalNetwork } from "../engine/engine_networking_utils";
|
|
3
4
|
import { getParam } from "../engine/engine_utils";
|
|
4
5
|
import { Behaviour } from "./Component";
|
|
5
6
|
|
|
7
|
+
const debug = getParam("debugnet");
|
|
8
|
+
|
|
6
9
|
export class Networking extends Behaviour implements INetworkingWebsocketUrlProvider {
|
|
7
10
|
|
|
11
|
+
@serializable()
|
|
8
12
|
url: string | null = null;
|
|
13
|
+
@serializable()
|
|
9
14
|
urlParameterName: string | null = null;
|
|
10
15
|
|
|
11
16
|
// used when local host is detected
|
|
17
|
+
@serializable()
|
|
12
18
|
localhost: string | null = null;
|
|
13
19
|
|
|
14
|
-
awake(){
|
|
20
|
+
awake() {
|
|
21
|
+
if (debug)
|
|
22
|
+
console.log(this);
|
|
15
23
|
this.context.connection.registerProvider(this);
|
|
16
24
|
}
|
|
17
25
|
|
|
@@ -11,6 +11,7 @@ import { OrbitControls as ThreeOrbitControls } from "three/examples/jsm/controls
|
|
|
11
11
|
import { EventSystem, EventSystemEvents } from "./ui/EventSystem";
|
|
12
12
|
import { ICameraController } from "../engine/engine_types";
|
|
13
13
|
import { setCameraController } from "../engine/engine_camera";
|
|
14
|
+
import { SyncedTransform } from "./SyncedTransform";
|
|
14
15
|
|
|
15
16
|
const freeCam = getParam("freecam");
|
|
16
17
|
|
|
@@ -70,7 +71,8 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
70
71
|
|
|
71
72
|
private _eventSystem?: EventSystem;
|
|
72
73
|
private _afterHandleInputFn?: any;
|
|
73
|
-
private _camera
|
|
74
|
+
private _camera: Camera | null = null;
|
|
75
|
+
private _syncedTransform?: SyncedTransform;
|
|
74
76
|
|
|
75
77
|
targetElement: HTMLElement | null = null;
|
|
76
78
|
|
|
@@ -133,6 +135,7 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
133
135
|
this._controls.autoRotate = this.autoRotate;
|
|
134
136
|
this._controls.autoRotateSpeed = this.autoRotateSpeed;
|
|
135
137
|
this._controls.enableZoom = this.enableZoom;
|
|
138
|
+
this._controls.addEventListener("start", this.onControlsChangeStarted.bind(this));
|
|
136
139
|
if (cam?.type === "PerspectiveCamera") {
|
|
137
140
|
if (freeCam) {
|
|
138
141
|
// dont set limits
|
|
@@ -158,7 +161,7 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
158
161
|
this._controls.listenToKeyEvents(window.document.body);
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
|
-
|
|
164
|
+
this._syncedTransform = GameObject.getComponent(this.gameObject, SyncedTransform) ?? undefined;
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
onDisable() {
|
|
@@ -172,6 +175,12 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
177
|
|
|
178
|
+
private onControlsChangeStarted() {
|
|
179
|
+
if(this._syncedTransform) {
|
|
180
|
+
this._syncedTransform.requestOwnership();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
175
184
|
private _shouldDisable: boolean = false;
|
|
176
185
|
private afterHandleInput() {
|
|
177
186
|
if (this._controls && this._eventSystem) {
|
|
@@ -17,7 +17,8 @@ import { Mathf } from "../engine/engine_math";
|
|
|
17
17
|
import { Context } from "../engine/engine_setup";
|
|
18
18
|
import { ParticleSubEmitter } from "./ParticleSystemSubEmitter";
|
|
19
19
|
import { NEEDLE_progressive } from "../engine/extensions/NEEDLE_progressive";
|
|
20
|
-
import { Gizmos
|
|
20
|
+
import { Gizmos } from "../engine/engine_gizmos";
|
|
21
|
+
import { isDevEnvironment } from "../engine/debug";
|
|
21
22
|
|
|
22
23
|
const debug = getParam("debugparticles");
|
|
23
24
|
const suppressProgressiveLoading = getParam("noprogressive");
|
|
@@ -857,16 +858,23 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
857
858
|
}
|
|
858
859
|
|
|
859
860
|
private preWarm() {
|
|
861
|
+
if (!this.emission?.enabled) return;
|
|
862
|
+
const emission = this.emission.rateOverTime.getMax();
|
|
863
|
+
if (emission <= 0) return;
|
|
860
864
|
const dt = 1 / 60;
|
|
861
865
|
const duration = this.main.duration;
|
|
862
866
|
const lifetime = this.main.startLifetime.getMax();
|
|
863
867
|
const maxDurationToPrewarm = 1000;
|
|
864
868
|
const timeToSimulate = Math.min(duration, lifetime, maxDurationToPrewarm);
|
|
865
869
|
const framesToSimulate = Math.ceil(timeToSimulate / dt);
|
|
870
|
+
const startTime = Date.now();
|
|
866
871
|
if (debug)
|
|
867
872
|
console.log(`Particles ${this.name} - Prewarm for ${framesToSimulate} frames (${timeToSimulate} sec). Duration: ${duration}, Lifetime: ${lifetime}`);
|
|
868
873
|
for (let i = 0; i < framesToSimulate; i++) {
|
|
869
874
|
if (this.currentParticles >= this.maxParticles) break;
|
|
875
|
+
if (Date.now() - startTime > 2) {
|
|
876
|
+
console.warn(`Particles ${this.name} - Prewarm took too long. Aborting.`);
|
|
877
|
+
}
|
|
870
878
|
this.onUpdate();
|
|
871
879
|
this.onSimulate(dt);
|
|
872
880
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Behaviour } from "./Component";
|
|
2
|
-
import { Box3, Color, EquirectangularReflectionMapping, LineBasicMaterial, Material, MeshStandardMaterial, Object3D, sRGBEncoding, Texture, Vector3, WebGLCubeRenderTarget, WebGLRenderTarget } from "three";
|
|
2
|
+
import { Box3, Color, EquirectangularReflectionMapping, LinearEncoding, LineBasicMaterial, Material, MeshStandardMaterial, Object3D, SrcAlphaFactor, sRGBEncoding, Texture, Vector3, WebGLCubeRenderTarget, WebGLRenderTarget } from "three";
|
|
3
3
|
import { serializable } from "../engine/engine_serialization";
|
|
4
4
|
import { Context } from "../engine/engine_setup";
|
|
5
5
|
import { getWorldPosition, getWorldScale } from "../engine/engine_three_utils";
|
|
@@ -47,7 +47,16 @@ export class ReflectionProbe extends Behaviour {
|
|
|
47
47
|
|
|
48
48
|
private _texture!: Texture;
|
|
49
49
|
set texture(tex: Texture) {
|
|
50
|
+
if (tex && !(tex instanceof Texture)) {
|
|
51
|
+
console.error("ReflectionProbe.texture must be a Texture", tex);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
50
54
|
this._texture = tex;
|
|
55
|
+
if (tex) {
|
|
56
|
+
tex.mapping = EquirectangularReflectionMapping;
|
|
57
|
+
tex.encoding = sRGBEncoding;
|
|
58
|
+
tex.needsUpdate = true;
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
61
|
get texture(): Texture {
|
|
53
62
|
return this._texture;
|
|
@@ -81,8 +90,6 @@ export class ReflectionProbe extends Behaviour {
|
|
|
81
90
|
if (this.texture) {
|
|
82
91
|
this.texture.mapping = EquirectangularReflectionMapping;
|
|
83
92
|
this.texture.encoding = sRGBEncoding;
|
|
84
|
-
// this.texture.rotation = Math.PI;
|
|
85
|
-
// this.texture.flipY = true;
|
|
86
93
|
this.texture.needsUpdate = true;
|
|
87
94
|
}
|
|
88
95
|
}
|
|
@@ -106,6 +113,7 @@ export class ReflectionProbe extends Behaviour {
|
|
|
106
113
|
|
|
107
114
|
onSet(_rend: IRenderer) {
|
|
108
115
|
if (disable) return;
|
|
116
|
+
if (!this.enabled) return;
|
|
109
117
|
if (_rend.sharedMaterials?.length <= 0) return;
|
|
110
118
|
if (!this.texture) return;
|
|
111
119
|
|
|
@@ -129,8 +137,10 @@ export class ReflectionProbe extends Behaviour {
|
|
|
129
137
|
let cached = rendererCache[i];
|
|
130
138
|
|
|
131
139
|
// make sure we have the currently assigned material cached (and an up to date clone of that)
|
|
132
|
-
if (!cached || cached.material !== material || cached.
|
|
140
|
+
if (!cached || cached.material !== material || cached.copy.version !== material.version) {
|
|
141
|
+
if(debug) console.log("Cloning material", material.name, material.version);
|
|
133
142
|
const clone = material.clone();
|
|
143
|
+
clone.version = material.version;
|
|
134
144
|
|
|
135
145
|
if (cached) {
|
|
136
146
|
cached.copy = clone;
|
|
@@ -147,9 +157,6 @@ export class ReflectionProbe extends Behaviour {
|
|
|
147
157
|
clone[$reflectionProbeKey] = this;
|
|
148
158
|
clone[$originalMaterial] = material;
|
|
149
159
|
|
|
150
|
-
// make sure the reflection probe is assigned
|
|
151
|
-
clone["envMap"] = this.texture;
|
|
152
|
-
|
|
153
160
|
if (debug)
|
|
154
161
|
console.log("Set reflection", _rend.name, _rend.guid);
|
|
155
162
|
}
|
|
@@ -157,6 +164,9 @@ export class ReflectionProbe extends Behaviour {
|
|
|
157
164
|
/** this is the material that we copied and that has the reflection probe */
|
|
158
165
|
const copy = cached?.copy;
|
|
159
166
|
|
|
167
|
+
// make sure the reflection probe is assigned
|
|
168
|
+
copy["envMap"] = this.texture;
|
|
169
|
+
|
|
160
170
|
_rend.sharedMaterials[i] = copy;
|
|
161
171
|
}
|
|
162
172
|
}
|
|
@@ -245,18 +245,37 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
private _sharedMaterials!: SharedMaterialArray;
|
|
248
|
-
private _originalMaterials
|
|
248
|
+
private _originalMaterials?: Material[];
|
|
249
249
|
|
|
250
250
|
// this is just available during deserialization
|
|
251
251
|
private set sharedMaterials(_val: Array<Material | null>) {
|
|
252
252
|
// TODO: elements in the array might be missing at the moment which leads to problems if an index is serialized
|
|
253
|
-
this._originalMaterials
|
|
253
|
+
if (!this._originalMaterials) {
|
|
254
|
+
this._originalMaterials = _val as Material[];
|
|
255
|
+
}
|
|
256
|
+
else if (_val) {
|
|
257
|
+
let didWarn = false;
|
|
258
|
+
for (let i = 0; i < this._sharedMaterials.length; i++) {
|
|
259
|
+
const mat = i < _val.length ? _val[i] : null;
|
|
260
|
+
if (mat && mat instanceof Material) {
|
|
261
|
+
this.sharedMaterials[i] = mat as Material;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
if (!didWarn) {
|
|
265
|
+
didWarn = true;
|
|
266
|
+
console.warn("Can not assign null as material: " + this.name, mat);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
254
271
|
}
|
|
255
272
|
|
|
256
273
|
//@ts-ignore
|
|
257
274
|
get sharedMaterials(): SharedMaterialArray {
|
|
258
|
-
if (!this._sharedMaterials || !this._sharedMaterials.is(this))
|
|
275
|
+
if (!this._sharedMaterials || !this._sharedMaterials.is(this)) {
|
|
276
|
+
if (!this._originalMaterials) this._originalMaterials = [];
|
|
259
277
|
this._sharedMaterials = new SharedMaterialArray(this, this._originalMaterials);
|
|
278
|
+
}
|
|
260
279
|
return this._sharedMaterials!;
|
|
261
280
|
}
|
|
262
281
|
|
|
@@ -609,8 +628,6 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
609
628
|
loadProgressiveTextures(material: THREE.Material) {
|
|
610
629
|
// progressive load before rendering so we only load textures for visible materials
|
|
611
630
|
if (!suppressProgressiveLoading && material) {
|
|
612
|
-
if (debugProgressiveLoading && material["_didRequestTextureLOD"] === undefined)
|
|
613
|
-
console.warn("Progressive?", this)
|
|
614
631
|
|
|
615
632
|
if (material["_didRequestTextureLOD"] === undefined && this.allowProgressiveLoading) {
|
|
616
633
|
material["_didRequestTextureLOD"] = 0;
|
|
@@ -43,6 +43,8 @@ export class RemoteSkybox extends Behaviour {
|
|
|
43
43
|
this._prevLoadedEnvironment = undefined;
|
|
44
44
|
}
|
|
45
45
|
this.unregisterDropEvents();
|
|
46
|
+
// Re-apply the skybox/background settings of the main camera
|
|
47
|
+
this.context.mainCameraComponent?.applyClearFlags();
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
async setSkybox(url: string | undefined | null) {
|
|
@@ -20,15 +20,11 @@ export class SmoothFollow extends Behaviour {
|
|
|
20
20
|
@serializable()
|
|
21
21
|
positionAxes : Axes = Axes.All;
|
|
22
22
|
|
|
23
|
-
// @serializable()
|
|
24
|
-
// rotationAxes : Axes = Axes.All;
|
|
25
|
-
|
|
26
23
|
flipForward: boolean = false;
|
|
27
24
|
|
|
28
25
|
private static _invertForward: THREE.Quaternion = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI);
|
|
29
26
|
private _firstUpdate = true;
|
|
30
27
|
|
|
31
|
-
|
|
32
28
|
onBeforeRender(): void {
|
|
33
29
|
this.updateNow(false);
|
|
34
30
|
}
|
|
@@ -39,9 +35,13 @@ export class SmoothFollow extends Behaviour {
|
|
|
39
35
|
const wp = getWorldPosition(this.target);
|
|
40
36
|
const fpos = this._firstUpdate || hard ? 1 : Mathf.clamp01(this.context.time.deltaTime * this.followFactor);
|
|
41
37
|
const currentPosition = this.worldPosition;
|
|
38
|
+
|
|
42
39
|
if(this.positionAxes & Axes.X) currentPosition.x = Mathf.lerp(currentPosition.x, wp.x, fpos);
|
|
43
40
|
if(this.positionAxes & Axes.Y) currentPosition.y = Mathf.lerp(currentPosition.y, wp.y, fpos);
|
|
44
41
|
if(this.positionAxes & Axes.Z) currentPosition.z = Mathf.lerp(currentPosition.z, wp.z, fpos);
|
|
42
|
+
|
|
43
|
+
// TODO lerp distance from target as well
|
|
44
|
+
|
|
45
45
|
this.worldPosition = currentPosition;
|
|
46
46
|
}
|
|
47
47
|
if (this.rotateFactor > 0) {
|