@needle-tools/engine 2.33.0-pre → 2.35.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.d.ts +3045 -2855
- package/dist/needle-engine.js +457 -407
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +117 -67
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/api.d.ts +3 -0
- package/lib/engine/api.js +4 -0
- package/lib/engine/api.js.map +1 -0
- package/lib/engine/engine.d.ts +4 -3
- package/lib/engine/engine_addressables.d.ts +5 -4
- package/lib/engine/engine_addressables.js +8 -7
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_components.d.ts +16 -0
- package/lib/engine/engine_components.js +223 -0
- package/lib/engine/engine_components.js.map +1 -0
- package/lib/engine/engine_create_objects.d.ts +11 -0
- package/lib/engine/engine_create_objects.js +20 -0
- package/lib/engine/engine_create_objects.js.map +1 -0
- package/lib/engine/engine_element.js +2 -2
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +33 -0
- package/lib/engine/engine_gameobject.js +449 -0
- package/lib/engine/engine_gameobject.js.map +1 -0
- package/lib/engine/engine_gltf.d.ts +13 -2
- package/lib/engine/engine_gltf.js +7 -1
- package/lib/engine/engine_gltf.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.d.ts +3 -3
- package/lib/engine/engine_gltf_builtin_components.js +2 -3
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_instancing.d.ts +5 -0
- package/lib/engine/engine_instancing.js +22 -0
- package/lib/engine/engine_instancing.js.map +1 -0
- package/lib/engine/engine_lightdata.d.ts +1 -1
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.d.ts +2 -2
- package/lib/engine/engine_mainloop_utils.js +7 -6
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +2 -11
- package/lib/engine/engine_networking.js +1 -7
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_files.d.ts +1 -1
- package/lib/engine/engine_networking_files.js +8 -7
- package/lib/engine/engine_networking_files.js.map +1 -1
- package/lib/engine/engine_networking_files_default_components.d.ts +2 -2
- package/lib/engine/engine_networking_files_default_components.js +38 -43
- package/lib/engine/engine_networking_files_default_components.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.d.ts +8 -6
- package/lib/engine/engine_networking_instantiate.js +12 -9
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_networking_types.d.ts +14 -0
- package/lib/engine/engine_networking_types.js +8 -0
- package/lib/engine/engine_networking_types.js.map +1 -0
- package/lib/engine/engine_physics.d.ts +1 -23
- package/lib/engine/engine_physics.js +18 -56
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_rendererdata.d.ts +1 -1
- package/lib/engine/engine_rendererdata.js.map +1 -1
- package/lib/engine/engine_scenetools.d.ts +2 -2
- package/lib/engine/engine_scenetools.js +22 -5
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +1 -1
- package/lib/engine/engine_serialization_core.d.ts +1 -1
- package/lib/engine/engine_serialization_decorator.d.ts +1 -1
- package/lib/engine/engine_setup.d.ts +14 -15
- package/lib/engine/engine_setup.js +34 -23
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_three_utils.js +0 -6
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_types.d.ts +103 -0
- package/lib/engine/engine_types.js +49 -0
- package/lib/engine/engine_types.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.js +2 -2
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_deferred_texture.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_lighting_settings.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_lightmaps.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.d.ts +2 -2
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -2
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/extensions/extensions.d.ts +1 -1
- package/lib/engine-components/Animation.js +1 -1
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AvatarLoader.js +6 -5
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +2 -2
- package/lib/engine-components/Camera.js +6 -12
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.d.ts +3 -0
- package/lib/engine-components/CameraUtils.js +15 -0
- package/lib/engine-components/CameraUtils.js.map +1 -0
- package/lib/engine-components/Collider.d.ts +1 -0
- package/lib/engine-components/Collider.js +4 -0
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +16 -50
- package/lib/engine-components/Component.js +67 -465
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.js +1 -1
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/Duplicatable.js +2 -1
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/LODGroup.js.map +1 -1
- package/lib/engine-components/Light.d.ts +2 -1
- package/lib/engine-components/Light.js +2 -2
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/NestedGltf.js +2 -1
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +4 -2
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +3 -5
- package/lib/engine-components/Renderer.js +3 -20
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/{Rigidbody.d.ts → RigidBody.d.ts} +2 -1
- package/lib/engine-components/{Rigidbody.js → RigidBody.js} +1 -1
- package/lib/engine-components/{Rigidbody.js.map → RigidBody.js.map} +1 -1
- package/lib/engine-components/ScreenCapture.d.ts +0 -10
- package/lib/engine-components/ScreenCapture.js +8 -75
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedCamera.js +3 -2
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js +1 -1
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TestRunner.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +14 -3
- package/lib/engine-components/VideoPlayer.js +390 -47
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/Voip.js +2 -1
- package/lib/engine-components/Voip.js.map +1 -1
- package/lib/engine-components/WebARSessionRoot.js +1 -1
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.js +1 -1
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/WebXRController.d.ts +1 -0
- package/lib/engine-components/WebXRController.js +40 -9
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/WebXRGrabRendering.d.ts +1 -1
- package/lib/engine-components/WebXRGrabRendering.js +1 -1
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -1
- package/lib/engine-components/WebXRSync.js +1 -1
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -2
- package/lib/engine-components/codegen/components.js +1 -2
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/js-extensions/ExtensionUtils.d.ts +4 -0
- package/lib/engine-components/js-extensions/ExtensionUtils.js +56 -0
- package/lib/engine-components/js-extensions/ExtensionUtils.js.map +1 -0
- package/lib/engine-components/js-extensions/Object3D.js +16 -41
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/js-extensions/Vector.d.ts +2 -0
- package/lib/engine-components/js-extensions/Vector.js +16 -0
- package/lib/engine-components/js-extensions/Vector.js.map +1 -0
- package/lib/engine-components/timeline/PlayableDirector.d.ts +2 -1
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/ui/BaseUIComponent.d.ts +1 -0
- package/lib/engine-components/ui/BaseUIComponent.js +11 -5
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +3 -0
- package/lib/engine-components/ui/Canvas.js +12 -1
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/CanvasScaler.d.ts +0 -0
- package/lib/engine-components/ui/CanvasScaler.js +17 -0
- package/lib/engine-components/ui/CanvasScaler.js.map +1 -0
- package/lib/engine-components/ui/EventSystem.d.ts +4 -1
- package/lib/engine-components/ui/EventSystem.js +28 -39
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/Graphic.js +2 -1
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Keyboard.js +2 -1
- package/lib/engine-components/ui/Keyboard.js.map +1 -1
- package/lib/engine-components/ui/RaycastUtils.d.ts +11 -0
- package/lib/engine-components/ui/RaycastUtils.js +62 -0
- package/lib/engine-components/ui/RaycastUtils.js.map +1 -0
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/ui/Text.js +8 -3
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/ui/Utils.js +3 -2
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/needle-engine.d.ts +3 -1
- package/lib/needle-engine.js +4 -2
- package/lib/needle-engine.js.map +1 -1
- package/package.json +13 -2
- package/src/engine/api.ts +3 -0
- package/src/engine/codegen/register_types.js +4 -6
- package/src/engine/engine_addressables.ts +12 -10
- package/src/engine/{engine_components.js → engine_components.ts} +37 -47
- package/src/engine/engine_create_objects.ts +27 -0
- package/src/engine/engine_element.ts +2 -2
- package/src/engine/engine_gameobject.ts +506 -0
- package/src/engine/engine_gltf.ts +21 -2
- package/src/engine/engine_gltf_builtin_components.ts +8 -7
- package/src/engine/engine_instancing.ts +25 -0
- package/src/engine/engine_lightdata.ts +1 -1
- package/src/engine/engine_mainloop_utils.ts +13 -11
- package/src/engine/engine_networking.ts +3 -14
- package/src/engine/engine_networking_files.ts +14 -11
- package/src/engine/engine_networking_files_default_components.ts +53 -52
- package/src/engine/engine_networking_instantiate.ts +24 -14
- package/src/engine/engine_networking_types.ts +19 -0
- package/src/engine/engine_physics.ts +21 -75
- package/src/engine/engine_rendererdata.ts +1 -1
- package/src/engine/engine_scenetools.ts +30 -6
- package/src/engine/engine_serialization_core.ts +1 -1
- package/src/engine/engine_serialization_decorator.ts +1 -1
- package/src/engine/engine_setup.ts +51 -37
- package/src/engine/engine_three_utils.ts +0 -8
- package/src/engine/engine_types.ts +180 -0
- package/src/engine/engine_utils.ts +1 -3
- package/src/engine/extensions/NEEDLE_components.ts +2 -2
- package/src/engine/extensions/NEEDLE_deferred_texture.ts +1 -1
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +1 -1
- package/src/engine/extensions/NEEDLE_lightmaps.ts +1 -1
- package/src/engine/extensions/NEEDLE_render_objects.ts +4 -4
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +5 -4
- package/src/engine/extensions/extensions.ts +1 -1
- package/src/engine-components/Animation.ts +1 -1
- package/src/engine-components/Animator.ts +3 -3
- package/src/engine-components/AvatarLoader.ts +6 -5
- package/src/engine-components/Camera.ts +10 -13
- package/src/engine-components/CameraUtils.ts +15 -0
- package/src/engine-components/Collider.ts +5 -0
- package/src/engine-components/Component.ts +83 -535
- package/src/engine-components/DragControls.ts +1 -1
- package/src/engine-components/Duplicatable.ts +4 -3
- package/src/engine-components/LODGroup.ts +1 -1
- package/src/engine-components/Light.ts +3 -2
- package/src/engine-components/NestedGltf.ts +2 -1
- package/src/engine-components/OrbitControls.ts +5 -5
- package/src/engine-components/Renderer.ts +7 -21
- package/src/engine-components/RigidBody.ts +2 -1
- package/src/engine-components/ScreenCapture.ts +11 -77
- package/src/engine-components/SpectatorCamera.ts +7 -5
- package/src/engine-components/SyncedCamera.ts +3 -2
- package/src/engine-components/SyncedTransform.ts +2 -2
- package/src/engine-components/TestRunner.ts +1 -2
- package/src/engine-components/VideoPlayer.ts +401 -48
- package/src/engine-components/Voip.ts +2 -1
- package/src/engine-components/WebARSessionRoot.ts +1 -1
- package/src/engine-components/WebXR.ts +2 -2
- package/src/engine-components/WebXRAvatar.ts +1 -1
- package/src/engine-components/WebXRController.ts +40 -10
- package/src/engine-components/WebXRGrabRendering.ts +1 -1
- package/src/engine-components/WebXRSync.ts +1 -1
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +2 -1
- package/src/engine-components/codegen/components.ts +1 -2
- package/src/engine-components/js-extensions/ExtensionUtils.ts +66 -0
- package/src/engine-components/js-extensions/Object3D.ts +22 -48
- package/src/engine-components/js-extensions/Vector.ts +17 -0
- package/src/engine-components/timeline/PlayableDirector.ts +2 -1
- package/src/engine-components/ui/BaseUIComponent.ts +17 -6
- package/src/engine-components/ui/Canvas.ts +14 -2
- package/src/engine-components/ui/CanvasScaler.ts +21 -0
- package/src/engine-components/ui/EventSystem.ts +30 -35
- package/src/engine-components/ui/Graphic.ts +2 -1
- package/src/engine-components/ui/Keyboard.ts +2 -1
- package/src/engine-components/ui/RaycastUtils.ts +64 -0
- package/src/engine-components/ui/Raycaster.ts +2 -0
- package/src/engine-components/ui/Text.ts +8 -4
- package/src/engine-components/ui/Utils.ts +3 -2
- package/src/needle-engine.ts +7 -2
|
@@ -7,12 +7,12 @@ import { Context } from "../engine/engine_setup";
|
|
|
7
7
|
import { Interactable, UsageMarker } from "./Interactable";
|
|
8
8
|
import { Rigidbody } from "./RigidBody";
|
|
9
9
|
import { WebXR } from "./WebXR";
|
|
10
|
-
import { InstancingUtil } from "./Renderer";
|
|
11
10
|
import { Avatar_POI } from "./avatar/Avatar_Brain_LookAt";
|
|
12
11
|
import { RaycastOptions } from "../engine/engine_physics";
|
|
13
12
|
import { getWorldPosition, getWorldQuaternion, setWorldPosition } from "../engine/engine_three_utils";
|
|
14
13
|
import { KeyCode } from "../engine/engine_input";
|
|
15
14
|
import { nameofFactory } from "../engine/engine_utils";
|
|
15
|
+
import { InstancingUtil } from "../engine/engine_instancing";
|
|
16
16
|
|
|
17
17
|
const debug = false;
|
|
18
18
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Behaviour, GameObject
|
|
1
|
+
import { Behaviour, GameObject } from "./Component";
|
|
2
2
|
import { WebXRController, ControllerEvents } from "./WebXRController";
|
|
3
3
|
import { DragControls, DragEvents } from "./DragControls";
|
|
4
4
|
import { Interactable } from "./Interactable";
|
|
5
5
|
import { Animation } from "./Animation";
|
|
6
6
|
import { Vector3, Quaternion, Object3D } from "three";
|
|
7
7
|
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
8
|
+
import { InstantiateOptions } from "../engine/engine_gameobject";
|
|
8
9
|
|
|
9
10
|
export class Duplicatable extends Interactable {
|
|
10
11
|
|
|
@@ -35,7 +36,7 @@ export class Duplicatable extends Interactable {
|
|
|
35
36
|
// }
|
|
36
37
|
// console.log(this, this.object);
|
|
37
38
|
if (this.object) {
|
|
38
|
-
if (this.object === this.gameObject) {
|
|
39
|
+
if (this.object as any === this.gameObject) {
|
|
39
40
|
console.error("Can not duplicate self");
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
@@ -90,7 +91,7 @@ export class Duplicatable extends Interactable {
|
|
|
90
91
|
if (!this.object) return null;
|
|
91
92
|
if (selected === this.gameObject || this.handleMultiObject(selected)) {
|
|
92
93
|
|
|
93
|
-
if (this.object === this.gameObject) return null;
|
|
94
|
+
if (this.object as any === this.gameObject) return null;
|
|
94
95
|
this.object.visible = true;
|
|
95
96
|
|
|
96
97
|
if (this._startPosition)
|
|
@@ -31,7 +31,7 @@ class LOD {
|
|
|
31
31
|
this.model = model;
|
|
32
32
|
this.renderers = [];
|
|
33
33
|
for (const guid of model.renderers) {
|
|
34
|
-
const rend = this.findRenderer(guid, group.gameObject);// GameObject.findByGuid(guid, group.gameObject) as Renderer;
|
|
34
|
+
const rend = this.findRenderer(guid, group.gameObject as GameObject);// GameObject.findByGuid(guid, group.gameObject) as Renderer;
|
|
35
35
|
if (rend && rend.gameObject) {
|
|
36
36
|
this.renderers.push(rend);
|
|
37
37
|
}
|
|
@@ -7,6 +7,7 @@ import { serializeable } from "../engine/engine_serialization_decorator";
|
|
|
7
7
|
import { Color, DirectionalLight, OrthographicCamera } from "three";
|
|
8
8
|
import { WebXR, WebXREvent } from "./WebXR";
|
|
9
9
|
import { WebARSessionRoot } from "./WebARSessionRoot";
|
|
10
|
+
import { ILight } from "../engine/engine_types";
|
|
10
11
|
|
|
11
12
|
// https://threejs.org/examples/webgl_shadowmap_csm.html
|
|
12
13
|
|
|
@@ -82,7 +83,7 @@ enum LightShadows {
|
|
|
82
83
|
Soft = 2,
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
export class Light extends Behaviour {
|
|
86
|
+
export class Light extends Behaviour implements ILight {
|
|
86
87
|
|
|
87
88
|
@serializeable()
|
|
88
89
|
private type: LightType = 0;
|
|
@@ -263,7 +264,7 @@ export class Light extends Behaviour {
|
|
|
263
264
|
private _webARRoot?: WebARSessionRoot;
|
|
264
265
|
|
|
265
266
|
private onWebXRStarted() {
|
|
266
|
-
this._webARRoot = this.gameObject
|
|
267
|
+
this._webARRoot = GameObject.getComponentInParent(this.gameObject, WebARSessionRoot) ?? undefined;
|
|
267
268
|
this.startCoroutine(this._updateLightIntensityInARRoutine());
|
|
268
269
|
}
|
|
269
270
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getParam } from "../engine/engine_utils";
|
|
2
|
-
import { Behaviour
|
|
2
|
+
import { Behaviour } from "../engine-components/Component";
|
|
3
3
|
import { AssetReference, ProgressCallback } from "../engine/engine_addressables";
|
|
4
4
|
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
5
5
|
import { InstantiateIdProvider } from "../engine/engine_networking_instantiate";
|
|
6
|
+
import { InstantiateOptions } from "../engine/engine_gameobject";
|
|
6
7
|
|
|
7
8
|
const debug = getParam("debugnestedgltf");
|
|
8
9
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Behaviour, GameObject } from "./Component";
|
|
2
|
-
import { Camera } from "./Camera";
|
|
2
|
+
// import { Camera } from "./Camera";
|
|
3
3
|
import { OrbitControls as ThreeOrbitControls } from "three/examples/jsm/controls/OrbitControls";
|
|
4
4
|
import { LookAtConstraint } from "./LookAtConstraint";
|
|
5
5
|
import * as THREE from "three";
|
|
6
6
|
import { getWorldPosition } from "../engine/engine_three_utils";
|
|
7
|
-
import {
|
|
7
|
+
import { RaycastOptions } from "../engine/engine_physics";
|
|
8
8
|
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
9
|
-
import {
|
|
9
|
+
import { Camera } from "./Camera";
|
|
10
10
|
|
|
11
11
|
export class OrbitControls extends Behaviour {
|
|
12
12
|
public get controls() {
|
|
@@ -30,7 +30,7 @@ export class OrbitControls extends Behaviour {
|
|
|
30
30
|
minZoom: number = 0;
|
|
31
31
|
maxZoom: number = Infinity;
|
|
32
32
|
enablePan: boolean = true;
|
|
33
|
-
@serializeable()
|
|
33
|
+
@serializeable(LookAtConstraint)
|
|
34
34
|
lookAtConstraint: LookAtConstraint | null = null;
|
|
35
35
|
lookAtConstraint01: number = 1;
|
|
36
36
|
middleClickToFocus: boolean = true;
|
|
@@ -61,10 +61,10 @@ export class OrbitControls extends Behaviour {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
onEnable() {
|
|
64
|
+
|
|
64
65
|
this._enableTime = this.context.time.time;
|
|
65
66
|
const camGo = GameObject.getComponent(this.gameObject, Camera);
|
|
66
67
|
const cam = camGo?.cam;
|
|
67
|
-
|
|
68
68
|
if (!this._controls) {
|
|
69
69
|
console.assert(cam !== null && cam !== undefined, "Missing camera", this);
|
|
70
70
|
if (cam)
|
|
@@ -8,6 +8,11 @@ import { serializeable } from "../engine/engine_serialization_decorator";
|
|
|
8
8
|
import { Material, Texture, Vector4 } from "three";
|
|
9
9
|
import { NEEDLE_render_objects } from "../engine/extensions/NEEDLE_render_objects";
|
|
10
10
|
import { NEEDLE_deferred_texture } from "../engine/extensions/NEEDLE_deferred_texture";
|
|
11
|
+
import { NEED_UPDATE_INSTANCE_KEY } from "../engine/engine_instancing";
|
|
12
|
+
import { IRenderer } from "../engine/engine_types";
|
|
13
|
+
|
|
14
|
+
// for staying compatible with old code
|
|
15
|
+
export { InstancingUtil } from "../engine/engine_instancing";
|
|
11
16
|
|
|
12
17
|
const suppressInstancing = getParam("noInstancing");
|
|
13
18
|
const debugLightmap = getParam("debuglightmaps") ? true : false;
|
|
@@ -98,7 +103,7 @@ class SharedMaterialArray {
|
|
|
98
103
|
|
|
99
104
|
}
|
|
100
105
|
|
|
101
|
-
export class Renderer extends Behaviour {
|
|
106
|
+
export class Renderer extends Behaviour implements IRenderer {
|
|
102
107
|
|
|
103
108
|
@serializeable()
|
|
104
109
|
receiveShadows: boolean = false;
|
|
@@ -491,26 +496,7 @@ export enum ShadowCastingMode {
|
|
|
491
496
|
ShadowsOnly,
|
|
492
497
|
}
|
|
493
498
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
export class InstancingUtil {
|
|
497
|
-
// TODO: change this so it does not set matrix world directly but some flag that is only used by instancing
|
|
498
|
-
static markDirty(go: THREE.Object3D | null, recursive: boolean = true) {
|
|
499
|
-
if (!go) return;
|
|
500
|
-
// potential optimization:
|
|
501
|
-
// if(go.matrixWorldNeedsUpdate) return;
|
|
502
|
-
// console.trace(go, GameObject.isUsingInstancing(go));
|
|
503
|
-
if (GameObject.isUsingInstancing(go)) {
|
|
504
|
-
go[NEED_UPDATE_INSTANCE_KEY] = true;
|
|
505
|
-
go.matrixWorldNeedsUpdate = true;
|
|
506
|
-
}
|
|
507
|
-
if (recursive) {
|
|
508
|
-
for (const child of go.children) {
|
|
509
|
-
InstancingUtil.markDirty(child, true);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
499
|
+
|
|
514
500
|
|
|
515
501
|
declare class InstancingSetupArgs { rend: Renderer; foundMeshes: number };
|
|
516
502
|
|
|
@@ -6,8 +6,9 @@ import { getWorldPosition } from "../engine/engine_three_utils";
|
|
|
6
6
|
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
7
7
|
import { Watch } from "../engine/engine_utils";
|
|
8
8
|
import { Vector3 } from "three";
|
|
9
|
+
import { IRigidbody } from "../engine/engine_types";
|
|
9
10
|
|
|
10
|
-
export class Rigidbody extends Behaviour {
|
|
11
|
+
export class Rigidbody extends Behaviour implements IRigidbody {
|
|
11
12
|
|
|
12
13
|
@serializeable()
|
|
13
14
|
mass: number = 1;
|
|
@@ -5,12 +5,11 @@ import { Context } from "../engine/engine_setup";
|
|
|
5
5
|
import { RoomEvents } from "../engine/engine_networking";
|
|
6
6
|
import { UserJoinedOrLeftRoomModel } from "../engine/engine_networking";
|
|
7
7
|
import { serializeable } from "../engine/engine_serialization";
|
|
8
|
-
import { IModel } from "../engine/engine_networking";
|
|
9
8
|
import { IPointerClickHandler } from "./ui/PointerEvents";
|
|
10
9
|
import { EventDispatcher } from "three";
|
|
11
10
|
import { AudioSource } from "./AudioSource";
|
|
12
|
-
import { getWorldScale, setWorldScale } from "../engine/engine_three_utils";
|
|
13
11
|
import { getParam } from "../engine/engine_utils";
|
|
12
|
+
import { IModel } from "../engine/engine_networking_types";
|
|
14
13
|
|
|
15
14
|
const debug = getParam("debugscreenshare");
|
|
16
15
|
|
|
@@ -26,12 +25,6 @@ export enum ScreenCaptureMode {
|
|
|
26
25
|
Receiving = 2
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export enum AspectMode {
|
|
30
|
-
None = 0,
|
|
31
|
-
AdjustHeight = 1,
|
|
32
|
-
AdjustWidth = 2,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
28
|
function disposeStream(str: MediaStream | null | undefined) {
|
|
36
29
|
if (!str) return;
|
|
37
30
|
for (const cap of str.getTracks())
|
|
@@ -42,6 +35,8 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
42
35
|
|
|
43
36
|
onPointerClick() {
|
|
44
37
|
if (this.isReceiving) {
|
|
38
|
+
if (this.videoPlayer)
|
|
39
|
+
this.videoPlayer.screenspace = !this.videoPlayer.screenspace;
|
|
45
40
|
return;
|
|
46
41
|
}
|
|
47
42
|
if (this.isSending) {
|
|
@@ -58,9 +53,6 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
58
53
|
@serializeable()
|
|
59
54
|
device: ScreenCaptureDevice = ScreenCaptureDevice.Screen;
|
|
60
55
|
|
|
61
|
-
@serializeable()
|
|
62
|
-
aspectMode: AspectMode = AspectMode.AdjustHeight;
|
|
63
|
-
|
|
64
56
|
get currentScream(): MediaStream | null {
|
|
65
57
|
return this._currentStream;
|
|
66
58
|
}
|
|
@@ -187,11 +179,16 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
187
179
|
this._requestOpen = true;
|
|
188
180
|
this._currentMode = mode;
|
|
189
181
|
this.videoPlayer.setVideo(stream);
|
|
190
|
-
|
|
182
|
+
|
|
183
|
+
const isSending = mode === ScreenCaptureMode.Sending;
|
|
184
|
+
if (isSending) {
|
|
191
185
|
this._net?.startSendingVideo(stream);
|
|
192
186
|
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
stream.addEventListener("ended", () => {
|
|
190
|
+
this.close();
|
|
191
|
+
});
|
|
195
192
|
}
|
|
196
193
|
|
|
197
194
|
private onReceiveVideo(evt: ReceiveVideoEvent) {
|
|
@@ -200,7 +197,6 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
200
197
|
|
|
201
198
|
|
|
202
199
|
|
|
203
|
-
|
|
204
200
|
private async tryShareUserCamera(opts: DisplayMediaStreamConstraints) {
|
|
205
201
|
|
|
206
202
|
// let newWindow = open('', 'example', 'width=300,height=300');
|
|
@@ -239,68 +235,6 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
|
239
235
|
// private openWindowToSelectCamera(){
|
|
240
236
|
|
|
241
237
|
// }
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
private _targetObjects?: Array<THREE.Object3D>;
|
|
247
|
-
|
|
248
|
-
private updateAspect() {
|
|
249
|
-
this.startCoroutine(this.updateAspectImpl());
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
private _updateAspectRoutineId: number = -1;
|
|
253
|
-
private *updateAspectImpl() {
|
|
254
|
-
const id = ++this._updateAspectRoutineId;
|
|
255
|
-
const lastAspect: number | undefined = undefined;
|
|
256
|
-
while (this.aspectMode !== AspectMode.None && this._currentStream && id === this._updateAspectRoutineId) {
|
|
257
|
-
const video = this.videoPlayer;
|
|
258
|
-
const stream = this._currentStream;
|
|
259
|
-
if (!video) return;
|
|
260
|
-
if (!stream) return;
|
|
261
|
-
let aspect: number | undefined = undefined;
|
|
262
|
-
for (const track of stream.getVideoTracks()) {
|
|
263
|
-
const settings = track.getSettings();
|
|
264
|
-
if (settings && settings.width && settings.height) {
|
|
265
|
-
aspect = settings.width / settings.height;
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
// on firefox capture canvas stream works but looks like
|
|
269
|
-
// the canvas stream track doesnt contain settings?!!?
|
|
270
|
-
else {
|
|
271
|
-
if (this.device === ScreenCaptureDevice.Canvas)
|
|
272
|
-
aspect = this.context.renderer.domElement.clientWidth / this.context.renderer.domElement.clientHeight;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (aspect === undefined) {
|
|
276
|
-
yield;
|
|
277
|
-
continue;
|
|
278
|
-
}
|
|
279
|
-
if (lastAspect === aspect) {
|
|
280
|
-
yield;
|
|
281
|
-
continue;
|
|
282
|
-
}
|
|
283
|
-
if (!this._targetObjects)
|
|
284
|
-
this._targetObjects = video.getTargetObjects();
|
|
285
|
-
for (const obj of this._targetObjects) {
|
|
286
|
-
let worldAspect = 1;
|
|
287
|
-
if (obj.parent) {
|
|
288
|
-
const parentScale = getWorldScale(obj.parent);
|
|
289
|
-
worldAspect = parentScale.x / parentScale.y;
|
|
290
|
-
}
|
|
291
|
-
switch (this.aspectMode) {
|
|
292
|
-
case AspectMode.AdjustHeight:
|
|
293
|
-
obj.scale.y = 1 / aspect * obj.scale.x * worldAspect;
|
|
294
|
-
break;
|
|
295
|
-
case AspectMode.AdjustWidth:
|
|
296
|
-
obj.scale.x = aspect * obj.scale.y * worldAspect;
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
for (let i = 0; i < 3; i++)
|
|
301
|
-
yield;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
238
|
}
|
|
305
239
|
|
|
306
240
|
|
|
@@ -12,7 +12,9 @@ import { Context } from "../engine/engine_setup";
|
|
|
12
12
|
import { getParam } from "../engine/engine_utils";
|
|
13
13
|
import { PlayerView, ViewDevice } from "../engine/engine_playerview";
|
|
14
14
|
import { RaycastOptions } from "../engine/engine_physics";
|
|
15
|
-
import {
|
|
15
|
+
import { RoomEvents } from "../engine/engine_networking";
|
|
16
|
+
import { ICamera } from "../engine/engine_types";
|
|
17
|
+
import { IModel } from "../engine/engine_networking_types";
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
export enum SpectatorMode {
|
|
@@ -177,7 +179,7 @@ export class SpectatorCamera extends Behaviour {
|
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
private onXRSessionEnded(_evt) {
|
|
180
|
-
this.context.removeCamera(this.cam);
|
|
182
|
+
this.context.removeCamera(this.cam as ICamera);
|
|
181
183
|
GameObject.setActive(this.gameObject, false);
|
|
182
184
|
if (this.orbit) this.orbit.enabled = true;
|
|
183
185
|
this._handler?.set(undefined);
|
|
@@ -355,16 +357,16 @@ class SpectatorHandler implements ISpectatorHandler {
|
|
|
355
357
|
// this.context.setCurrentCamera(this.cam);
|
|
356
358
|
if (debug) console.log("FOLLOW", followObject);
|
|
357
359
|
if (!this.context.isInXR) {
|
|
358
|
-
this.context.setCurrentCamera(this.cam);
|
|
360
|
+
this.context.setCurrentCamera(this.cam as ICamera);
|
|
359
361
|
}
|
|
360
|
-
else this.context.removeCamera(this.cam);
|
|
362
|
+
else this.context.removeCamera(this.cam as ICamera);
|
|
361
363
|
}
|
|
362
364
|
|
|
363
365
|
disable() {
|
|
364
366
|
if (debug) console.log("STOP FOLLOW", this.currentObject);
|
|
365
367
|
this.view = undefined;
|
|
366
368
|
this.currentObject = undefined;
|
|
367
|
-
this.context.removeCamera(this.cam);
|
|
369
|
+
this.context.removeCamera(this.cam as ICamera);
|
|
368
370
|
if (this.follow)
|
|
369
371
|
this.follow.enabled = false;
|
|
370
372
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NetworkConnection } from "../engine/engine_networking";
|
|
2
|
-
import { Behaviour, GameObject
|
|
2
|
+
import { Behaviour, GameObject } from "./Component";
|
|
3
3
|
import { Camera } from "./Camera";
|
|
4
4
|
import * as utils from "../engine/engine_three_utils"
|
|
5
5
|
import { WebXR } from "./WebXR";
|
|
@@ -7,12 +7,13 @@ import { Builder } from "flatbuffers";
|
|
|
7
7
|
import { SyncedCameraModel } from "../engine-schemes/synced-camera-model";
|
|
8
8
|
import { Vec3 } from "../engine-schemes/vec3";
|
|
9
9
|
import { registerType } from "../engine-schemes/schemes";
|
|
10
|
-
import { InstancingUtil } from "
|
|
10
|
+
import { InstancingUtil } from "../engine/engine_instancing";
|
|
11
11
|
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
12
12
|
import { Object3D } from "three";
|
|
13
13
|
import { AvatarMarker } from "./WebXRAvatar";
|
|
14
14
|
import { AssetReference } from "../engine/engine_addressables";
|
|
15
15
|
import { ViewDevice } from "../engine/engine_playerview";
|
|
16
|
+
import { InstantiateOptions } from "../engine/engine_gameobject";
|
|
16
17
|
|
|
17
18
|
const SyncedCameraModelIdentifier = "SCAM";
|
|
18
19
|
registerType(SyncedCameraModelIdentifier, SyncedCameraModel.getRootAsSyncedCameraModel);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as THREE from 'three'
|
|
2
|
-
import {
|
|
2
|
+
import { OwnershipModel, RoomEvents } from "../engine/engine_networking"
|
|
3
3
|
import { Behaviour, GameObject } from "./Component";
|
|
4
4
|
import { Rigidbody } from "./RigidBody";
|
|
5
5
|
import * as utils from "../engine/engine_utils"
|
|
6
6
|
import { sendDestroyed } from '../engine/engine_networking_instantiate';
|
|
7
|
-
import { InstancingUtil } from
|
|
7
|
+
import { InstancingUtil } from "../engine/engine_instancing";
|
|
8
8
|
import { SyncedTransformModel } from '../engine-schemes/synced-transform-model';
|
|
9
9
|
import * as flatbuffers from "flatbuffers";
|
|
10
10
|
import { Transform } from '../engine-schemes/transform';
|
|
@@ -3,10 +3,9 @@ import * as tests from "../engine/tests/test_utils";
|
|
|
3
3
|
import { createTransformModel, SyncedTransform, SyncedTransformIdentifier } from "./SyncedTransform";
|
|
4
4
|
import * as flatbuffers from 'flatbuffers';
|
|
5
5
|
import { SyncedTransformModel } from "../engine-schemes/synced-transform-model";
|
|
6
|
-
import * as schemes from "../engine-schemes/schemes";
|
|
7
|
-
import { IModel, NetworkConnection } from "../engine/engine_networking";
|
|
8
6
|
import { Rigidbody } from "./Rigidbody";
|
|
9
7
|
import { Vector3 } from "three";
|
|
8
|
+
import { IModel } from "../engine/engine_networking_types";
|
|
10
9
|
|
|
11
10
|
export class TestRunner extends Behaviour {
|
|
12
11
|
awake(): void {
|