@needle-tools/engine 4.1.0-beta.3 → 4.1.0-beta.5
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 +29 -18
- package/components.needle.json +1 -1
- package/dist/gltf-progressive.js +59 -59
- package/dist/gltf-progressive.light.js +59 -59
- package/dist/gltf-progressive.light.min.js +6 -6
- package/dist/gltf-progressive.light.umd.cjs +5 -5
- package/dist/gltf-progressive.min.js +6 -6
- package/dist/gltf-progressive.umd.cjs +5 -5
- package/dist/needle-engine.bundle.js +2774 -2753
- package/dist/needle-engine.bundle.light.js +2773 -2752
- package/dist/needle-engine.bundle.light.min.js +110 -110
- package/dist/needle-engine.bundle.light.umd.cjs +101 -101
- package/dist/needle-engine.bundle.min.js +110 -110
- package/dist/needle-engine.bundle.umd.cjs +113 -113
- package/dist/needle-engine.js +202 -201
- package/dist/needle-engine.light.d.ts +14263 -0
- package/dist/needle-engine.light.js +202 -201
- package/dist/needle-engine.light.min.js +1 -1
- package/dist/needle-engine.light.umd.cjs +1 -1
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/three-examples.js +2795 -2436
- package/dist/three-examples.light.js +2795 -2436
- package/dist/three-examples.light.min.js +47 -15
- package/dist/three-examples.light.umd.cjs +47 -15
- package/dist/three-examples.min.js +47 -15
- package/dist/three-examples.umd.cjs +47 -15
- package/dist/three.js +67 -62
- package/dist/three.light.js +67 -62
- package/dist/three.light.min.js +170 -170
- package/dist/three.light.umd.cjs +170 -170
- package/dist/three.min.js +170 -170
- package/dist/three.umd.cjs +170 -170
- package/dist/vendor.js +1 -1
- package/dist/vendor.light.js +1 -1
- package/dist/vendor.light.min.js +1 -1
- package/dist/vendor.min.js +1 -1
- package/lib/engine/engine_context.d.ts +3 -2
- package/lib/engine/engine_context.js +26 -4
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +1 -1
- package/lib/engine/engine_physics_rapier.js +17 -12
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_types.d.ts +1 -1
- package/lib/engine-components/Camera.d.ts +7 -4
- package/lib/engine-components/Camera.js +13 -10
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/Collider.js +4 -5
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +1 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/RigidBody.js +2 -2
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +1 -1
- package/lib/engine-components/export/usdz/index.d.ts +1 -1
- package/lib/engine-components/export/usdz/index.js +1 -1
- package/lib/engine-components/export/usdz/index.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystem.d.ts +5 -6
- package/lib/engine-components/particlesystem/ParticleSystem.js +23 -9
- package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystemModules.js +7 -1
- package/lib/engine-components/particlesystem/ParticleSystemModules.js.map +1 -1
- package/package.json +4 -3
- package/src/engine/engine_context.ts +31 -8
- package/src/engine/engine_physics_rapier.ts +20 -10
- package/src/engine/engine_types.ts +1 -1
- package/src/engine-components/Camera.ts +14 -11
- package/src/engine-components/Collider.ts +4 -4
- package/src/engine-components/OrbitControls.ts +1 -1
- package/src/engine-components/RigidBody.ts +2 -2
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +1 -1
- package/src/engine-components/export/usdz/index.ts +1 -1
- package/src/engine-components/particlesystem/ParticleSystem.ts +26 -10
- package/src/engine-components/particlesystem/ParticleSystemModules.ts +9 -2
|
@@ -490,7 +490,7 @@ export interface IPhysicsEngine {
|
|
|
490
490
|
addSphereCollider(collider: ICollider);
|
|
491
491
|
addBoxCollider(collider: ICollider, size: Vector3);
|
|
492
492
|
addCapsuleCollider(collider: ICollider, radius: number, height: number);
|
|
493
|
-
addMeshCollider(collider: ICollider, mesh: Mesh, convex: boolean, scale
|
|
493
|
+
addMeshCollider(collider: ICollider, mesh: Mesh, convex: boolean, scale?: Vector3 | undefined);
|
|
494
494
|
|
|
495
495
|
updatePhysicsMaterial(collider: ICollider);
|
|
496
496
|
|
|
@@ -51,7 +51,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
/** The camera's field of view in degrees if it is a perspective camera */
|
|
54
|
+
/** The camera's field of view in degrees if it is a perspective camera. Calls updateProjectionMatrix when set */
|
|
55
55
|
get fieldOfView(): number | undefined {
|
|
56
56
|
if (this._cam instanceof PerspectiveCamera) {
|
|
57
57
|
return this._cam.fov;
|
|
@@ -74,7 +74,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/** The camera's near clipping plane */
|
|
77
|
+
/** The camera's near clipping plane. Calls updateProjectionMatrix when set */
|
|
78
78
|
get nearClipPlane(): number { return this._nearClipPlane; }
|
|
79
79
|
@serializable()
|
|
80
80
|
set nearClipPlane(val) {
|
|
@@ -87,15 +87,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
87
87
|
}
|
|
88
88
|
private _nearClipPlane: number = 0.1;
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
if (this._cam) {
|
|
92
|
-
this._cam.near = this._nearClipPlane;
|
|
93
|
-
this._cam.far = this._farClipPlane;
|
|
94
|
-
this._cam.updateProjectionMatrix();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** The camera's far clipping plane */
|
|
90
|
+
/** The camera's far clipping plane. Calls updateProjectionMatrix when set */
|
|
99
91
|
get farClipPlane(): number { return this._farClipPlane; }
|
|
100
92
|
@serializable()
|
|
101
93
|
set farClipPlane(val) {
|
|
@@ -108,6 +100,17 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
108
100
|
}
|
|
109
101
|
private _farClipPlane: number = 1000;
|
|
110
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Applys both the camera's near and far plane and calls updateProjectionMatrix on the camera.
|
|
105
|
+
*/
|
|
106
|
+
applyClippingPlane() {
|
|
107
|
+
if (this._cam) {
|
|
108
|
+
this._cam.near = this._nearClipPlane;
|
|
109
|
+
this._cam.far = this._farClipPlane;
|
|
110
|
+
this._cam.updateProjectionMatrix();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
111
114
|
/** The camera's clear flags - determines if the background is a skybox or a solid color or transparent */
|
|
112
115
|
@serializable()
|
|
113
116
|
public get clearFlags(): ClearFlags {
|
|
@@ -207,12 +207,12 @@ export class MeshCollider extends Collider {
|
|
|
207
207
|
const LOD = 0;
|
|
208
208
|
|
|
209
209
|
if (this.sharedMesh?.isMesh) {
|
|
210
|
-
this.context.physics.engine.addMeshCollider(this, this.sharedMesh, this.convex
|
|
210
|
+
this.context.physics.engine.addMeshCollider(this, this.sharedMesh, this.convex);
|
|
211
211
|
NEEDLE_progressive.assignMeshLOD(this.sharedMesh, LOD).then(res => {
|
|
212
212
|
if (res && this.activeAndEnabled && this.context.physics.engine && this.sharedMesh) {
|
|
213
213
|
this.context.physics.engine.removeBody(this);
|
|
214
214
|
this.sharedMesh.geometry = res;
|
|
215
|
-
this.context.physics.engine.addMeshCollider(this, this.sharedMesh, this.convex
|
|
215
|
+
this.context.physics.engine.addMeshCollider(this, this.sharedMesh, this.convex);
|
|
216
216
|
}
|
|
217
217
|
})
|
|
218
218
|
}
|
|
@@ -224,7 +224,7 @@ export class MeshCollider extends Collider {
|
|
|
224
224
|
for (const ch in group.children) {
|
|
225
225
|
const child = group.children[ch] as Mesh;
|
|
226
226
|
if (child.isMesh) {
|
|
227
|
-
this.context.physics.engine.addMeshCollider(this, child, this.convex
|
|
227
|
+
this.context.physics.engine.addMeshCollider(this, child, this.convex);
|
|
228
228
|
promises.push(NEEDLE_progressive.assignMeshLOD(child, LOD));
|
|
229
229
|
}
|
|
230
230
|
}
|
|
@@ -235,7 +235,7 @@ export class MeshCollider extends Collider {
|
|
|
235
235
|
for (const r of res) {
|
|
236
236
|
if (r && this.activeAndEnabled) {
|
|
237
237
|
mesh.geometry = r;
|
|
238
|
-
this.context.physics.engine?.addMeshCollider(this, mesh, this.convex
|
|
238
|
+
this.context.physics.engine?.addMeshCollider(this, mesh, this.convex);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
});
|
|
@@ -287,7 +287,7 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
287
287
|
cam = this.gameObject;
|
|
288
288
|
}
|
|
289
289
|
if (cam) setCameraController(cam, this, true);
|
|
290
|
-
if (!this._controls && cam instanceof
|
|
290
|
+
if (!this._controls && cam instanceof Object3D) {
|
|
291
291
|
this._cameraObject = cam;
|
|
292
292
|
// Using the parent if possible to make it possible to disable input on the canvas
|
|
293
293
|
// for having HTML content behind it and still receive input
|
|
@@ -324,9 +324,9 @@ export class Rigidbody extends Behaviour implements IRigidbody {
|
|
|
324
324
|
console.warn(`Rigidbody could not be created: Rapier physics are explicitly disabled.`);
|
|
325
325
|
else {
|
|
326
326
|
MODULES.RAPIER_PHYSICS.ready().then(async () => {
|
|
327
|
-
await delayForFrames(
|
|
327
|
+
await delayForFrames(3);
|
|
328
328
|
if (!this.context.physics.engine?.getBody(this))
|
|
329
|
-
console.warn(`Rigidbody could not be created. Ensure \"
|
|
329
|
+
console.warn(`Rigidbody could not be created. Ensure \"${this.name}\" has a Collider component.`);
|
|
330
330
|
})
|
|
331
331
|
}
|
|
332
332
|
}
|
|
@@ -1174,7 +1174,7 @@ declare type ImageReadbackResult = {
|
|
|
1174
1174
|
imageBitmap?: ImageBitmap;
|
|
1175
1175
|
}
|
|
1176
1176
|
|
|
1177
|
-
/** Reads back a texture from the GPU (can be compressed, a render texture, or
|
|
1177
|
+
/** Reads back a texture from the GPU (can be compressed, a render texture, or anything), optionally applies RGBA colorScale to it, and returns CPU data for further usage.
|
|
1178
1178
|
* Note that there are WebGL / WebGPU rules preventing some use of data between WebGL contexts.
|
|
1179
1179
|
*/
|
|
1180
1180
|
async function decompressGpuTexture( texture, maxTextureSize = Infinity, renderer: WebGLRenderer | null = null, colorScale: Vector4 | undefined = undefined): Promise<ImageReadbackResult> {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { type UsdzBehaviour } from "./extensions/behavior/Behaviour.js";
|
|
2
|
-
export { imageToCanvas, makeNameSafeForUSD, USDZExporter as NeedleUSDZExporter, USDDocument, USDObject, USDWriter,type USDZExporterContext } from "./ThreeUSDZExporter.js";
|
|
2
|
+
export { decompressGpuTexture, imageToCanvas, makeNameSafeForUSD, USDZExporter as NeedleUSDZExporter, USDDocument, USDObject, USDWriter,type USDZExporterContext } from "./ThreeUSDZExporter.js";
|
|
3
3
|
export { USDZExporter } from "./USDZExporter.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxesHelper, BackSide, Blending, BufferGeometry, FrontSide, LinearSRGBColorSpace, Material, Matrix4, Mesh, NormalBlending, Object3D, PlaneGeometry, Quaternion, SpriteMaterial, Texture, Vector3, Vector4 } from "three";
|
|
1
|
+
import { AxesHelper, BackSide, Blending, BufferGeometry, FrontSide, LinearSRGBColorSpace, Material, Matrix4, Mesh, MeshBasicMaterial, MeshStandardMaterial, NormalBlending, Object3D, PlaneGeometry, Quaternion, SpriteMaterial, Texture, Vector3, Vector4 } from "three";
|
|
2
2
|
import type { BatchedRenderer, Behavior, BurstParameters, EmissionState, EmitterShape, FunctionColorGenerator, FunctionJSON, FunctionValueGenerator, GeneratorMemory, Particle, ParticleSystemParameters, RecordState, TrailSettings, ValueGenerator } from "three.quarks";
|
|
3
3
|
import { BatchedParticleRenderer, ConstantColor, ConstantValue, ParticleSystem as _ParticleSystem, RenderMode, TrailParticle, Vector3 as QVector3, Vector4 as QVector4 } from "three.quarks";
|
|
4
4
|
|
|
@@ -39,10 +39,10 @@ export class ParticleSystemRenderer extends Behaviour {
|
|
|
39
39
|
renderMode?: ParticleSystemRenderMode;
|
|
40
40
|
|
|
41
41
|
@serializable(Material)
|
|
42
|
-
particleMaterial?: SpriteMaterial;
|
|
42
|
+
particleMaterial?: SpriteMaterial | MeshBasicMaterial;
|
|
43
43
|
|
|
44
44
|
@serializable(Material)
|
|
45
|
-
trailMaterial?: SpriteMaterial;
|
|
45
|
+
trailMaterial?: SpriteMaterial | MeshBasicMaterial;
|
|
46
46
|
|
|
47
47
|
// @serializable(Mesh)
|
|
48
48
|
particleMesh?: Mesh | string;
|
|
@@ -68,6 +68,7 @@ export class ParticleSystemRenderer extends Behaviour {
|
|
|
68
68
|
// showBalloonWarning(msg);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
get transparent(): boolean {
|
|
@@ -80,6 +81,24 @@ export class ParticleSystemRenderer extends Behaviour {
|
|
|
80
81
|
let material = (trailEnabled === true && this.trailMaterial) ? this.trailMaterial : this.particleMaterial;
|
|
81
82
|
|
|
82
83
|
if (material) {
|
|
84
|
+
|
|
85
|
+
if (material.type === "MeshStandardMaterial") {
|
|
86
|
+
if (debug) console.debug("ParticleSystemRenderer.getMaterial: MeshStandardMaterial detected, converting to MeshBasicMaterial. See https://github.com/Alchemist0823/three.quarks/issues/101");
|
|
87
|
+
if ("map" in material && material.map) {
|
|
88
|
+
material.map.colorSpace = LinearSRGBColorSpace;
|
|
89
|
+
material.map.premultiplyAlpha = false;
|
|
90
|
+
}
|
|
91
|
+
const newMaterial = new MeshBasicMaterial({ map: material.map });
|
|
92
|
+
if (trailEnabled) this.trailMaterial = newMaterial;
|
|
93
|
+
else this.particleMaterial = newMaterial;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if (material.map) {
|
|
98
|
+
material.map.colorSpace = LinearSRGBColorSpace;
|
|
99
|
+
material.map.premultiplyAlpha = false;
|
|
100
|
+
}
|
|
101
|
+
|
|
83
102
|
if (trailEnabled) {
|
|
84
103
|
// the particle material for trails must be DoubleSide or BackSide (since otherwise the trail is invisible)
|
|
85
104
|
if (material.side === FrontSide) {
|
|
@@ -896,7 +915,7 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
896
915
|
if (particleSystemBehaviour instanceof ParticleSystemBaseBehaviour) {
|
|
897
916
|
particleSystemBehaviour.system = this;
|
|
898
917
|
}
|
|
899
|
-
if (isDevEnvironment()) console.
|
|
918
|
+
if (isDevEnvironment() || debug) console.debug("Add custom ParticleSystem Behaviour", particleSystemBehaviour);
|
|
900
919
|
this._particleSystem.addBehavior(particleSystemBehaviour);
|
|
901
920
|
return true;
|
|
902
921
|
}
|
|
@@ -908,6 +927,7 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
908
927
|
const behaviours = this._particleSystem.behaviors;
|
|
909
928
|
const index = behaviours.indexOf(particleSystemBehaviour);
|
|
910
929
|
if (index !== -1) {
|
|
930
|
+
if (isDevEnvironment() || debug) console.debug("Remove custom ParticleSystem Behaviour", index, particleSystemBehaviour);
|
|
911
931
|
behaviours.splice(index, 1);
|
|
912
932
|
return true;
|
|
913
933
|
}
|
|
@@ -1145,13 +1165,9 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
1145
1165
|
}
|
|
1146
1166
|
}
|
|
1147
1167
|
|
|
1148
|
-
private lastMaterialVersion: number = -1;
|
|
1168
|
+
// private lastMaterialVersion: number = -1;
|
|
1149
1169
|
private onUpdate() {
|
|
1150
|
-
|
|
1151
|
-
if (mat && mat.version != this.lastMaterialVersion && this._particleSystem) {
|
|
1152
|
-
this.lastMaterialVersion = mat.version;
|
|
1153
|
-
this._particleSystem.texture = this._interface.texture;
|
|
1154
|
-
}
|
|
1170
|
+
|
|
1155
1171
|
|
|
1156
1172
|
if (this._bursts) {
|
|
1157
1173
|
this.emission.bursts = this._bursts;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createNoise4D, type NoiseFunction4D } from 'simplex-noise';
|
|
2
2
|
import { BufferGeometry, Color, Euler, Matrix4, Mesh, Object3D, Quaternion, Triangle, Vector2, Vector3, Vector4 } from "three";
|
|
3
|
-
import type { EmitterShape, IParticleSystem as QParticleSystem,Particle, ShapeJSON, Vector3 as QVector3, Vector4 as QVector4 } from "three.quarks";
|
|
3
|
+
import type { EmitterShape, IParticleSystem as QParticleSystem, Particle, ShapeJSON, Vector3 as QVector3, Vector4 as QVector4 } from "three.quarks";
|
|
4
4
|
|
|
5
5
|
import { isDevEnvironment } from '../../engine/debug/index.js';
|
|
6
6
|
import { Gizmos } from "../../engine/engine_gizmos.js";
|
|
@@ -360,9 +360,16 @@ export class MinMaxGradient {
|
|
|
360
360
|
this.gradientMax.evaluate(t01, MinMaxGradient._temp2);
|
|
361
361
|
return MinMaxGradient._temp.lerp(MinMaxGradient._temp2, t);
|
|
362
362
|
|
|
363
|
+
case ParticleSystemGradientMode.RandomColor:
|
|
364
|
+
case "RandomColor":
|
|
365
|
+
const random_t = Math.random();
|
|
366
|
+
this.gradientMin.evaluate(t01, MinMaxGradient._temp);
|
|
367
|
+
this.gradientMax.evaluate(t01, MinMaxGradient._temp2);
|
|
368
|
+
return MinMaxGradient._temp.lerp(MinMaxGradient._temp2, random_t);
|
|
369
|
+
|
|
363
370
|
}
|
|
364
371
|
// console.warn("Not implemented", ParticleSystemGradientMode[this.mode]);
|
|
365
|
-
MinMaxGradient._temp.set(
|
|
372
|
+
MinMaxGradient._temp.set(0xffffff)
|
|
366
373
|
MinMaxGradient._temp.alpha = 1;
|
|
367
374
|
return MinMaxGradient._temp;
|
|
368
375
|
}
|