@needle-tools/engine 2.33.0-pre → 2.34.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 +9 -0
- package/dist/needle-engine.d.ts +177 -153
- package/dist/needle-engine.js +390 -340
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +68 -18
- package/dist/needle-engine.min.js.map +4 -4
- 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_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_physics.d.ts +2 -0
- package/lib/engine/engine_physics.js +7 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine-components/Animation.js +1 -1
- package/lib/engine-components/Animation.js.map +1 -1
- 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.js +2 -1
- 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/Renderer.d.ts +0 -3
- package/lib/engine-components/Renderer.js +1 -20
- package/lib/engine-components/Renderer.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/SyncedCamera.js +1 -1
- 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/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/WebARSessionRoot.js +1 -1
- package/lib/engine-components/WebARSessionRoot.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 +12 -1
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +0 -1
- package/lib/engine-components/codegen/components.js +0 -1
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.d.ts +3 -0
- package/lib/engine-components/ui/EventSystem.js +17 -8
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/package.json +2 -2
- package/src/engine/codegen/register_types.js +2 -4
- package/src/engine/engine_create_objects.ts +27 -0
- package/src/engine/engine_instancing.ts +25 -0
- package/src/engine/engine_physics.ts +9 -1
- package/src/engine-components/Animation.ts +1 -1
- package/src/engine-components/Collider.ts +5 -0
- package/src/engine-components/Component.ts +2 -1
- package/src/engine-components/DragControls.ts +1 -1
- package/src/engine-components/Renderer.ts +2 -20
- package/src/engine-components/ScreenCapture.ts +10 -76
- package/src/engine-components/SyncedCamera.ts +1 -1
- package/src/engine-components/SyncedTransform.ts +1 -1
- package/src/engine-components/VideoPlayer.ts +401 -48
- package/src/engine-components/WebARSessionRoot.ts +1 -1
- package/src/engine-components/WebXRAvatar.ts +1 -1
- package/src/engine-components/WebXRController.ts +11 -1
- package/src/engine-components/codegen/components.ts +0 -1
- package/src/engine-components/ui/EventSystem.ts +19 -10
|
@@ -17,6 +17,11 @@ export class Collider extends Behaviour {
|
|
|
17
17
|
this._shape = null;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
start(){
|
|
21
|
+
if (!this.attachedRigidbody)
|
|
22
|
+
this.attachedRigidbody = this.gameObject.getComponentInParent(Rigidbody);
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
onEnable() {
|
|
21
26
|
// a rigidbody is not assigned if we export an asset
|
|
22
27
|
if (!this.attachedRigidbody)
|
|
@@ -11,6 +11,7 @@ import { InstantiateIdProvider, syncDestroy, syncInstantiate } from "../engine/e
|
|
|
11
11
|
import { SourceIdentifier } from "../engine/engine_gltf";
|
|
12
12
|
import { Collision } from "../engine/engine_physics";
|
|
13
13
|
import * as Object3DExtensions from "./js-extensions/Object3D";
|
|
14
|
+
import { InstancingUtil } from "../engine/engine_instancing";
|
|
14
15
|
|
|
15
16
|
export interface UIDProvider {
|
|
16
17
|
seed: number;
|
|
@@ -96,7 +97,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D {
|
|
|
96
97
|
go["__isUsingInstancing"] = instanced;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
public static isUsingInstancing(instance: THREE.Object3D): boolean { return instance
|
|
100
|
+
public static isUsingInstancing(instance: THREE.Object3D): boolean { return InstancingUtil.isUsingInstancing(instance); }
|
|
100
101
|
|
|
101
102
|
public static foreachComponent(instance: THREE.Object3D, cb: (comp: Component) => any, recursive: boolean = true): any {
|
|
102
103
|
if (!instance) return;
|
|
@@ -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
|
|
|
@@ -8,6 +8,7 @@ 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";
|
|
11
12
|
|
|
12
13
|
const suppressInstancing = getParam("noInstancing");
|
|
13
14
|
const debugLightmap = getParam("debuglightmaps") ? true : false;
|
|
@@ -491,26 +492,7 @@ export enum ShadowCastingMode {
|
|
|
491
492
|
ShadowsOnly,
|
|
492
493
|
}
|
|
493
494
|
|
|
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
|
-
}
|
|
495
|
+
|
|
514
496
|
|
|
515
497
|
declare class InstancingSetupArgs { rend: Renderer; foundMeshes: number };
|
|
516
498
|
|
|
@@ -9,7 +9,6 @@ import { IModel } from "../engine/engine_networking";
|
|
|
9
9
|
import { IPointerClickHandler } from "./ui/PointerEvents";
|
|
10
10
|
import { EventDispatcher } from "three";
|
|
11
11
|
import { AudioSource } from "./AudioSource";
|
|
12
|
-
import { getWorldScale, setWorldScale } from "../engine/engine_three_utils";
|
|
13
12
|
import { getParam } from "../engine/engine_utils";
|
|
14
13
|
|
|
15
14
|
const debug = getParam("debugscreenshare");
|
|
@@ -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
|
|
|
@@ -7,7 +7,7 @@ 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";
|
|
@@ -4,7 +4,7 @@ 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';
|