@needle-tools/engine 2.54.2-pre → 2.55.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 +10 -0
- package/dist/needle-engine.d.ts +27 -4
- package/dist/needle-engine.js +352 -352
- package/dist/needle-engine.js.map +3 -3
- package/dist/needle-engine.min.js +38 -38
- package/dist/needle-engine.min.js.map +3 -3
- package/dist/needle-engine.tsbuildinfo +1 -1
- package/lib/engine/engine_lightdata.js +1 -1
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.js +8 -0
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +1 -1
- package/lib/engine/engine_physics.js +44 -3
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics.types.d.ts +13 -0
- package/lib/engine/engine_physics.types.js +7 -0
- package/lib/engine/engine_physics.types.js.map +1 -1
- package/lib/engine/engine_setup.js +2 -2
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_time.d.ts +1 -0
- package/lib/engine/engine_time.js +7 -0
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine/engine_types.d.ts +4 -1
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +1 -0
- package/lib/engine/engine_utils.js +3 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +2 -0
- package/lib/engine-components/Collider.js +4 -0
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +1 -0
- package/lib/engine-components/ParticleSystem.js +10 -5
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.d.ts +1 -1
- package/lib/engine-components/ParticleSystemModules.js +25 -19
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +1 -0
- package/lib/engine-components/Renderer.js +5 -0
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RigidBody.js +1 -19
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js +1 -3
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +2 -1
- package/lib/engine-components/VideoPlayer.js +54 -51
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/WebARSessionRoot.js +5 -0
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXR.js +13 -13
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRController.js +1 -2
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/engine/engine_lightdata.ts +1 -1
- package/src/engine/engine_mainloop_utils.ts +6 -0
- package/src/engine/engine_physics.ts +47 -5
- package/src/engine/engine_physics.types.ts +17 -0
- package/src/engine/engine_setup.ts +2 -2
- package/src/engine/engine_time.ts +7 -1
- package/src/engine/engine_types.ts +5 -2
- package/src/engine/engine_utils.ts +4 -0
- package/src/engine-components/Collider.ts +3 -0
- package/src/engine-components/ParticleSystem.ts +10 -5
- package/src/engine-components/ParticleSystemModules.ts +27 -20
- package/src/engine-components/Renderer.ts +6 -0
- package/src/engine-components/RigidBody.ts +1 -20
- package/src/engine-components/SyncedTransform.ts +1 -3
- package/src/engine-components/VideoPlayer.ts +55 -51
- package/src/engine-components/WebARSessionRoot.ts +5 -0
- package/src/engine-components/WebXR.ts +15 -13
- package/src/engine-components/WebXRController.ts +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.55.0-pre",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally.",
|
|
5
5
|
"main": "dist/needle-engine.js",
|
|
6
6
|
"module": "src/needle-engine.ts",
|
|
@@ -33,7 +33,7 @@ export class LightDataRegistry implements ILightDataRegistry {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
registerTexture(sourceId: SourceIdentifier, type: LightmapType, tex: Texture, index: number) {
|
|
36
|
-
if (debugLightmap) console.log("Registering
|
|
36
|
+
if (debugLightmap) console.log("Registering ", LightmapType[type], tex, sourceId);
|
|
37
37
|
if (!this._lightmaps.has(sourceId))
|
|
38
38
|
this._lightmaps.set(sourceId, new Map());
|
|
39
39
|
const map = this._lightmaps.get(sourceId);
|
|
@@ -68,6 +68,12 @@ export function processNewScripts(context: Context) {
|
|
|
68
68
|
new_scripts_buffer.splice(i, 1);
|
|
69
69
|
i--; continue;
|
|
70
70
|
}
|
|
71
|
+
if (script.registering) {
|
|
72
|
+
try {
|
|
73
|
+
script.registering();
|
|
74
|
+
}
|
|
75
|
+
catch (err) { console.error(err); }
|
|
76
|
+
}
|
|
71
77
|
// console.log(script, script.gameObject)
|
|
72
78
|
// TODO: we should not call awake on components with inactive gameobjects
|
|
73
79
|
if (script.__internalAwake !== undefined) {
|
|
@@ -15,9 +15,10 @@ import {
|
|
|
15
15
|
import { InstancingUtil } from './engine_instancing';
|
|
16
16
|
import { foreachComponent } from './engine_gameobject';
|
|
17
17
|
|
|
18
|
-
import RAPIER, { ActiveEvents, Collider, ColliderDesc, EventQueue, JointData, RigidBody, RigidBodyType, World } from '@dimforge/rapier3d-compat';
|
|
19
|
-
import { CollisionDetectionMode } from '../engine/engine_physics.types';
|
|
18
|
+
import RAPIER, { ActiveEvents, CoefficientCombineRule, Collider, ColliderDesc, EventQueue, JointData, RigidBody, RigidBodyType, World } from '@dimforge/rapier3d-compat';
|
|
19
|
+
import { CollisionDetectionMode, PhysicsMaterialCombine } from '../engine/engine_physics.types';
|
|
20
20
|
import { Gizmos } from './engine_gizmos';
|
|
21
|
+
import { Mathf } from './engine_math';
|
|
21
22
|
export type Rapier = typeof RAPIER;
|
|
22
23
|
|
|
23
24
|
|
|
@@ -354,7 +355,7 @@ export class Physics {
|
|
|
354
355
|
this.createCollider(collider, desc, center);
|
|
355
356
|
}
|
|
356
357
|
|
|
357
|
-
addMeshCollider(collider: ICollider, mesh: Mesh, convex: boolean, scale:Vector3) {
|
|
358
|
+
addMeshCollider(collider: ICollider, mesh: Mesh, convex: boolean, scale: Vector3) {
|
|
358
359
|
const geo = mesh.geometry;
|
|
359
360
|
if (!geo) {
|
|
360
361
|
if (debugPhysics) console.warn("Missing mesh geometry", mesh.name);
|
|
@@ -405,7 +406,7 @@ export class Physics {
|
|
|
405
406
|
matrix.decompose(this._tempPosition, this._tempQuaternion, this._tempScale);
|
|
406
407
|
getWorldScale(collider.gameObject, this._tempScale);
|
|
407
408
|
if (center) {
|
|
408
|
-
center.multiply(
|
|
409
|
+
center.multiply(this._tempScale);
|
|
409
410
|
this._tempPosition.x -= center.x;
|
|
410
411
|
this._tempPosition.y += center.y;
|
|
411
412
|
this._tempPosition.z += center.z;
|
|
@@ -414,6 +415,42 @@ export class Physics {
|
|
|
414
415
|
desc.setRotation(this._tempQuaternion);
|
|
415
416
|
desc.setSensor(collider.isTrigger);
|
|
416
417
|
|
|
418
|
+
// TODO: we might want to update this if the material changes
|
|
419
|
+
const physicsMaterial = collider.sharedMaterial;
|
|
420
|
+
if (physicsMaterial) {
|
|
421
|
+
CoefficientCombineRule
|
|
422
|
+
desc.setRestitution(physicsMaterial.bounciness);
|
|
423
|
+
switch (physicsMaterial.bounceCombine) {
|
|
424
|
+
case PhysicsMaterialCombine.Average:
|
|
425
|
+
desc.setRestitutionCombineRule(CoefficientCombineRule.Average);
|
|
426
|
+
break;
|
|
427
|
+
case PhysicsMaterialCombine.Maximum:
|
|
428
|
+
desc.setRestitutionCombineRule(CoefficientCombineRule.Max);
|
|
429
|
+
break;
|
|
430
|
+
case PhysicsMaterialCombine.Minimum:
|
|
431
|
+
desc.setRestitutionCombineRule(CoefficientCombineRule.Min);
|
|
432
|
+
break;
|
|
433
|
+
case PhysicsMaterialCombine.Multiply:
|
|
434
|
+
desc.setRestitutionCombineRule(CoefficientCombineRule.Multiply);
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
desc.setFriction(physicsMaterial.dynamicFriction);
|
|
438
|
+
switch (physicsMaterial.frictionCombine) {
|
|
439
|
+
case PhysicsMaterialCombine.Average:
|
|
440
|
+
desc.setFrictionCombineRule(CoefficientCombineRule.Average);
|
|
441
|
+
break;
|
|
442
|
+
case PhysicsMaterialCombine.Maximum:
|
|
443
|
+
desc.setFrictionCombineRule(CoefficientCombineRule.Max);
|
|
444
|
+
break;
|
|
445
|
+
case PhysicsMaterialCombine.Minimum:
|
|
446
|
+
desc.setFrictionCombineRule(CoefficientCombineRule.Min);
|
|
447
|
+
break;
|
|
448
|
+
case PhysicsMaterialCombine.Multiply:
|
|
449
|
+
desc.setFrictionCombineRule(CoefficientCombineRule.Multiply);
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
417
454
|
// if we want to use explicit mass properties, we need to set the collider density to 0
|
|
418
455
|
// otherwise rapier will compute the mass properties based on the collider shape and density
|
|
419
456
|
// https://rapier.rs/docs/user_guides/javascript/rigid_bodies#mass-properties
|
|
@@ -583,12 +620,17 @@ export class Physics {
|
|
|
583
620
|
// private _lastStepTime: number | undefined = 0;
|
|
584
621
|
private lines?: LineSegments;
|
|
585
622
|
|
|
586
|
-
public step(
|
|
623
|
+
public step(dt?: number) {
|
|
587
624
|
if (!this.world) return;
|
|
588
625
|
this._isUpdatingPhysicsWorld = true;
|
|
589
626
|
if (!this.eventQueue) {
|
|
590
627
|
this.eventQueue = new EventQueue(false);
|
|
591
628
|
}
|
|
629
|
+
if (dt) {
|
|
630
|
+
// if we make to sudden changes to the timestep the physics can get unstable
|
|
631
|
+
// https://rapier.rs/docs/user_guides/javascript/integration_parameters/#dt
|
|
632
|
+
this.world.timestep = Mathf.lerp(this.world.timestep, dt, 0.8);
|
|
633
|
+
}
|
|
592
634
|
this.world.step(this.eventQueue);
|
|
593
635
|
this._isUpdatingPhysicsWorld = false;
|
|
594
636
|
this.updateDebugRendering(this.world);
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
export enum PhysicsMaterialCombine
|
|
5
|
+
{
|
|
6
|
+
Average = 0,
|
|
7
|
+
Multiply = 1,
|
|
8
|
+
Minimum = 2,
|
|
9
|
+
Maximum = 3,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PhysicsMaterial = {
|
|
13
|
+
bounceCombine: PhysicsMaterialCombine;
|
|
14
|
+
bounciness: number;
|
|
15
|
+
frictionCombine: PhysicsMaterialCombine;
|
|
16
|
+
dynamicFriction: number;
|
|
17
|
+
staticFriction: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
3
20
|
export enum CollisionDetectionMode {
|
|
4
21
|
Discrete = 0,
|
|
5
22
|
Continuous = 1,
|
|
@@ -315,8 +315,8 @@ export class Context {
|
|
|
315
315
|
this.renderer.domElement.style.width = "100%";
|
|
316
316
|
this.renderer.domElement.style.height = "100%";
|
|
317
317
|
if (this.composer) {
|
|
318
|
-
this.composer.setSize(width, height);
|
|
319
|
-
this.composer.setPixelRatio(window.devicePixelRatio);
|
|
318
|
+
this.composer.setSize?.call(this.composer, width, height);
|
|
319
|
+
this.composer.setPixelRatio?.call(this.composer, window.devicePixelRatio);
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
1
|
import { Clock } from 'three'
|
|
2
|
+
import { getParam } from './engine_utils';
|
|
3
|
+
|
|
4
|
+
const debug = getParam("debugtime");
|
|
5
|
+
let timeScale = 1;
|
|
6
|
+
if(typeof debug === "number") timeScale = debug;
|
|
3
7
|
|
|
4
8
|
export class Time {
|
|
5
9
|
|
|
6
10
|
deltaTime = 0;
|
|
7
11
|
time = 0;
|
|
12
|
+
timeScale = 1;
|
|
8
13
|
|
|
9
14
|
/** same as frameCount */
|
|
10
15
|
frame = 0;
|
|
@@ -27,6 +32,7 @@ export class Time {
|
|
|
27
32
|
this.deltaTime = this.clock.getDelta();
|
|
28
33
|
// clamp delta time because if tab is not active clock.getDelta can get pretty big
|
|
29
34
|
this.deltaTime = Math.min(.1, this.deltaTime);
|
|
35
|
+
this.deltaTime *= timeScale * this.timeScale;
|
|
30
36
|
if(this.deltaTime <= 0) this.deltaTime = 0.000000000001;
|
|
31
37
|
this.frame += 1;
|
|
32
38
|
this.time += this.deltaTime;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Camera, Color, Material, Object3D, Vector3, Quaternion, Ray } from "three";
|
|
2
2
|
import { RGBAColor } from "../engine-components/js-extensions/RGBAColor";
|
|
3
|
-
import { CollisionDetectionMode, RigidbodyConstraints } from "./engine_physics.types";
|
|
3
|
+
import { CollisionDetectionMode, PhysicsMaterial, RigidbodyConstraints } from "./engine_physics.types";
|
|
4
4
|
import { getWorldPosition } from "./engine_three_utils";
|
|
5
5
|
import { CircularBuffer } from "./engine_utils";
|
|
6
6
|
|
|
@@ -67,6 +67,8 @@ export interface IComponent {
|
|
|
67
67
|
__internalDestroy();
|
|
68
68
|
resolveGuids?(guidsMap: GuidsMap): void;
|
|
69
69
|
|
|
70
|
+
/** experimental, called when the script is registered for the first time, this is called even if the component is not enabled. */
|
|
71
|
+
registering?();
|
|
70
72
|
awake();
|
|
71
73
|
onEnable();
|
|
72
74
|
onDisable();
|
|
@@ -78,7 +80,7 @@ export interface IComponent {
|
|
|
78
80
|
/** called when this.context.isPaused changes or when rendering loop changes due to changing DOM element visibility
|
|
79
81
|
* e.g. when the DOM element becomes hidden or out ot view
|
|
80
82
|
*/
|
|
81
|
-
onPausedChanged?(isPaused:boolean, wasPaused:boolean);
|
|
83
|
+
onPausedChanged?(isPaused: boolean, wasPaused: boolean);
|
|
82
84
|
|
|
83
85
|
start?(): void;
|
|
84
86
|
earlyUpdate?(): void;
|
|
@@ -138,6 +140,7 @@ export declare interface ICollider extends IComponent {
|
|
|
138
140
|
get isCollider();
|
|
139
141
|
attachedRigidbody: IRigidbody | null;
|
|
140
142
|
isTrigger: boolean;
|
|
143
|
+
sharedMaterial?: PhysicsMaterial;
|
|
141
144
|
}
|
|
142
145
|
|
|
143
146
|
export declare interface IRigidbody extends IComponent {
|
|
@@ -5,6 +5,7 @@ import { Event, Mesh, Object3D, Vector3 } from "three"
|
|
|
5
5
|
// import { IColliderProvider, registerColliderProvider } from "../engine/engine_physics";
|
|
6
6
|
import { ICollider } from "../engine/engine_types";
|
|
7
7
|
import { getWorldScale } from "../engine/engine_three_utils";
|
|
8
|
+
import { PhysicsMaterial } from "../engine/engine_physics.types";
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
export class Collider extends Behaviour implements ICollider {
|
|
@@ -18,6 +19,8 @@ export class Collider extends Behaviour implements ICollider {
|
|
|
18
19
|
@serializable()
|
|
19
20
|
isTrigger: boolean = false;
|
|
20
21
|
|
|
22
|
+
@serializable()
|
|
23
|
+
sharedMaterial?: PhysicsMaterial;
|
|
21
24
|
|
|
22
25
|
awake() {
|
|
23
26
|
super.awake();
|
|
@@ -548,6 +548,8 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
548
548
|
private _state?: ParticlesEmissionState;
|
|
549
549
|
emit(count: number) {
|
|
550
550
|
if (this._particleSystem) {
|
|
551
|
+
// we need to call update the matrices etc e.g. if we call emit from a physics callback
|
|
552
|
+
this.onUpdate();
|
|
551
553
|
count = Math.min(count, this.maxParticles - this.currentParticles);
|
|
552
554
|
if (!this._state) this._state = new ParticlesEmissionState();
|
|
553
555
|
this._state.waitEmiting = count;
|
|
@@ -768,6 +770,14 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
768
770
|
}
|
|
769
771
|
|
|
770
772
|
onBeforeRender() {
|
|
773
|
+
this.onUpdate();
|
|
774
|
+
const dt = this.deltaTime;
|
|
775
|
+
this._batchSystem?.update(dt);
|
|
776
|
+
this._time += dt;
|
|
777
|
+
if (this._time > this.duration) this._time = 0;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
private onUpdate(){
|
|
771
781
|
if (this._bursts) {
|
|
772
782
|
this.emission.bursts = this._bursts;
|
|
773
783
|
delete this._bursts;
|
|
@@ -796,17 +806,12 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
796
806
|
this._container.matrix.identity();
|
|
797
807
|
this._container.matrix.scale(scale);
|
|
798
808
|
}
|
|
799
|
-
|
|
800
809
|
this.emission.system = this;
|
|
801
|
-
const dt = this.deltaTime;
|
|
802
810
|
this._interface.update();
|
|
803
811
|
this.shape.update(this, this.context, this.main.simulationSpace, this.gameObject);
|
|
804
812
|
this.noise.update(this.context);
|
|
805
813
|
this.inheritVelocity?.update(this.context);
|
|
806
814
|
this.velocityOverLifetime.update(this);
|
|
807
|
-
this._batchSystem?.update(dt);
|
|
808
|
-
this._time += dt;
|
|
809
|
-
if (this._time > this.duration) this._time = 0;
|
|
810
815
|
}
|
|
811
816
|
|
|
812
817
|
private addSubParticleSystems() {
|
|
@@ -6,6 +6,11 @@ import { AnimationCurve } from "./AnimationCurve";
|
|
|
6
6
|
import { Vec2, Vec3 } from "../engine/engine_types";
|
|
7
7
|
import { Context } from "../engine/engine_setup";
|
|
8
8
|
import { EmitterShape, FrameOverLife, Particle, ShapeJSON } from "three.quarks";
|
|
9
|
+
import { createNoise4D, NoiseFunction4D } from 'simplex-noise';
|
|
10
|
+
import { Gizmos } from "../engine/engine_gizmos";
|
|
11
|
+
import { getParam } from "../engine/engine_utils";
|
|
12
|
+
|
|
13
|
+
const debug = getParam("debugparticles");
|
|
9
14
|
|
|
10
15
|
declare type Color4 = { r: number, g: number, b: number, a: number };
|
|
11
16
|
declare type ColorKey = { time: number, color: Color4 };
|
|
@@ -457,10 +462,10 @@ export class SizeOverLifetimeModule {
|
|
|
457
462
|
|
|
458
463
|
export class ShapeModule implements EmitterShape {
|
|
459
464
|
|
|
465
|
+
// Emittershape start
|
|
460
466
|
get type(): string {
|
|
461
467
|
return ParticleSystemShapeType[this.shapeType];
|
|
462
468
|
}
|
|
463
|
-
|
|
464
469
|
initialize(particle: Particle): void {
|
|
465
470
|
this.getPosition();
|
|
466
471
|
particle.position.copy(this._vector);
|
|
@@ -471,6 +476,7 @@ export class ShapeModule implements EmitterShape {
|
|
|
471
476
|
clone(): EmitterShape {
|
|
472
477
|
return new ShapeModule();
|
|
473
478
|
}
|
|
479
|
+
// EmitterShape end
|
|
474
480
|
|
|
475
481
|
@serializable()
|
|
476
482
|
shapeType: ParticleSystemShapeType = ParticleSystemShapeType.Box;
|
|
@@ -574,16 +580,12 @@ export class ShapeModule implements EmitterShape {
|
|
|
574
580
|
this.randomConePoint(this.position, this.angle, radius, this.radiusThickness, this.arc, this.arcMode, this._vector);
|
|
575
581
|
break;
|
|
576
582
|
case ParticleSystemShapeType.Sphere:
|
|
577
|
-
this.randomSpherePoint(this.position, radius, this.radiusThickness, this.arc, this._vector);
|
|
578
|
-
this._vector.x *= this.scale.x;
|
|
579
|
-
this._vector.y *= this.scale.y;
|
|
580
|
-
this._vector.z *= this.scale.z;
|
|
583
|
+
this.randomSpherePoint(this.position, radius, this.radiusThickness, this.arc, this._vector, this.scale);
|
|
581
584
|
break;
|
|
582
585
|
case ParticleSystemShapeType.Circle:
|
|
583
|
-
this.
|
|
584
|
-
this.
|
|
585
|
-
this.
|
|
586
|
-
this._vector.z *= 0;
|
|
586
|
+
this._temp.copy(this.scale);
|
|
587
|
+
this._temp.z = 0;
|
|
588
|
+
this.randomSpherePoint(this.position, radius, this.radiusThickness, this.arc, this._vector, this._temp);
|
|
587
589
|
break;
|
|
588
590
|
default:
|
|
589
591
|
this._vector.set(0, 0, 0);
|
|
@@ -600,6 +602,7 @@ export class ShapeModule implements EmitterShape {
|
|
|
600
602
|
this._vector.applyEuler(this._rotation);
|
|
601
603
|
|
|
602
604
|
if (isWorldSpace) {
|
|
605
|
+
this._vector.applyQuaternion(this.system.worldQuaternion);
|
|
603
606
|
this._vector.add(this.system.worldPos);
|
|
604
607
|
}
|
|
605
608
|
}
|
|
@@ -607,7 +610,8 @@ export class ShapeModule implements EmitterShape {
|
|
|
607
610
|
|
|
608
611
|
|
|
609
612
|
private _dir: Vector3 = new Vector3();
|
|
610
|
-
|
|
613
|
+
|
|
614
|
+
getDirection(pos: Vec3): Vector3 {
|
|
611
615
|
if (!this.enabled) {
|
|
612
616
|
this._dir.set(0, 0, 1);
|
|
613
617
|
return this._dir;
|
|
@@ -623,10 +627,11 @@ export class ShapeModule implements EmitterShape {
|
|
|
623
627
|
break;
|
|
624
628
|
case ParticleSystemShapeType.Circle:
|
|
625
629
|
case ParticleSystemShapeType.Sphere:
|
|
626
|
-
const rx =
|
|
627
|
-
const ry =
|
|
628
|
-
const rz =
|
|
629
|
-
this._dir.set(rx, ry, rz)
|
|
630
|
+
const rx = pos.x;
|
|
631
|
+
const ry = pos.y;
|
|
632
|
+
const rz = pos.z;
|
|
633
|
+
this._dir.set(rx, ry, rz)
|
|
634
|
+
this._dir.sub(this.position)
|
|
630
635
|
break;
|
|
631
636
|
default:
|
|
632
637
|
this._dir.set(0, 0, 1);
|
|
@@ -640,7 +645,10 @@ export class ShapeModule implements EmitterShape {
|
|
|
640
645
|
this._dir.normalize();
|
|
641
646
|
this.spherizeDirection(this._dir, this.sphericalDirectionAmount);
|
|
642
647
|
this.randomizeDirection(this._dir, this.randomDirectionAmount);
|
|
643
|
-
|
|
648
|
+
if (debug) {
|
|
649
|
+
Gizmos.DrawSphere(pos, .01, 0x883300, .5, true);
|
|
650
|
+
Gizmos.DrawDirection(pos, this._dir, 0x883300, .5, true);
|
|
651
|
+
}
|
|
644
652
|
return this._dir;
|
|
645
653
|
}
|
|
646
654
|
|
|
@@ -677,15 +685,15 @@ export class ShapeModule implements EmitterShape {
|
|
|
677
685
|
dir.lerp(v, amount);
|
|
678
686
|
}
|
|
679
687
|
|
|
680
|
-
private randomSpherePoint(pos: Vec3, radius: number, thickness: number, arc: number, vec: Vec3) {
|
|
688
|
+
private randomSpherePoint(pos: Vec3, radius: number, thickness: number, arc: number, vec: Vec3, scale: Vec3) {
|
|
681
689
|
const u = Math.random();
|
|
682
690
|
const v = Math.random();
|
|
683
691
|
const theta = 2 * Math.PI * u * (arc / 360);
|
|
684
692
|
const phi = Math.acos(2 * v - 1);
|
|
685
693
|
const r = Mathf.lerp(1, 1 - (Math.pow(1 - Math.random(), Math.PI)), thickness) * (radius);
|
|
686
|
-
const x = pos.x + (-r * Math.sin(phi) * Math.cos(theta));
|
|
687
|
-
const y = pos.y + (r * Math.sin(phi) * Math.sin(theta));
|
|
688
|
-
const z = pos.z + (r * Math.cos(phi));
|
|
694
|
+
const x = pos.x + scale.x * (-r * Math.sin(phi) * Math.cos(theta));
|
|
695
|
+
const y = pos.y + scale.y * (r * Math.sin(phi) * Math.sin(theta));
|
|
696
|
+
const z = pos.z + scale.z * (r * Math.cos(phi));
|
|
689
697
|
vec.x = x;
|
|
690
698
|
vec.y = y;
|
|
691
699
|
vec.z = z;
|
|
@@ -738,7 +746,6 @@ export class ShapeModule implements EmitterShape {
|
|
|
738
746
|
|
|
739
747
|
|
|
740
748
|
|
|
741
|
-
import { createNoise4D, NoiseFunction4D } from 'simplex-noise';
|
|
742
749
|
|
|
743
750
|
export class NoiseModule {
|
|
744
751
|
@serializable()
|
|
@@ -229,6 +229,12 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
229
229
|
|
|
230
230
|
allowProgressiveLoading: boolean = true;
|
|
231
231
|
|
|
232
|
+
registering() {
|
|
233
|
+
if (!this.enabled) {
|
|
234
|
+
this.setVisibility(false);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
232
238
|
awake() {
|
|
233
239
|
this.clearInstancingState();
|
|
234
240
|
|
|
@@ -359,26 +359,7 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
359
359
|
/**d
|
|
360
360
|
* @deprecated not used anymore
|
|
361
361
|
*/
|
|
362
|
-
public setBodyFromGameObject(_velocity: THREE.Vector3 | null | { x: number, y: number, z: number } = null) {
|
|
363
|
-
if (this.gameObject && !this.destroyed) {
|
|
364
|
-
// this.context.physics.updateBody(this);
|
|
365
|
-
// this._ignoreChange = true;
|
|
366
|
-
// const wp = this.worldPosition;
|
|
367
|
-
// this.body.position.set(wp.x, wp.y, wp.z);
|
|
368
|
-
// const wr = this.worldQuaternion;
|
|
369
|
-
// this.body.quaternion.set(wr.x, wr.y, wr.z, wr.w);
|
|
370
|
-
|
|
371
|
-
// if (velocity) {
|
|
372
|
-
// Rigidbody.copyVector3.set(velocity.x, velocity.y, velocity.z);
|
|
373
|
-
// this._smoothedVelocity.lerp(Rigidbody.copyVector3, this.context.time.deltaTime / .1);
|
|
374
|
-
// const sm = this._smoothedVelocity;
|
|
375
|
-
// this.body.velocity.x = sm.x;
|
|
376
|
-
// this.body.velocity.y = sm.y;
|
|
377
|
-
// this.body.velocity.z = sm.z;
|
|
378
|
-
// }
|
|
379
|
-
// this._ignoreChange = false;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
362
|
+
public setBodyFromGameObject(_velocity: THREE.Vector3 | null | { x: number, y: number, z: number } = null) { }
|
|
382
363
|
|
|
383
364
|
|
|
384
365
|
|
|
@@ -268,7 +268,6 @@ export class SyncedTransform extends Behaviour {
|
|
|
268
268
|
if (this.rb) {
|
|
269
269
|
this.rb.isKinematic = this._model.isOwned ?? false;
|
|
270
270
|
this.rb.setVelocity(0, 0, 0);
|
|
271
|
-
this.rb.setBodyFromGameObject();
|
|
272
271
|
}
|
|
273
272
|
return;
|
|
274
273
|
}
|
|
@@ -288,7 +287,6 @@ export class SyncedTransform extends Behaviour {
|
|
|
288
287
|
console.log("RESET", this.name)
|
|
289
288
|
this.gameObject.position.set(0, 1, 0);
|
|
290
289
|
this.rb.setVelocity(0, 0, 0);
|
|
291
|
-
this.rb.setBodyFromGameObject();
|
|
292
290
|
}
|
|
293
291
|
}
|
|
294
292
|
|
|
@@ -300,7 +298,7 @@ export class SyncedTransform extends Behaviour {
|
|
|
300
298
|
console.log("send update", this.context.connection.connectionId, this.guid, this.gameObject.name, this.gameObject.guid);
|
|
301
299
|
|
|
302
300
|
if (this.overridePhysics && this.rb) {
|
|
303
|
-
this.rb.setBodyFromGameObject();
|
|
301
|
+
// this.rb.setBodyFromGameObject();
|
|
304
302
|
}
|
|
305
303
|
|
|
306
304
|
this._needsUpdate = false;
|