@needle-tools/engine 3.2.3-alpha → 3.2.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/needle-engine.js +24012 -22890
- package/dist/needle-engine.min.js +363 -363
- package/dist/needle-engine.umd.cjs +369 -369
- package/lib/engine/api.d.ts +33 -11
- package/lib/engine/api.js +33 -11
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_addressables.d.ts +3 -3
- package/lib/engine/engine_addressables.js +0 -1
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_context.d.ts +11 -12
- package/lib/engine/engine_context.js +16 -17
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_fileloader.d.ts +2 -2
- package/lib/engine/engine_fileloader.js +2 -2
- package/lib/engine/engine_fileloader.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +8 -8
- package/lib/engine/engine_gameobject.js +1 -1
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gizmos.d.ts +2 -3
- package/lib/engine/engine_gizmos.js +3 -3
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js +4 -5
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_input.d.ts +7 -7
- package/lib/engine/engine_input.js +12 -12
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_license.js +2 -2
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.d.ts +1 -1
- package/lib/engine/engine_mainloop_utils.js +1 -1
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking_auto.d.ts +1 -1
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_networking_files.d.ts +4 -4
- package/lib/engine/engine_networking_files.js +4 -5
- package/lib/engine/engine_networking_files.js.map +1 -1
- package/lib/engine/engine_three_utils.d.ts +19 -19
- package/lib/engine/engine_three_utils.js +17 -18
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.d.ts +6 -5
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_lighting_settings.js +14 -6
- package/lib/engine/extensions/NEEDLE_lighting_settings.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +3 -4
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +25 -26
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine-components/Animation.d.ts +6 -7
- package/lib/engine-components/Animation.js +5 -6
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/Animator.d.ts +3 -4
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.js +3 -4
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioListener.d.ts +2 -2
- package/lib/engine-components/AudioListener.js +2 -2
- package/lib/engine-components/AudioListener.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +2 -2
- package/lib/engine-components/AudioSource.js +4 -4
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/AvatarLoader.d.ts +7 -7
- package/lib/engine-components/AvatarLoader.js +3 -4
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/AxesHelper.js.map +1 -1
- package/lib/engine-components/BasicIKConstraint.js +2 -2
- package/lib/engine-components/BasicIKConstraint.js.map +1 -1
- package/lib/engine-components/BoxHelperComponent.d.ts +5 -5
- package/lib/engine-components/BoxHelperComponent.js +6 -6
- package/lib/engine-components/BoxHelperComponent.js.map +1 -1
- package/lib/engine-components/Component.d.ts +45 -47
- package/lib/engine-components/Component.js +16 -17
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +3 -3
- package/lib/engine-components/DragControls.js +22 -24
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/api.d.ts +3 -0
- package/lib/engine-components/api.js +3 -0
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/ui/Utils.d.ts +4 -3
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/engine-components-experimental/api.d.ts +1 -0
- package/lib/engine-components-experimental/api.js +2 -0
- package/lib/engine-components-experimental/api.js.map +1 -0
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +2 -1
- package/lib/engine-components-experimental/networking/PlayerSync.js +18 -1
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/lib/needle-engine.d.ts +1 -5
- package/lib/needle-engine.js +4 -5
- package/lib/needle-engine.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/plugins/vite/license.js +2 -2
- package/src/engine/api.ts +39 -20
- package/src/engine/codegen/register_types.js +2 -2
- package/src/engine/engine_addressables.ts +6 -7
- package/src/engine/engine_context.ts +31 -28
- package/src/engine/engine_fileloader.js +2 -2
- package/src/engine/engine_gameobject.ts +21 -21
- package/src/engine/engine_gizmos.ts +5 -6
- package/src/engine/engine_gltf_builtin_components.ts +9 -10
- package/src/engine/engine_input.ts +17 -18
- package/src/engine/engine_license.ts +2 -2
- package/src/engine/engine_mainloop_utils.ts +5 -5
- package/src/engine/engine_networking_auto.ts +1 -1
- package/src/engine/engine_networking_files.ts +10 -11
- package/src/engine/engine_three_utils.ts +37 -37
- package/src/engine/extensions/NEEDLE_components.ts +7 -6
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +15 -6
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +29 -30
- package/src/engine-components/Animation.ts +17 -19
- package/src/engine-components/Animator.ts +4 -5
- package/src/engine-components/AnimatorController.ts +16 -17
- package/src/engine-components/AudioListener.ts +4 -4
- package/src/engine-components/AudioSource.ts +8 -8
- package/src/engine-components/AvatarLoader.ts +15 -16
- package/src/engine-components/AxesHelper.ts +1 -1
- package/src/engine-components/BasicIKConstraint.ts +2 -2
- package/src/engine-components/BoxHelperComponent.ts +13 -13
- package/src/engine-components/Component.ts +65 -68
- package/src/engine-components/DragControls.ts +42 -43
- package/src/engine-components/ParticleSystemModules.ts +1483 -1483
- package/src/engine-components/api.ts +3 -0
- package/src/engine-components/ui/Utils.ts +4 -4
- package/src/engine-components-experimental/api.ts +1 -0
- package/src/engine-components-experimental/networking/PlayerSync.ts +17 -4
- package/src/needle-engine.ts +5 -9
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Behaviour } from "./Component";
|
|
2
|
-
import
|
|
3
|
-
import { AnimationAction, AnimationClip, Vector2 } from "three";
|
|
2
|
+
import { AnimationAction, AnimationClip, AnimationMixer, LoopOnce, LoopRepeat } from "three";
|
|
4
3
|
import { MixerEvent } from "./Animator";
|
|
5
4
|
import { serializable } from "../engine/engine_serialization_decorator";
|
|
6
|
-
import { InstancingUtil } from "../engine/engine_instancing";
|
|
7
5
|
import { Mathf } from "../engine/engine_math";
|
|
8
6
|
import { Vec2 } from "../engine/engine_types";
|
|
9
7
|
import { getParam } from "../engine/engine_utils";
|
|
@@ -63,7 +61,7 @@ export class Animation extends Behaviour {
|
|
|
63
61
|
this.animations = animations;
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
set animations(animations:
|
|
64
|
+
set animations(animations: AnimationClip[]) {
|
|
67
65
|
if (debug) console.log("assign animations", animations);
|
|
68
66
|
this.gameObject.animations = animations;
|
|
69
67
|
}
|
|
@@ -74,29 +72,29 @@ export class Animation extends Behaviour {
|
|
|
74
72
|
/**
|
|
75
73
|
* @deprecated Currently unsupported
|
|
76
74
|
*/
|
|
77
|
-
get currentAction():
|
|
75
|
+
get currentAction(): AnimationAction | null {
|
|
78
76
|
return this._currentActions[0];
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
/**
|
|
82
80
|
* @deprecated Currently unsupported
|
|
83
81
|
*/
|
|
84
|
-
get currentActions():
|
|
82
|
+
get currentActions(): AnimationAction[] {
|
|
85
83
|
return this._currentActions;
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
private mixer:
|
|
89
|
-
get actions(): Array<
|
|
86
|
+
private mixer: AnimationMixer | undefined = undefined;
|
|
87
|
+
get actions(): Array<AnimationAction> {
|
|
90
88
|
return this._actions;
|
|
91
89
|
}
|
|
92
|
-
set actions(val: Array<
|
|
90
|
+
set actions(val: Array<AnimationAction>) {
|
|
93
91
|
this._actions = val;
|
|
94
92
|
}
|
|
95
|
-
private _actions: Array<
|
|
93
|
+
private _actions: Array<AnimationAction> = [];
|
|
96
94
|
|
|
97
|
-
// private _currentAction:
|
|
95
|
+
// private _currentAction: AnimationAction | null = null;
|
|
98
96
|
|
|
99
|
-
private _currentActions:
|
|
97
|
+
private _currentActions: AnimationAction[] = [];
|
|
100
98
|
private _handles: AnimationHandle[] = [];
|
|
101
99
|
|
|
102
100
|
awake() {
|
|
@@ -133,7 +131,7 @@ export class Animation extends Behaviour {
|
|
|
133
131
|
// InstancingUtil.markDirty(this.gameObject);
|
|
134
132
|
}
|
|
135
133
|
|
|
136
|
-
getAction(name: string):
|
|
134
|
+
getAction(name: string): AnimationAction | undefined | null {
|
|
137
135
|
return this.actions?.find(a => a.getClip().name === name);
|
|
138
136
|
}
|
|
139
137
|
|
|
@@ -210,8 +208,8 @@ export class Animation extends Behaviour {
|
|
|
210
208
|
if (options?.startTime !== undefined) action.time = options.startTime;
|
|
211
209
|
|
|
212
210
|
if (options?.loop !== undefined)
|
|
213
|
-
action.loop = options.loop ?
|
|
214
|
-
else action.loop =
|
|
211
|
+
action.loop = options.loop ? LoopRepeat : LoopOnce;
|
|
212
|
+
else action.loop = LoopOnce;
|
|
215
213
|
action.play();
|
|
216
214
|
if (debug)
|
|
217
215
|
console.log("PLAY", action.getClip().name, action)
|
|
@@ -239,14 +237,14 @@ export class Animation extends Behaviour {
|
|
|
239
237
|
this._didInit = true;
|
|
240
238
|
if (!this.gameObject) return;
|
|
241
239
|
this.actions = [];
|
|
242
|
-
this.mixer = new
|
|
240
|
+
this.mixer = new AnimationMixer(this.gameObject);
|
|
243
241
|
}
|
|
244
242
|
}
|
|
245
243
|
|
|
246
244
|
|
|
247
245
|
class AnimationHandle {
|
|
248
|
-
mixer:
|
|
249
|
-
action:
|
|
246
|
+
mixer: AnimationMixer;
|
|
247
|
+
action: AnimationAction;
|
|
250
248
|
promise: Promise<AnimationAction> | null = null;
|
|
251
249
|
resolve: Function | null = null;
|
|
252
250
|
reject: Function | null = null;
|
|
@@ -258,7 +256,7 @@ class AnimationHandle {
|
|
|
258
256
|
private _finishedCallback?: any;
|
|
259
257
|
private _resolvedOrRejectedCallback?: (AnimationHandle) => void;
|
|
260
258
|
|
|
261
|
-
constructor(action:
|
|
259
|
+
constructor(action: AnimationAction, mixer: AnimationMixer, opts?: PlayOptions, cb?: (handle: AnimationHandle) => void) {
|
|
262
260
|
this.action = action;
|
|
263
261
|
this.mixer = mixer;
|
|
264
262
|
this._resolvedOrRejectedCallback = cb;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Behaviour } from "./Component";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { getParam, deepClone } from "../engine/engine_utils";
|
|
2
|
+
import { AnimationActionLoopStyles, AnimationAction, AnimationMixer } from "three";
|
|
3
|
+
import { getParam } from "../engine/engine_utils";
|
|
5
4
|
import { AnimatorControllerModel } from "../engine/extensions/NEEDLE_animator_controller_model";
|
|
6
5
|
import { AnimatorController } from "./AnimatorController";
|
|
7
6
|
import { serializable } from "../engine/engine_serialization_decorator";
|
|
@@ -12,9 +11,9 @@ const debug = getParam("debuganimator");
|
|
|
12
11
|
|
|
13
12
|
export declare class MixerEvent {
|
|
14
13
|
type: string;
|
|
15
|
-
action:
|
|
14
|
+
action: AnimationAction;
|
|
16
15
|
loopDelta: number;
|
|
17
|
-
target:
|
|
16
|
+
target: AnimationMixer;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
export declare class PlayOptions {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Animator } from "./Animator";
|
|
2
2
|
import { AnimatorConditionMode, AnimatorControllerModel, AnimatorControllerParameterType, AnimatorStateInfo, Condition, createMotion, State, StateMachineBehaviour } from "../engine/extensions/NEEDLE_animator_controller_model";
|
|
3
|
-
import { AnimationAction, AnimationClip, AnimationMixer, AxesHelper, Euler, KeyframeTrack, LoopOnce,
|
|
3
|
+
import { AnimationAction, AnimationClip, AnimationMixer, AxesHelper, Euler, KeyframeTrack, LoopOnce, Object3D, Quaternion, Vector3 } from "three";
|
|
4
4
|
import { deepClone, getParam } from "../engine/engine_utils";
|
|
5
5
|
import { Context } from "../engine/engine_setup";
|
|
6
|
-
import * as THREE from "three";
|
|
7
6
|
import { TypeStore } from "../engine/engine_typestore";
|
|
8
7
|
import { assign } from "../engine/engine_serialization_core";
|
|
9
8
|
import { Mathf } from "../engine/engine_math";
|
|
@@ -110,7 +109,7 @@ export class AnimatorController {
|
|
|
110
109
|
get context(): Context | undefined | null { return this.animator?.context; }
|
|
111
110
|
|
|
112
111
|
|
|
113
|
-
// applyRootMotion(obj:
|
|
112
|
+
// applyRootMotion(obj: Object3D) {
|
|
114
113
|
// // this.internalApplyRootMotion(obj);
|
|
115
114
|
// }
|
|
116
115
|
|
|
@@ -160,7 +159,7 @@ export class AnimatorController {
|
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
|
|
163
|
-
private _mixer!:
|
|
162
|
+
private _mixer!: AnimationMixer;
|
|
164
163
|
private _activeState?: State;
|
|
165
164
|
|
|
166
165
|
constructor(model: AnimatorControllerModel) {
|
|
@@ -541,10 +540,10 @@ export class AnimatorController {
|
|
|
541
540
|
private rootMotionHandler?: RootMotionHandler;
|
|
542
541
|
|
|
543
542
|
|
|
544
|
-
// private findRootBone(obj:
|
|
543
|
+
// private findRootBone(obj: Object3D): Object3D | null {
|
|
545
544
|
// if (this.animationRoot) return this.animationRoot;
|
|
546
545
|
// if (obj.type === "Bone") {
|
|
547
|
-
// this.animationRoot = obj as
|
|
546
|
+
// this.animationRoot = obj as Bone;
|
|
548
547
|
// return this.animationRoot;
|
|
549
548
|
// }
|
|
550
549
|
// if (obj.children) {
|
|
@@ -601,16 +600,16 @@ class TrackEvaluationWrapper {
|
|
|
601
600
|
|
|
602
601
|
class RootMotionAction {
|
|
603
602
|
|
|
604
|
-
private static lastObjPosition: { [key: string]:
|
|
605
|
-
static lastObjRotation: { [key: string]:
|
|
603
|
+
private static lastObjPosition: { [key: string]: Vector3 } = {};
|
|
604
|
+
static lastObjRotation: { [key: string]: Quaternion } = {};
|
|
606
605
|
|
|
607
606
|
// we remove the first keyframe rotation from the space rotation when updating
|
|
608
|
-
private static firstKeyframeRotation: { [key: string]:
|
|
607
|
+
private static firstKeyframeRotation: { [key: string]: Quaternion } = {};
|
|
609
608
|
// this is used to rotate the space on clip end / start (so the transform direction is correct)
|
|
610
|
-
private static spaceRotation: { [key: string]:
|
|
611
|
-
private static effectiveSpaceRotation: { [key: string]:
|
|
609
|
+
private static spaceRotation: { [key: string]: Quaternion } = {};
|
|
610
|
+
private static effectiveSpaceRotation: { [key: string]: Quaternion } = {};
|
|
612
611
|
|
|
613
|
-
private static clipOffsetRotation: { [key: string]:
|
|
612
|
+
private static clipOffsetRotation: { [key: string]: Quaternion } = {};
|
|
614
613
|
|
|
615
614
|
|
|
616
615
|
set action(val: AnimationAction) {
|
|
@@ -631,14 +630,14 @@ class RootMotionAction {
|
|
|
631
630
|
positionChange: Vector3 = new Vector3();
|
|
632
631
|
rotationChange: Quaternion = new Quaternion();
|
|
633
632
|
|
|
634
|
-
constructor(context: Context, root:
|
|
633
|
+
constructor(context: Context, root: Object3D, clip: AnimationClip, positionTrack: KeyframeTrack | null, rotationTrack: KeyframeTrack | null) {
|
|
635
634
|
// console.log(this, positionTrack, rotationTrack);
|
|
636
635
|
this.context = context;
|
|
637
636
|
this.root = root;
|
|
638
637
|
this.clip = clip;
|
|
639
638
|
|
|
640
639
|
if (!RootMotionAction.firstKeyframeRotation[clip.uuid])
|
|
641
|
-
RootMotionAction.firstKeyframeRotation[clip.uuid] = new
|
|
640
|
+
RootMotionAction.firstKeyframeRotation[clip.uuid] = new Quaternion();
|
|
642
641
|
if (rotationTrack) {
|
|
643
642
|
const values = rotationTrack.values;
|
|
644
643
|
RootMotionAction.firstKeyframeRotation[clip.uuid]
|
|
@@ -672,7 +671,7 @@ class RootMotionAction {
|
|
|
672
671
|
|
|
673
672
|
if (debugRootMotion)
|
|
674
673
|
{
|
|
675
|
-
const euler = new
|
|
674
|
+
const euler = new Euler().setFromQuaternion(lastRotation);
|
|
676
675
|
console.log("START", this.clip.name, Mathf.toDegrees(euler.y));
|
|
677
676
|
}
|
|
678
677
|
}
|
|
@@ -799,13 +798,13 @@ class RootMotionHandler {
|
|
|
799
798
|
|
|
800
799
|
private controller: AnimatorController;
|
|
801
800
|
private handler: RootMotionAction[] = [];
|
|
802
|
-
private root!:
|
|
801
|
+
private root!: Object3D;
|
|
803
802
|
|
|
804
803
|
constructor(controller: AnimatorController) {
|
|
805
804
|
this.controller = controller;
|
|
806
805
|
}
|
|
807
806
|
|
|
808
|
-
createClip(mixer: AnimationMixer, root:
|
|
807
|
+
createClip(mixer: AnimationMixer, root: Object3D, clip: AnimationClip): AnimationAction {
|
|
809
808
|
this.root = root;
|
|
810
809
|
let rootName = "";
|
|
811
810
|
if (root && "name" in root) {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Behaviour, GameObject } from "./Component";
|
|
2
|
-
import
|
|
2
|
+
import { AudioListener as ThreeAudioListener } from "three";
|
|
3
3
|
import { AudioSource } from "./AudioSource";
|
|
4
4
|
import { Camera } from "./Camera";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export class AudioListener extends Behaviour {
|
|
8
8
|
|
|
9
|
-
get listener():
|
|
9
|
+
get listener(): ThreeAudioListener {
|
|
10
10
|
if (this._listener == null)
|
|
11
|
-
this._listener = new
|
|
11
|
+
this._listener = new ThreeAudioListener();
|
|
12
12
|
return this._listener;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
private _listener:
|
|
15
|
+
private _listener: ThreeAudioListener | null = null;
|
|
16
16
|
|
|
17
17
|
awake() {
|
|
18
18
|
AudioSource.registerWaitForAllowAudio(() => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Behaviour, GameObject } from "./Component";
|
|
2
|
-
import * as THREE from "three";
|
|
3
2
|
import { PositionalAudioHelper } from 'three/examples/jsm/helpers/PositionalAudioHelper.js';
|
|
4
3
|
import { AudioListener } from "./AudioListener";
|
|
5
4
|
import * as utils from "../engine/engine_utils";
|
|
6
5
|
import { serializable } from "../engine/engine_serialization_decorator";
|
|
7
|
-
import {
|
|
6
|
+
import { ApplicationEvents } from "../engine/engine_application";
|
|
7
|
+
import { AudioLoader, PositionalAudio } from "three";
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
const debug = utils.getParam("debugaudio");
|
|
@@ -146,20 +146,20 @@ export class AudioSource extends Behaviour {
|
|
|
146
146
|
playInBackground: boolean = true;
|
|
147
147
|
|
|
148
148
|
private _loop: boolean = false;
|
|
149
|
-
private sound:
|
|
149
|
+
private sound: PositionalAudio | null = null;
|
|
150
150
|
private helper: PositionalAudioHelper | null = null;
|
|
151
151
|
private wasPlaying = false;
|
|
152
|
-
private audioLoader:
|
|
152
|
+
private audioLoader: AudioLoader | null = null;
|
|
153
153
|
private shouldPlay: boolean = false;
|
|
154
154
|
// set this from audio context time, used to set clip offset when setting "time" property
|
|
155
155
|
// there is maybe a better way to set a audio clip current time?!
|
|
156
156
|
private _lastClipStartedLoading: string | null = null;
|
|
157
157
|
|
|
158
|
-
public get Sound():
|
|
158
|
+
public get Sound(): PositionalAudio | null {
|
|
159
159
|
if (!this.sound && AudioSource._userInteractionRegistered) {
|
|
160
160
|
const listener = GameObject.getComponent(this.context.mainCamera, AudioListener) ?? GameObject.findObjectOfType(AudioListener, this.context);
|
|
161
161
|
if (listener?.listener) {
|
|
162
|
-
this.sound = new
|
|
162
|
+
this.sound = new PositionalAudio(listener.listener);
|
|
163
163
|
this.gameObject.add(this.sound);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
@@ -170,7 +170,7 @@ export class AudioSource extends Behaviour {
|
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
awake() {
|
|
173
|
-
this.audioLoader = new
|
|
173
|
+
this.audioLoader = new AudioLoader();
|
|
174
174
|
if (this.playOnAwake) this.shouldPlay = true;
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -294,7 +294,7 @@ export class AudioSource extends Behaviour {
|
|
|
294
294
|
console.log(this.clip);
|
|
295
295
|
if (this.clip.endsWith(".mp3") || this.clip.endsWith(".wav")) {
|
|
296
296
|
if (!this.audioLoader)
|
|
297
|
-
this.audioLoader = new
|
|
297
|
+
this.audioLoader = new AudioLoader();
|
|
298
298
|
this.shouldPlay = true;
|
|
299
299
|
if (this._lastClipStartedLoading === this.clip) {
|
|
300
300
|
if (debug) console.log("Is currently loading:", this._lastClipStartedLoading, this)
|
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as THREE from "three";
|
|
1
|
+
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
3
2
|
import * as utils from "../engine/engine_utils"
|
|
4
|
-
// import * as object from "../engine/engine_gltf_builtin_components";
|
|
5
3
|
import * as loaders from "../engine/engine_loaders"
|
|
6
4
|
import { Context } from "../engine/engine_setup";
|
|
7
5
|
import { GameObject } from "./Component";
|
|
8
6
|
import { download_file } from "../engine/engine_web_api";
|
|
9
7
|
import { getLoader } from "../engine/engine_gltf";
|
|
10
8
|
import { InstantiateOptions } from "../engine/engine_gameobject";
|
|
9
|
+
import { Box3, Object3D, Vector3 } from "three";
|
|
11
10
|
|
|
12
11
|
const debug = utils.getParam("debugavatar");
|
|
13
12
|
|
|
14
13
|
export class AvatarModel {
|
|
15
|
-
root:
|
|
16
|
-
head:
|
|
17
|
-
leftHand:
|
|
18
|
-
rigthHand:
|
|
14
|
+
root: Object3D;
|
|
15
|
+
head: Object3D;
|
|
16
|
+
leftHand: Object3D | null;
|
|
17
|
+
rigthHand: Object3D | null;
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
get isValid(): boolean {
|
|
22
21
|
return this.head !== null && this.head !== undefined;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
constructor(root:
|
|
24
|
+
constructor(root: Object3D, head: Object3D, leftHand: Object3D | null, rigthHand: Object3D | null) {
|
|
26
25
|
this.root = root;
|
|
27
26
|
this.head = head;
|
|
28
27
|
this.leftHand = leftHand;
|
|
@@ -40,14 +39,14 @@ export class AvatarLoader {
|
|
|
40
39
|
// private loader: GLTFLoader | null;
|
|
41
40
|
// private avatarModelCache: Map<string, AvatarModel | null> = new Map<string, AvatarModel | null>();
|
|
42
41
|
|
|
43
|
-
public async getOrCreateNewAvatarInstance(context: Context, avatarId: string |
|
|
42
|
+
public async getOrCreateNewAvatarInstance(context: Context, avatarId: string | Object3D): Promise<AvatarModel | null> {
|
|
44
43
|
|
|
45
44
|
if (!avatarId) {
|
|
46
45
|
console.error("Can not create avatar: failed to provide id or root object");
|
|
47
46
|
return null;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
let root:
|
|
49
|
+
let root: Object3D | null = null;
|
|
51
50
|
if (typeof avatarId === "string") {
|
|
52
51
|
root = await this.loadAvatar(context, avatarId);
|
|
53
52
|
if (!root) {
|
|
@@ -77,7 +76,7 @@ export class AvatarLoader {
|
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
|
|
80
|
-
private async loadAvatar(context: Context, avatarId: string): Promise<
|
|
79
|
+
private async loadAvatar(context: Context, avatarId: string): Promise<Object3D | null> {
|
|
81
80
|
|
|
82
81
|
console.assert(avatarId !== undefined && avatarId !== null && typeof avatarId === "string", "Avatar id must not be null");
|
|
83
82
|
if (avatarId.length <= 0) return null;
|
|
@@ -146,9 +145,9 @@ export class AvatarLoader {
|
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
// TODO this should be burned to the ground once 🤞 we have proper extras that define object relations.
|
|
149
|
-
private findAvatar(obj:
|
|
148
|
+
private findAvatar(obj: Object3D): AvatarModel {
|
|
150
149
|
|
|
151
|
-
const root:
|
|
150
|
+
const root: Object3D = obj;
|
|
152
151
|
let searchIn = root;
|
|
153
152
|
// some GLTFs have a "scene" root it seems, others don't, we skip the root here if there's only one child
|
|
154
153
|
if (searchIn.children.length == 1)
|
|
@@ -163,8 +162,8 @@ export class AvatarLoader {
|
|
|
163
162
|
head = root;
|
|
164
163
|
|
|
165
164
|
// normalize size, if the object isn't properly setup the scale might be totally off
|
|
166
|
-
const boundsSize = new
|
|
167
|
-
new
|
|
165
|
+
const boundsSize = new Vector3();
|
|
166
|
+
new Box3().setFromObject(head).getSize(boundsSize);
|
|
168
167
|
const maxAxis = Math.max(boundsSize.x, boundsSize.y, boundsSize.z);
|
|
169
168
|
console.warn("[Custom Avatar] " + "Normalizing head scale, it's too big: " + maxAxis + " meters! Should be < 0.3m");
|
|
170
169
|
if (maxAxis > 0.3) {
|
|
@@ -177,7 +176,7 @@ export class AvatarLoader {
|
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
|
|
180
|
-
private findAvatarPart(obj:
|
|
179
|
+
private findAvatarPart(obj: Object3D, searchString: string[]): Object3D | null {
|
|
181
180
|
|
|
182
181
|
const name = obj.name.toLowerCase();
|
|
183
182
|
let matchesAll = true;
|
|
@@ -11,7 +11,7 @@ export class AxesHelper extends Behaviour {
|
|
|
11
11
|
@serializable()
|
|
12
12
|
public isGizmo:boolean = true;
|
|
13
13
|
|
|
14
|
-
private _axes:
|
|
14
|
+
private _axes: _AxesHelper | null = null;
|
|
15
15
|
|
|
16
16
|
onEnable(): void {
|
|
17
17
|
if (this.isGizmo && !params.showGizmos) return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Behaviour, GameObject } from "./Component";
|
|
2
2
|
import * as utils from "./../engine/engine_three_utils";
|
|
3
|
-
import
|
|
3
|
+
import { Vector3 } from "three";
|
|
4
4
|
|
|
5
5
|
export class BasicIKConstraint extends Behaviour {
|
|
6
6
|
|
|
@@ -33,7 +33,7 @@ export class BasicIKConstraint extends Behaviour {
|
|
|
33
33
|
let hintDir = utils.getWorldPosition(this.hint).clone();
|
|
34
34
|
hintDir.sub(center);
|
|
35
35
|
|
|
36
|
-
let offsetDir = new
|
|
36
|
+
let offsetDir = new Vector3();
|
|
37
37
|
offsetDir.crossVectors(hintDir, dir0);
|
|
38
38
|
offsetDir.crossVectors(dir0, offsetDir);
|
|
39
39
|
offsetDir.normalize();
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { Behaviour } from "./Component";
|
|
2
|
-
import * as THREE from "three";
|
|
3
2
|
import { getParam } from "../engine/engine_utils";
|
|
4
3
|
import { CreateWireCube, Gizmos } from "../engine/engine_gizmos";
|
|
5
4
|
import { getWorldPosition, getWorldScale } from "../engine/engine_three_utils";
|
|
5
|
+
import { Box3, Color, ColorRepresentation, LineSegments, Object3D, Vector3 } from "three";
|
|
6
6
|
|
|
7
7
|
const gizmos = getParam("gizmos");
|
|
8
8
|
const debug = getParam("debugboxhelper");
|
|
9
9
|
|
|
10
10
|
export class BoxHelperComponent extends Behaviour {
|
|
11
11
|
|
|
12
|
-
private box:
|
|
13
|
-
private static testBox:
|
|
12
|
+
private box: Box3 | null = null;
|
|
13
|
+
private static testBox: Box3 = new Box3();
|
|
14
14
|
private _lastMatrixUpdateFrame: number = -1;
|
|
15
|
-
private static _position:
|
|
16
|
-
private static _size:
|
|
15
|
+
private static _position: Vector3 = new Vector3();
|
|
16
|
+
private static _size: Vector3 = new Vector3(.01, .01, .01);
|
|
17
17
|
|
|
18
|
-
public isInBox(obj:
|
|
18
|
+
public isInBox(obj: Object3D, scaleFactor?: number): boolean | undefined {
|
|
19
19
|
if (!obj) return undefined;
|
|
20
20
|
|
|
21
21
|
// if (!obj.geometry.boundingBox) obj.geometry.computeBoundingBox();
|
|
22
22
|
// if (!obj.geometry.boundingBox) return undefined;
|
|
23
23
|
|
|
24
24
|
if (!this.box) {
|
|
25
|
-
this.box = new
|
|
25
|
+
this.box = new Box3();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
|
|
@@ -56,14 +56,14 @@ export class BoxHelperComponent extends Behaviour {
|
|
|
56
56
|
return intersects;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
public intersects(box:
|
|
59
|
+
public intersects(box: Box3): boolean {
|
|
60
60
|
if (!box) return false;
|
|
61
61
|
return this.updateBox(false).intersectsBox(box);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
public updateBox(force: boolean = false):
|
|
64
|
+
public updateBox(force: boolean = false): Box3 {
|
|
65
65
|
if (!this.box) {
|
|
66
|
-
this.box = new
|
|
66
|
+
this.box = new Box3();
|
|
67
67
|
}
|
|
68
68
|
if (force || this.context.time.frameCount != this._lastMatrixUpdateFrame) {
|
|
69
69
|
const firstUpdate = this._lastMatrixUpdateFrame < 0;
|
|
@@ -77,8 +77,8 @@ export class BoxHelperComponent extends Behaviour {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
private _helper:
|
|
81
|
-
private _color:
|
|
80
|
+
private _helper: LineSegments | null = null;
|
|
81
|
+
private _color: Color | null = null;
|
|
82
82
|
|
|
83
83
|
awake(): void {
|
|
84
84
|
this._helper = null;
|
|
@@ -86,7 +86,7 @@ export class BoxHelperComponent extends Behaviour {
|
|
|
86
86
|
this.box = null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
public showHelper(col:
|
|
89
|
+
public showHelper(col: ColorRepresentation | null = null, force: boolean = false) {
|
|
90
90
|
if (!gizmos && !force) return;
|
|
91
91
|
if (this._helper) {
|
|
92
92
|
if (col)
|