@needle-tools/engine 3.3.0-alpha → 3.5.0-alpha
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 +19 -0
- package/dist/needle-engine.js +62620 -61118
- package/dist/needle-engine.min.js +434 -410
- package/dist/needle-engine.umd.cjs +435 -411
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +50 -2
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_context.d.ts +1 -1
- package/lib/engine/engine_context.js +21 -15
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_context_registry.d.ts +5 -3
- package/lib/engine/engine_context_registry.js +10 -2
- package/lib/engine/engine_context_registry.js.map +1 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.js +2 -3
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +1 -1
- package/lib/engine/engine_gameobject.js +4 -2
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_input.d.ts +2 -2
- package/lib/engine/engine_physics.d.ts +20 -93
- package/lib/engine/engine_physics.js +20 -892
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics.types.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +103 -0
- package/lib/engine/engine_physics_rapier.js +1003 -0
- package/lib/engine/engine_physics_rapier.js.map +1 -0
- package/lib/engine/engine_three_utils.js +2 -2
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_types.d.ts +50 -1
- package/lib/engine/engine_types.js +8 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine-components/Animation.js +4 -0
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/Collider.js +6 -6
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Joints.js +2 -2
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +0 -1
- package/lib/engine-components/RigidBody.js +24 -30
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +25 -1
- package/lib/engine-components/codegen/components.js +25 -1
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/Extension.d.ts +4 -4
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +86 -0
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +858 -0
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -0
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +6 -3
- package/lib/engine-components/export/usdz/USDZExporter.js +34 -11
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/Animation.d.ts +15 -15
- package/lib/engine-components/export/usdz/extensions/Animation.js +24 -29
- package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.d.ts +5 -0
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.js +7 -0
- package/lib/engine-components/export/usdz/extensions/DocumentExtension.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/USDZText.d.ts +47 -0
- package/lib/engine-components/export/usdz/extensions/USDZText.js +114 -0
- package/lib/engine-components/export/usdz/extensions/USDZText.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.d.ts +30 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.js +89 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Actions.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +23 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +114 -0
- package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +102 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +458 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.d.ts +111 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js +409 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/ui/BaseUIComponent.d.ts +2 -0
- package/lib/engine-components/ui/BaseUIComponent.js +6 -0
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +11 -1
- package/lib/engine-components/ui/Canvas.js +72 -3
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Image.js +4 -4
- package/lib/engine-components/ui/Image.js.map +1 -1
- package/lib/engine-components/ui/Interfaces.d.ts +11 -0
- package/lib/engine-components/ui/Interfaces.js +11 -0
- package/lib/engine-components/ui/Interfaces.js.map +1 -1
- package/lib/engine-components/ui/Layout.d.ts +65 -3
- package/lib/engine-components/ui/Layout.js +304 -3
- package/lib/engine-components/ui/Layout.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.d.ts +8 -7
- package/lib/engine-components/ui/RectTransform.js +66 -36
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/lib/engine-components/utils/LookAt.d.ts +7 -1
- package/lib/engine-components/utils/LookAt.js +43 -6
- package/lib/engine-components/utils/LookAt.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +4 -3
- package/lib/engine-components/webxr/WebXRImageTracking.js +81 -25
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/plugins/vite/config.js +2 -1
- package/plugins/vite/defines.js +30 -0
- package/plugins/vite/dependency-watcher.js +173 -0
- package/plugins/vite/editor-connection.js +37 -39
- package/plugins/vite/index.js +5 -1
- package/plugins/vite/reload.js +16 -3
- package/src/engine/api.ts +1 -0
- package/src/engine/codegen/register_types.js +50 -2
- package/src/engine/engine_context.ts +32 -23
- package/src/engine/engine_context_registry.ts +13 -6
- package/src/engine/engine_element.ts +2 -1
- package/src/engine/engine_element_loading.ts +2 -3
- package/src/engine/engine_gameobject.ts +3 -2
- package/src/engine/engine_input.ts +2 -2
- package/src/engine/engine_physics.ts +25 -1020
- package/src/engine/engine_physics.types.ts +1 -3
- package/src/engine/engine_physics_rapier.ts +1127 -0
- package/src/engine/engine_three_utils.ts +2 -2
- package/src/engine/engine_types.ts +66 -4
- package/src/engine-components/Animation.ts +4 -0
- package/src/engine-components/Collider.ts +6 -6
- package/src/engine-components/Joints.ts +2 -2
- package/src/engine-components/RigidBody.ts +24 -31
- package/src/engine-components/codegen/components.ts +25 -1
- package/src/engine-components/export/usdz/Extension.ts +4 -5
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +1312 -0
- package/src/engine-components/export/usdz/USDZExporter.ts +39 -17
- package/src/engine-components/export/usdz/extensions/Animation.ts +37 -45
- package/src/engine-components/export/usdz/extensions/DocumentExtension.ts +10 -0
- package/src/engine-components/export/usdz/extensions/USDZText.ts +142 -0
- package/src/engine-components/export/usdz/extensions/behavior/Actions.ts +99 -0
- package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +181 -0
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +545 -0
- package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +459 -0
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
- package/src/engine-components/ui/BaseUIComponent.ts +7 -1
- package/src/engine-components/ui/Canvas.ts +80 -5
- package/src/engine-components/ui/Graphic.ts +2 -0
- package/src/engine-components/ui/Image.ts +3 -3
- package/src/engine-components/ui/Interfaces.ts +30 -6
- package/src/engine-components/ui/Layout.ts +303 -4
- package/src/engine-components/ui/RectTransform.ts +67 -41
- package/src/engine-components/utils/LookAt.ts +60 -7
- package/src/engine-components/webxr/WebXRImageTracking.ts +100 -27
- package/lib/engine-components/export/usdz/types.d.ts +0 -34
- package/lib/engine-components/export/usdz/types.js +0 -2
- package/lib/engine-components/export/usdz/types.js.map +0 -1
- package/src/engine-components/export/usdz/types.ts +0 -39
|
@@ -98,8 +98,8 @@ export function setWorldScale(obj: Object3D, vec: Vector3) {
|
|
|
98
98
|
const tempVec = _worldScale2;
|
|
99
99
|
const obj2 = obj.parent;
|
|
100
100
|
obj2.getWorldScale(tempVec);
|
|
101
|
-
|
|
102
|
-
obj.scale.
|
|
101
|
+
obj.scale.copy(vec);
|
|
102
|
+
obj.scale.divide(tempVec);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const _forward = new Vector3();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RenderTexture } from "./engine_texture";
|
|
2
|
-
import { Camera, Color, Material, Object3D, Vector3, Quaternion, Ray, Scene, Renderer, WebGLRenderer } from "three";
|
|
2
|
+
import { Camera, Color, Material, Object3D, Vector3, Quaternion, Ray, Scene, Renderer, WebGLRenderer, Mesh } from "three";
|
|
3
3
|
import { RGBAColor } from "../engine-components/js-extensions/RGBAColor";
|
|
4
4
|
import { CollisionDetectionMode, PhysicsMaterial, RigidbodyConstraints } from "./engine_physics.types";
|
|
5
5
|
import { CircularBuffer } from "./engine_utils";
|
|
@@ -20,7 +20,6 @@ export interface UIDProvider {
|
|
|
20
20
|
generateUUID(): string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
export declare type CoroutineData = {
|
|
25
24
|
comp: IComponent,
|
|
26
25
|
main: Generator,
|
|
@@ -31,9 +30,17 @@ export interface ITime {
|
|
|
31
30
|
get time(): number;
|
|
32
31
|
}
|
|
33
32
|
|
|
33
|
+
export interface IInput {
|
|
34
|
+
convertScreenspaceToRaycastSpace(vec: Vec2): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface IPhysics {
|
|
38
|
+
engine?: IPhysicsEngine;
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
export interface IContext {
|
|
35
42
|
alias?: string | null;
|
|
36
|
-
hash?:string;
|
|
43
|
+
hash?: string;
|
|
37
44
|
|
|
38
45
|
scene: Scene;
|
|
39
46
|
renderer: WebGLRenderer;
|
|
@@ -42,6 +49,8 @@ export interface IContext {
|
|
|
42
49
|
domElement: HTMLElement;
|
|
43
50
|
|
|
44
51
|
time: ITime;
|
|
52
|
+
input: IInput;
|
|
53
|
+
physics: IPhysics;
|
|
45
54
|
|
|
46
55
|
scripts: IComponent[];
|
|
47
56
|
scripts_pausedChanged: IComponent[];
|
|
@@ -343,4 +352,57 @@ export class Collision {
|
|
|
343
352
|
// }
|
|
344
353
|
// return this._point;
|
|
345
354
|
// }
|
|
346
|
-
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export type RaycastResult = null | { point: Vector3, collider: ICollider, normal?: Vector3 };
|
|
358
|
+
|
|
359
|
+
export class SphereOverlapResult {
|
|
360
|
+
object: Object3D;
|
|
361
|
+
collider: ICollider;
|
|
362
|
+
constructor(object: Object3D, collider: ICollider) {
|
|
363
|
+
this.object = object;
|
|
364
|
+
this.collider = collider;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
export interface IPhysicsEngine {
|
|
370
|
+
initialize(ctx: IContext): Promise<boolean>;
|
|
371
|
+
step(dt: number): void;
|
|
372
|
+
postStep();
|
|
373
|
+
get isUpdating(): boolean;
|
|
374
|
+
/** clear all possibly cached data (e.g. mesh data when creating scaled mesh colliders) */
|
|
375
|
+
clearCaches();
|
|
376
|
+
|
|
377
|
+
// raycasting
|
|
378
|
+
/** fast raycast without getting the normal vector */
|
|
379
|
+
raycast(origin: Vec2 | Vec3, direction: Vec3 | undefined, maxDistance: number, solid: boolean): RaycastResult;
|
|
380
|
+
/** raycast that also gets the normal vector. If you don't need it use raycast() */
|
|
381
|
+
raycastAndGetNormal(origin: Vec2 | Vec3, direction: Vec3 | undefined, maxDistance: number, solid: boolean) : RaycastResult;
|
|
382
|
+
sphereOverlap(point: Vector3, radius: number): Array<SphereOverlapResult>;
|
|
383
|
+
|
|
384
|
+
// Collider methods
|
|
385
|
+
addSphereCollider(collider: ICollider, center: Vector3, radius: number);
|
|
386
|
+
addBoxCollider(collider: ICollider, center: Vector3, size: Vector3);
|
|
387
|
+
addCapsuleCollider(collider: ICollider, center: Vector3, radius: number, height: number);
|
|
388
|
+
addMeshCollider(collider: ICollider, mesh: Mesh, convex: boolean, scale: Vector3);
|
|
389
|
+
|
|
390
|
+
// Rigidbody methods
|
|
391
|
+
wakeup(rb: IRigidbody);
|
|
392
|
+
updateProperties(rb: IRigidbody);
|
|
393
|
+
resetForces(rb: IRigidbody, wakeup: boolean);
|
|
394
|
+
resetTorques(rb: IRigidbody, wakeup: boolean);
|
|
395
|
+
addForce(rb: IRigidbody, vec: Vec3, wakeup: boolean);
|
|
396
|
+
applyImpulse(rb: IRigidbody, vec: Vec3, wakeup: boolean);
|
|
397
|
+
getLinearVelocity(rb: IRigidbody): Vec3 | null;
|
|
398
|
+
getAngularVelocity(rb: IRigidbody): Vec3 | null;
|
|
399
|
+
setAngularVelocity(rb: IRigidbody, vec: Vec3, wakeup: boolean);
|
|
400
|
+
setLinearVelocity(rb: IRigidbody, vec: Vec3, wakeup: boolean);
|
|
401
|
+
|
|
402
|
+
updateBody(comp: ICollider | IRigidbody, translation: boolean, rotation: boolean);
|
|
403
|
+
removeBody(body: IComponent);
|
|
404
|
+
|
|
405
|
+
// Joints
|
|
406
|
+
addFixedJoint(body1: IRigidbody, body2: IRigidbody)
|
|
407
|
+
addHingeJoint(body1: IRigidbody, body2: IRigidbody, anchor: Vec3, axis: Vec3)
|
|
408
|
+
}
|
|
@@ -176,6 +176,10 @@ export class Animation extends Behaviour {
|
|
|
176
176
|
return this.internalOnPlay(act, options);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
+
if (!(clip instanceof AnimationClip)) {
|
|
180
|
+
console.warn("Clip is no AnimationClip", clip, "on object: " + this.name)
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
179
183
|
const act = this.mixer.clipAction(clip);
|
|
180
184
|
this.actions.push(act);
|
|
181
185
|
return this.internalOnPlay(act, options);
|
|
@@ -40,7 +40,7 @@ export class Collider extends Behaviour implements ICollider {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
onDisable() {
|
|
43
|
-
this.context.physics.removeBody(this);
|
|
43
|
+
this.context.physics.engine?.removeBody(this);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
}
|
|
@@ -55,7 +55,7 @@ export class SphereCollider extends Collider {
|
|
|
55
55
|
|
|
56
56
|
onEnable() {
|
|
57
57
|
super.onEnable();
|
|
58
|
-
this.context.physics.addSphereCollider(this, this.center, this.radius);
|
|
58
|
+
this.context.physics.engine?.addSphereCollider(this, this.center, this.radius);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -68,7 +68,7 @@ export class BoxCollider extends Collider {
|
|
|
68
68
|
|
|
69
69
|
onEnable() {
|
|
70
70
|
super.onEnable();
|
|
71
|
-
this.context.physics.addBoxCollider(this, this.center, this.size);
|
|
71
|
+
this.context.physics.engine?.addBoxCollider(this, this.center, this.size);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -90,7 +90,7 @@ export class MeshCollider extends Collider {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
if (this.sharedMesh?.isMesh) {
|
|
93
|
-
this.context.physics.addMeshCollider(this, this.sharedMesh, this.convex, getWorldScale(this.gameObject));
|
|
93
|
+
this.context.physics.engine?.addMeshCollider(this, this.sharedMesh, this.convex, getWorldScale(this.gameObject));
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
96
96
|
const group = this.sharedMesh as any as Group;
|
|
@@ -99,7 +99,7 @@ export class MeshCollider extends Collider {
|
|
|
99
99
|
for (const ch in group.children) {
|
|
100
100
|
const child = group.children[ch] as Mesh;
|
|
101
101
|
if (child.isMesh) {
|
|
102
|
-
this.context.physics.addMeshCollider(this, child, this.convex, getWorldScale(this.gameObject));
|
|
102
|
+
this.context.physics.engine?.addMeshCollider(this, child, this.convex, getWorldScale(this.gameObject));
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -119,7 +119,7 @@ export class CapsuleCollider extends Collider {
|
|
|
119
119
|
|
|
120
120
|
onEnable() {
|
|
121
121
|
super.onEnable();
|
|
122
|
-
this.context.physics.addCapsuleCollider(this, this.center, this.height, this.radius);
|
|
122
|
+
this.context.physics.engine?.addCapsuleCollider(this, this.center, this.height, this.radius);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
}
|
|
@@ -32,7 +32,7 @@ export abstract class Joint extends Behaviour {
|
|
|
32
32
|
export class FixedJoint extends Joint {
|
|
33
33
|
|
|
34
34
|
protected createJoint(self: Rigidbody, other: Rigidbody) {
|
|
35
|
-
this.context.physics.addFixedJoint(self, other);
|
|
35
|
+
this.context.physics.engine?.addFixedJoint(self, other);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -46,7 +46,7 @@ export class HingeJoint extends Joint {
|
|
|
46
46
|
|
|
47
47
|
protected createJoint(self: Rigidbody, other: Rigidbody) {
|
|
48
48
|
if (this.axis && this.anchor)
|
|
49
|
-
this.context.physics.addHingeJoint(self, other, this.anchor, this.axis);
|
|
49
|
+
this.context.physics.engine?.addHingeJoint(self, other, this.anchor, this.axis);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
}
|
|
@@ -89,7 +89,7 @@ class TransformWatch {
|
|
|
89
89
|
this.position = {};
|
|
90
90
|
// this.position = this.obj.position.clone();
|
|
91
91
|
this._positionWatch.subscribeWrite((val, prop) => {
|
|
92
|
-
if (this.context.physics.isUpdating || this.mute) return;
|
|
92
|
+
if (this.context.physics.engine?.isUpdating || this.mute) return;
|
|
93
93
|
const prev = this.position![prop];
|
|
94
94
|
if (Math.abs(prev - val) < .00001) return;
|
|
95
95
|
this.position![prop] = val;
|
|
@@ -103,7 +103,7 @@ class TransformWatch {
|
|
|
103
103
|
this.quaternion = {};
|
|
104
104
|
// this.quaternion = this.obj.quaternion.clone();
|
|
105
105
|
this._rotationWatch.subscribeWrite((val, prop) => {
|
|
106
|
-
if (this.context.physics.isUpdating || this.mute) return;
|
|
106
|
+
if (this.context.physics.engine?.isUpdating || this.mute) return;
|
|
107
107
|
const prev = this.quaternion![prop];
|
|
108
108
|
if (Math.abs(prev - val) < .00001) return;
|
|
109
109
|
this.quaternion![prop] = val;
|
|
@@ -245,11 +245,11 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
245
245
|
|
|
246
246
|
onDisable() {
|
|
247
247
|
this._watch?.stop();
|
|
248
|
-
this.context.physics.removeBody(this);
|
|
248
|
+
this.context.physics.engine?.removeBody(this);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
onDestroy(): void {
|
|
252
|
-
this.context.physics.removeBody(this);
|
|
252
|
+
this.context.physics.engine?.removeBody(this);
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
onValidate() {
|
|
@@ -261,12 +261,12 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
261
261
|
while (true) {
|
|
262
262
|
if (this._propertiesChanged) {
|
|
263
263
|
this._propertiesChanged = false;
|
|
264
|
-
this.context.physics.updateProperties(this);
|
|
264
|
+
this.context.physics.engine?.updateProperties(this);
|
|
265
265
|
}
|
|
266
266
|
if (this._watch?.isDirty) {
|
|
267
267
|
this._watch.mute = true;
|
|
268
268
|
this._watch.applyValues();
|
|
269
|
-
this.context.physics.updateBody(this, this._watch.positionChanged, this._watch.rotationChanged);
|
|
269
|
+
this.context.physics.engine?.updateBody(this, this._watch.positionChanged, this._watch.rotationChanged);
|
|
270
270
|
this._watch.reset();
|
|
271
271
|
}
|
|
272
272
|
else this._watch?.syncValues();
|
|
@@ -275,10 +275,6 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
private get body() {
|
|
279
|
-
return this.context.physics.internal_getRigidbody(this);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
278
|
public teleport(pt: { x: number, y: number, z: number }, localspace: boolean = true) {
|
|
283
279
|
this._watch?.reset(true);
|
|
284
280
|
if (localspace) this.gameObject.position.set(pt.x, pt.y, pt.z);
|
|
@@ -288,11 +284,11 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
288
284
|
}
|
|
289
285
|
|
|
290
286
|
public resetForces() {
|
|
291
|
-
this.
|
|
287
|
+
this.context.physics.engine?.resetForces(this, true);
|
|
292
288
|
}
|
|
293
289
|
|
|
294
290
|
public resetTorques() {
|
|
295
|
-
this.
|
|
291
|
+
this.context.physics.engine?.resetTorques(this, true);
|
|
296
292
|
}
|
|
297
293
|
|
|
298
294
|
public resetVelocities() {
|
|
@@ -306,24 +302,24 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
306
302
|
}
|
|
307
303
|
|
|
308
304
|
public wakeUp() {
|
|
309
|
-
this.
|
|
305
|
+
this.context.physics.engine?.wakeup(this);
|
|
310
306
|
}
|
|
311
307
|
|
|
312
308
|
public applyForce(vec: Vector3, _rel?: THREE.Vector3) {
|
|
313
|
-
this.
|
|
309
|
+
this.context.physics.engine?.addForce(this, vec, true);
|
|
314
310
|
}
|
|
315
311
|
|
|
316
312
|
public applyImpulse(vec: Vector3) {
|
|
317
|
-
this.
|
|
313
|
+
this.context.physics.engine?.applyImpulse(this, vec, true);
|
|
318
314
|
}
|
|
319
315
|
|
|
320
316
|
public setForce(x: number, y: number, z: number) {
|
|
321
|
-
this.
|
|
322
|
-
this.
|
|
317
|
+
this.context.physics.engine?.resetForces(this, true);
|
|
318
|
+
this.context.physics.engine?.addForce(this, { x, y, z }, true);
|
|
323
319
|
}
|
|
324
320
|
|
|
325
321
|
public getVelocity(): Vector3 {
|
|
326
|
-
const vel = this.
|
|
322
|
+
const vel = this.context.physics.engine?.getLinearVelocity(this);
|
|
327
323
|
if (!vel) return this._currentVelocity.set(0, 0, 0);
|
|
328
324
|
this._currentVelocity.x = vel.x;
|
|
329
325
|
this._currentVelocity.y = vel.y;
|
|
@@ -334,25 +330,25 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
334
330
|
public setVelocity(x: number | Vector3, y?: number, z?: number) {
|
|
335
331
|
if (x instanceof Vector3) {
|
|
336
332
|
const vec = x;
|
|
337
|
-
this.
|
|
333
|
+
this.context.physics.engine?.setLinearVelocity(this,vec, true);
|
|
338
334
|
return;
|
|
339
335
|
}
|
|
340
336
|
if (y === undefined || z === undefined) return;
|
|
341
|
-
this.
|
|
337
|
+
this.context.physics.engine?.setLinearVelocity(this, { x: x, y: y, z: z }, true);
|
|
342
338
|
}
|
|
343
339
|
|
|
344
340
|
public setAngularVelocity(x: number | Vector3, y?: number, z?: number) {
|
|
345
341
|
if (x instanceof Vector3) {
|
|
346
342
|
const vec = x;
|
|
347
|
-
this.
|
|
343
|
+
this.context.physics.engine?.setAngularVelocity(this, vec, true);
|
|
348
344
|
return;
|
|
349
345
|
}
|
|
350
346
|
if (y === undefined || z === undefined) return;
|
|
351
|
-
this.
|
|
347
|
+
this.context.physics.engine?.setAngularVelocity(this, { x: x, y: y, z: z }, true);
|
|
352
348
|
}
|
|
353
349
|
|
|
354
350
|
public getAngularVelocity(): Vector3 {
|
|
355
|
-
const vel = this.
|
|
351
|
+
const vel = this.context.physics.engine?.getAngularVelocity(this);
|
|
356
352
|
if (!vel) return this._currentVelocity.set(0, 0, 0);
|
|
357
353
|
this._currentVelocity.x = vel.x;
|
|
358
354
|
this._currentVelocity.y = vel.y;
|
|
@@ -381,13 +377,10 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
381
377
|
|
|
382
378
|
|
|
383
379
|
private captureVelocity() {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
this._smoothedVelocity.lerp(vel, this.context.time.deltaTime / .1);
|
|
390
|
-
// this._smoothedVelocity.set(0, 1 / this.context.time.deltaTime, 0);
|
|
391
|
-
}
|
|
380
|
+
const wp = getWorldPosition(this.gameObject);
|
|
381
|
+
Rigidbody.tempPosition.copy(wp);
|
|
382
|
+
const vel = wp.sub(this._lastPosition);
|
|
383
|
+
this._lastPosition.copy(Rigidbody.tempPosition);
|
|
384
|
+
this._smoothedVelocity.lerp(vel, this.context.time.deltaTime / .1);
|
|
392
385
|
}
|
|
393
386
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// Export types
|
|
2
2
|
export class __Ignore {}
|
|
3
|
+
export { ActionBuilder } from "../export/usdz/extensions/behavior/BehavioursBuilder";
|
|
4
|
+
export { ActionCollection } from "../export/usdz/extensions/behavior/Actions";
|
|
5
|
+
export { ActionModel } from "../export/usdz/extensions/behavior/BehavioursBuilder";
|
|
3
6
|
export { AlignmentConstraint } from "../AlignmentConstraint";
|
|
4
7
|
export { Animation } from "../Animation";
|
|
5
8
|
export { AnimationCurve } from "../AnimationCurve";
|
|
@@ -24,6 +27,8 @@ export { AvatarModel } from "../AvatarLoader";
|
|
|
24
27
|
export { AxesHelper } from "../AxesHelper";
|
|
25
28
|
export { BaseUIComponent } from "../ui/BaseUIComponent";
|
|
26
29
|
export { BasicIKConstraint } from "../BasicIKConstraint";
|
|
30
|
+
export { BehaviorExtension } from "../export/usdz/extensions/behavior/Behaviour";
|
|
31
|
+
export { BehaviorModel } from "../export/usdz/extensions/behavior/BehavioursBuilder";
|
|
27
32
|
export { Behaviour } from "../Component";
|
|
28
33
|
export { Bloom } from "../postprocessing/Effects/Bloom";
|
|
29
34
|
export { BoxCollider } from "../Collider";
|
|
@@ -35,6 +40,8 @@ export { Camera } from "../Camera";
|
|
|
35
40
|
export { Canvas } from "../ui/Canvas";
|
|
36
41
|
export { CanvasGroup } from "../ui/CanvasGroup";
|
|
37
42
|
export { CapsuleCollider } from "../Collider";
|
|
43
|
+
export { ChangeMaterialOnClick } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
44
|
+
export { ChangeTransformOnClick } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
38
45
|
export { CharacterController } from "../CharacterController";
|
|
39
46
|
export { CharacterControllerInput } from "../CharacterController";
|
|
40
47
|
export { ChromaticAberration } from "../postprocessing/Effects/ChromaticAberration";
|
|
@@ -48,10 +55,12 @@ export { Deletable } from "../DeleteBox";
|
|
|
48
55
|
export { DeleteBox } from "../DeleteBox";
|
|
49
56
|
export { DepthOfField } from "../postprocessing/Effects/DepthOfField";
|
|
50
57
|
export { DeviceFlag } from "../DeviceFlag";
|
|
58
|
+
export { DocumentExtension } from "../export/usdz/extensions/DocumentExtension";
|
|
51
59
|
export { DragControls } from "../DragControls";
|
|
52
60
|
export { DropListener } from "../DropListener";
|
|
53
61
|
export { Duplicatable } from "../Duplicatable";
|
|
54
62
|
export { EmissionModule } from "../ParticleSystemModules";
|
|
63
|
+
export { EmphasizeOnClick } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
55
64
|
export { EventList } from "../EventList";
|
|
56
65
|
export { EventListEvent } from "../EventList";
|
|
57
66
|
export { EventSystem } from "../ui/EventSystem";
|
|
@@ -68,13 +77,14 @@ export { GraphicRaycaster } from "../ui/Raycaster";
|
|
|
68
77
|
export { GridHelper } from "../GridHelper";
|
|
69
78
|
export { GridLayoutGroup } from "../ui/Layout";
|
|
70
79
|
export { GroundProjectedEnv } from "../GroundProjection";
|
|
80
|
+
export { GroupActionModel } from "../export/usdz/extensions/behavior/BehavioursBuilder";
|
|
81
|
+
export { HideOnStart } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
71
82
|
export { HingeJoint } from "../Joints";
|
|
72
83
|
export { HorizontalLayoutGroup } from "../ui/Layout";
|
|
73
84
|
export { Image } from "../ui/Image";
|
|
74
85
|
export { InheritVelocityModule } from "../ParticleSystemModules";
|
|
75
86
|
export { InputField } from "../ui/InputField";
|
|
76
87
|
export { Interactable } from "../Interactable";
|
|
77
|
-
export { LayoutGroup } from "../ui/Layout";
|
|
78
88
|
export { Light } from "../Light";
|
|
79
89
|
export { LimitVelocityOverLifetimeModule } from "../ParticleSystemModules";
|
|
80
90
|
export { LODGroup } from "../LODGroup";
|
|
@@ -96,15 +106,19 @@ export { OffsetConstraint } from "../OffsetConstraint";
|
|
|
96
106
|
export { OpenURL } from "../utils/OpenURL";
|
|
97
107
|
export { OrbitControls } from "../OrbitControls";
|
|
98
108
|
export { Outline } from "../ui/Outline";
|
|
109
|
+
export { Padding } from "../ui/Layout";
|
|
99
110
|
export { ParticleBurst } from "../ParticleSystemModules";
|
|
100
111
|
export { ParticleSubEmitter } from "../ParticleSystemSubEmitter";
|
|
101
112
|
export { ParticleSystem } from "../ParticleSystem";
|
|
102
113
|
export { ParticleSystemRenderer } from "../ParticleSystem";
|
|
103
114
|
export { PixelationEffect } from "../postprocessing/Effects/Pixelation";
|
|
104
115
|
export { PlayableDirector } from "../timeline/PlayableDirector";
|
|
116
|
+
export { PlayAnimationOnClick } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
105
117
|
export { PlayerColor } from "../PlayerColor";
|
|
106
118
|
export { PointerEventData } from "../ui/PointerEvents";
|
|
107
119
|
export { PostProcessingHandler } from "../postprocessing/PostProcessingHandler";
|
|
120
|
+
export { PreliminaryAction } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
121
|
+
export { PreliminaryTrigger } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
108
122
|
export { QuickLookOverlay } from "../export/usdz/USDZExporter";
|
|
109
123
|
export { RawImage } from "../ui/Image";
|
|
110
124
|
export { Raycaster } from "../ui/Raycaster";
|
|
@@ -122,6 +136,7 @@ export { RotationOverLifetimeModule } from "../ParticleSystemModules";
|
|
|
122
136
|
export { SceneSwitcher } from "../SceneSwitcher";
|
|
123
137
|
export { ScreenCapture } from "../ScreenCapture";
|
|
124
138
|
export { ScreenSpaceAmbientOcclusion } from "../postprocessing/Effects/ScreenspaceAmbientOcclusion";
|
|
139
|
+
export { SetActiveOnClick } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
125
140
|
export { ShadowCatcher } from "../ShadowCatcher";
|
|
126
141
|
export { ShapeModule } from "../ParticleSystemModules";
|
|
127
142
|
export { SignalAsset } from "../timeline/SignalAsset";
|
|
@@ -146,24 +161,33 @@ export { SubEmitterSystem } from "../ParticleSystem";
|
|
|
146
161
|
export { SyncedCamera } from "../SyncedCamera";
|
|
147
162
|
export { SyncedRoom } from "../SyncedRoom";
|
|
148
163
|
export { SyncedTransform } from "../SyncedTransform";
|
|
164
|
+
export { TapGestureTrigger } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
149
165
|
export { TeleportTarget } from "../webxr/WebXRController";
|
|
150
166
|
export { TestRunner } from "../TestRunner";
|
|
151
167
|
export { TestSimulateUserData } from "../TestRunner";
|
|
152
168
|
export { Text } from "../ui/Text";
|
|
169
|
+
export { TextBuilder } from "../export/usdz/extensions/USDZText";
|
|
170
|
+
export { TextExtension } from "../export/usdz/extensions/USDZText";
|
|
153
171
|
export { TextureSheetAnimationModule } from "../ParticleSystemModules";
|
|
154
172
|
export { TiltShiftEffect } from "../postprocessing/Effects/TiltShiftEffect";
|
|
155
173
|
export { ToneMapping } from "../postprocessing/Effects/Tonemapping";
|
|
156
174
|
export { TrailModule } from "../ParticleSystemModules";
|
|
157
175
|
export { TransformData } from "../export/usdz/extensions/Animation";
|
|
158
176
|
export { TransformGizmo } from "../TransformGizmo";
|
|
177
|
+
export { TriggerBuilder } from "../export/usdz/extensions/behavior/BehavioursBuilder";
|
|
178
|
+
export { TriggerModel } from "../export/usdz/extensions/behavior/BehavioursBuilder";
|
|
159
179
|
export { UIRaycastUtils } from "../ui/RaycastUtils";
|
|
160
180
|
export { UIRootComponent } from "../ui/BaseUIComponent";
|
|
161
181
|
export { UsageMarker } from "../Interactable";
|
|
182
|
+
export { USDZBehaviours } from "../export/usdz/extensions/behavior/Behaviour";
|
|
162
183
|
export { USDZExporter } from "../export/usdz/USDZExporter";
|
|
184
|
+
export { USDZText } from "../export/usdz/extensions/USDZText";
|
|
185
|
+
export { VariantAction } from "../export/usdz/extensions/behavior/Actions";
|
|
163
186
|
export { VelocityOverLifetimeModule } from "../ParticleSystemModules";
|
|
164
187
|
export { VerticalLayoutGroup } from "../ui/Layout";
|
|
165
188
|
export { VideoPlayer } from "../VideoPlayer";
|
|
166
189
|
export { Vignette } from "../postprocessing/Effects/Vignette";
|
|
190
|
+
export { VisibilityAction } from "../export/usdz/extensions/behavior/BehaviourComponents";
|
|
167
191
|
export { Voip } from "../Voip";
|
|
168
192
|
export { Volume } from "../postprocessing/Volume";
|
|
169
193
|
export { VolumeParameter } from "../postprocessing/VolumeParameter";
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { USDObject } from "./ThreeUSDZExporter";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
export interface IUSDZExporterExtension {
|
|
3
|
+
export interface IUSDExporterExtension {
|
|
5
4
|
|
|
6
5
|
get extensionName(): string;
|
|
7
6
|
onBeforeBuildDocument?(context);
|
|
8
7
|
onAfterBuildDocument?(context);
|
|
9
|
-
onExportObject?(object, model :
|
|
8
|
+
onExportObject?(object, model : USDObject, context);
|
|
10
9
|
onAfterSerialize?(context);
|
|
11
|
-
onAfterHierarchy?(context);
|
|
10
|
+
onAfterHierarchy?(context, writer : any);
|
|
12
11
|
}
|