@needle-tools/engine 2.30.0-pre → 2.31.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 +4 -0
- package/dist/needle-engine.d.ts +807 -753
- package/dist/needle-engine.js +336 -336
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +16 -16
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/engine_physics.d.ts +19 -8
- package/lib/engine/engine_physics.js +57 -48
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine-components/Camera.js +0 -1
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/Component.d.ts +10 -0
- package/lib/engine-components/Component.js +53 -0
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/Rigidbody.d.ts +1 -1
- package/lib/engine-components/Rigidbody.js +3 -3
- package/lib/engine-components/Rigidbody.js.map +1 -1
- package/lib/engine-components/ScreenCapture.d.ts +35 -6
- package/lib/engine-components/ScreenCapture.js +356 -103
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +4 -0
- package/lib/engine-components/VideoPlayer.js +22 -1
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/needle-engine.d.ts +1 -0
- package/lib/needle-engine.js +1 -0
- package/lib/needle-engine.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_physics.ts +74 -57
- package/src/engine-components/Camera.ts +0 -1
- package/src/engine-components/Component.ts +58 -0
- package/src/engine-components/RigidBody.ts +2 -2
- package/src/engine-components/ScreenCapture.ts +386 -114
- package/src/engine-components/VideoPlayer.ts +26 -2
- package/src/needle-engine.ts +1 -0
|
@@ -125,13 +125,26 @@ export class VideoPlayer extends Behaviour {
|
|
|
125
125
|
private _isPlaying: boolean = false;
|
|
126
126
|
private wasPlaying: boolean = false;
|
|
127
127
|
|
|
128
|
+
setVideo(video: MediaStream) {
|
|
129
|
+
this.clip = video;
|
|
130
|
+
this.source = VideoSource.VideoClip;
|
|
131
|
+
if (!this.videoElement) this.create(true);
|
|
132
|
+
else {
|
|
133
|
+
// TODO: how to prevent interruption error when another video is already playing
|
|
134
|
+
this.videoElement.srcObject = video;
|
|
135
|
+
if (this._isPlaying)
|
|
136
|
+
this.videoElement.play();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
128
140
|
setClipURL(url: string) {
|
|
129
141
|
if (this.url === url) return;
|
|
130
142
|
// console.log("SET URL", url);
|
|
131
143
|
this.url = url;
|
|
132
144
|
this.source = VideoSource.Url;
|
|
133
145
|
if (debug) console.log("set url", url);
|
|
134
|
-
if (this.videoElement)
|
|
146
|
+
if (!this.videoElement) this.create(true);
|
|
147
|
+
else {
|
|
135
148
|
this.videoElement.src = url;
|
|
136
149
|
if (this._isPlaying)
|
|
137
150
|
this.videoElement.play();
|
|
@@ -182,7 +195,8 @@ export class VideoPlayer extends Behaviour {
|
|
|
182
195
|
awaitInput(() => {
|
|
183
196
|
this._receivedInput = true;
|
|
184
197
|
this.updateVideoElementSettings();
|
|
185
|
-
})
|
|
198
|
+
});
|
|
199
|
+
this._targetObjects = [];
|
|
186
200
|
}
|
|
187
201
|
|
|
188
202
|
play() {
|
|
@@ -243,6 +257,12 @@ export class VideoPlayer extends Behaviour {
|
|
|
243
257
|
this.handleBeginPlaying(playAutomatically);
|
|
244
258
|
}
|
|
245
259
|
|
|
260
|
+
private _targetObjects: Array<Object3D>;
|
|
261
|
+
|
|
262
|
+
getTargetObjects(): Array<Object3D> {
|
|
263
|
+
return Array.from(this._targetObjects);
|
|
264
|
+
}
|
|
265
|
+
|
|
246
266
|
private createVideoElement(): HTMLVideoElement {
|
|
247
267
|
const video = document.createElement("video") as HTMLVideoElement;
|
|
248
268
|
if (this._crossOrigin)
|
|
@@ -255,6 +275,8 @@ export class VideoPlayer extends Behaviour {
|
|
|
255
275
|
if (!this.enabled) return;
|
|
256
276
|
if (!this.videoElement) return;
|
|
257
277
|
|
|
278
|
+
this._targetObjects.length = 0;
|
|
279
|
+
|
|
258
280
|
let target: Object3D | undefined = this.gameObject;
|
|
259
281
|
|
|
260
282
|
switch (this.renderMode) {
|
|
@@ -272,6 +294,8 @@ export class VideoPlayer extends Behaviour {
|
|
|
272
294
|
}
|
|
273
295
|
const mat = target["material"];
|
|
274
296
|
if (mat) {
|
|
297
|
+
this._targetObjects.push(target);
|
|
298
|
+
|
|
275
299
|
if (mat !== this.videoMaterial) {
|
|
276
300
|
this.videoMaterial = mat.clone();
|
|
277
301
|
target["material"] = this.videoMaterial;
|
package/src/needle-engine.ts
CHANGED
|
@@ -5,6 +5,7 @@ import "./engine/engine_setup";
|
|
|
5
5
|
|
|
6
6
|
export { GameObject, Behaviour } from "./engine-components/Component";
|
|
7
7
|
export { serializeable } from "./engine/engine_serialization_decorator";
|
|
8
|
+
export { Collision } from "./engine/engine_physics";
|
|
8
9
|
export * from "./engine-components/codegen/exports";
|
|
9
10
|
|
|
10
11
|
|