@needle-tools/engine 2.55.0-pre → 2.55.2-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.
Files changed (65) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/needle-engine.d.ts +143 -133
  3. package/dist/needle-engine.js +358 -358
  4. package/dist/needle-engine.js.map +4 -4
  5. package/dist/needle-engine.min.js +20 -20
  6. package/dist/needle-engine.min.js.map +4 -4
  7. package/dist/needle-engine.tsbuildinfo +1 -1
  8. package/lib/engine/engine_gizmos.d.ts +2 -0
  9. package/lib/engine/engine_gizmos.js +24 -1
  10. package/lib/engine/engine_gizmos.js.map +1 -1
  11. package/lib/engine/engine_physics.d.ts +1 -0
  12. package/lib/engine/engine_physics.js +5 -2
  13. package/lib/engine/engine_physics.js.map +1 -1
  14. package/lib/engine/engine_serialization_core.js +20 -10
  15. package/lib/engine/engine_serialization_core.js.map +1 -1
  16. package/lib/engine/engine_setup.js +7 -1
  17. package/lib/engine/engine_setup.js.map +1 -1
  18. package/lib/engine/engine_time.js +3 -3
  19. package/lib/engine/engine_time.js.map +1 -1
  20. package/lib/engine/engine_types.d.ts +1 -0
  21. package/lib/engine/engine_types.js.map +1 -1
  22. package/lib/engine/extensions/NEEDLE_lightmaps.js +3 -1
  23. package/lib/engine/extensions/NEEDLE_lightmaps.js.map +1 -1
  24. package/lib/engine-components/Camera.d.ts +1 -2
  25. package/lib/engine-components/Camera.js +10 -10
  26. package/lib/engine-components/Camera.js.map +1 -1
  27. package/lib/engine-components/CameraUtils.d.ts +2 -2
  28. package/lib/engine-components/CameraUtils.js +13 -4
  29. package/lib/engine-components/CameraUtils.js.map +1 -1
  30. package/lib/engine-components/LODGroup.js +9 -0
  31. package/lib/engine-components/LODGroup.js.map +1 -1
  32. package/lib/engine-components/OrbitControls.d.ts +8 -7
  33. package/lib/engine-components/OrbitControls.js +38 -7
  34. package/lib/engine-components/OrbitControls.js.map +1 -1
  35. package/lib/engine-components/ParticleSystem.js +7 -1
  36. package/lib/engine-components/ParticleSystem.js.map +1 -1
  37. package/lib/engine-components/ParticleSystemModules.d.ts +1 -1
  38. package/lib/engine-components/ParticleSystemModules.js +2 -2
  39. package/lib/engine-components/ParticleSystemModules.js.map +1 -1
  40. package/lib/engine-components/Renderer.js +16 -2
  41. package/lib/engine-components/Renderer.js.map +1 -1
  42. package/lib/engine-components/RigidBody.d.ts +4 -0
  43. package/lib/engine-components/RigidBody.js +16 -0
  44. package/lib/engine-components/RigidBody.js.map +1 -1
  45. package/lib/engine-components/js-extensions/RGBAColor.d.ts +2 -0
  46. package/lib/engine-components/js-extensions/RGBAColor.js +2 -0
  47. package/lib/engine-components/js-extensions/RGBAColor.js.map +1 -1
  48. package/lib/tsconfig.tsbuildinfo +1 -1
  49. package/package.json +1 -1
  50. package/src/engine/engine_gizmos.ts +27 -2
  51. package/src/engine/engine_physics.ts +5 -4
  52. package/src/engine/engine_serialization_core.ts +25 -13
  53. package/src/engine/engine_setup.ts +9 -4
  54. package/src/engine/engine_time.ts +2 -2
  55. package/src/engine/engine_types.ts +1 -0
  56. package/src/engine/extensions/NEEDLE_lightmaps.ts +3 -1
  57. package/src/engine-components/Camera.ts +12 -15
  58. package/src/engine-components/CameraUtils.ts +15 -5
  59. package/src/engine-components/LODGroup.ts +9 -0
  60. package/src/engine-components/OrbitControls.ts +58 -19
  61. package/src/engine-components/ParticleSystem.ts +9 -2
  62. package/src/engine-components/ParticleSystemModules.ts +2 -2
  63. package/src/engine-components/Renderer.ts +19 -2
  64. package/src/engine-components/RigidBody.ts +22 -5
  65. package/src/engine-components/js-extensions/RGBAColor.ts +3 -0
@@ -22,6 +22,7 @@ const debugInstancing = getParam("debuginstancing");
22
22
  const debugProgressiveLoading = getParam("debugprogressive");
23
23
  const suppressProgressiveLoading = getParam("noprogressive");
24
24
 
25
+ const showWireframe = getParam("wireframe");
25
26
 
26
27
  export enum ReflectionProbeUsage {
27
28
  Off = 0,
@@ -285,15 +286,20 @@ export class Renderer extends Behaviour implements IRenderer {
285
286
  this._lightmaps = [];
286
287
 
287
288
  if (type === "Mesh") {
288
- if (!this.gameObject["material"]?.isMeshBasicMaterial === true) {
289
+ const mat = this.gameObject["material"];
290
+ if (!mat?.isMeshBasicMaterial) {
289
291
  const rm = new RendererLightmap(this.gameObject, this.context);// GameObject.addNewComponent(this.gameObject, RendererLightmap);
290
292
  this._lightmaps.push(rm);
291
293
  rm.init(this.lightmapIndex, this.lightmapScaleOffset, tex, debugLightmap);
292
294
  }
295
+ else {
296
+ if (mat)
297
+ console.warn("Lightmapping is not supported on MeshBasicMaterial", mat.name)
298
+ }
293
299
  }
294
300
  // for multi materials we need to loop through children
295
301
  // and then we add a lightmap renderer component to each of them
296
- else if (this.isMultiMaterialObject(this.gameObject)) {
302
+ else if (this.isMultiMaterialObject(this.gameObject) && this.sharedMaterials.length > 0) {
297
303
  for (const child of this.gameObject.children) {
298
304
  if (!child["material"]?.isMeshBasicMaterial) {
299
305
  const rm = new RendererLightmap(child as GameObject, this.context);
@@ -309,6 +315,17 @@ export class Renderer extends Behaviour implements IRenderer {
309
315
  }
310
316
  }
311
317
 
318
+
319
+
320
+ if (showWireframe) {
321
+ for (let i = 0; i < this.sharedMaterials.length; i++) {
322
+ const mat: any = this.sharedMaterials[i];
323
+ if (mat) {
324
+ mat.wireframe = true;
325
+ }
326
+ }
327
+ }
328
+
312
329
  }
313
330
 
314
331
  private _isInstancingEnabled: boolean = false;
@@ -38,11 +38,11 @@ class TransformWatch {
38
38
  }
39
39
  }
40
40
 
41
- syncValues(){
42
- for(const key of this._positionKeys){
41
+ syncValues() {
42
+ for (const key of this._positionKeys) {
43
43
  this.position![key] = this.obj.position[key];
44
44
  }
45
- for(const key of this._quaternionKeys){
45
+ for (const key of this._quaternionKeys) {
46
46
  this.quaternion![key] = this.obj.quaternion[key];
47
47
  }
48
48
  }
@@ -213,6 +213,14 @@ export class Rigidbody extends Behaviour implements IRigidbody {
213
213
  else this.constraints &= ~RigidbodyConstraints.FreezeRotationZ;
214
214
  }
215
215
 
216
+ set gravityScale(val: number) {
217
+ this._gravityScale = val;
218
+ }
219
+ get gravityScale() {
220
+ return this._gravityScale;
221
+ }
222
+ private _gravityScale: number = 1;
223
+
216
224
  private static tempPosition: THREE.Vector3 = new THREE.Vector3();
217
225
  private _propertiesChanged: boolean = false;
218
226
  private _currentVelocity: THREE.Vector3 = new THREE.Vector3();
@@ -271,9 +279,9 @@ export class Rigidbody extends Behaviour implements IRigidbody {
271
279
  return this.context.physics.internal_getRigidbody(this);
272
280
  }
273
281
 
274
- public teleport(pt: { x: number, y: number, z: number }, localspace:boolean = true) {
282
+ public teleport(pt: { x: number, y: number, z: number }, localspace: boolean = true) {
275
283
  this._watch?.reset(true);
276
- if(localspace) this.gameObject.position.set(pt.x, pt.y, pt.z);
284
+ if (localspace) this.gameObject.position.set(pt.x, pt.y, pt.z);
277
285
  else this.setWorldPosition(pt.x, pt.y, pt.z);
278
286
  this.resetForcesAndTorques();
279
287
  this.resetVelocities();
@@ -343,6 +351,15 @@ export class Rigidbody extends Behaviour implements IRigidbody {
343
351
  this.body?.setAngvel({ x: x, y: y, z: z }, true);
344
352
  }
345
353
 
354
+ public getAngularVelocity(): Vector3 {
355
+ const vel = this.body?.angvel();
356
+ if (!vel) return this._currentVelocity.set(0, 0, 0);
357
+ this._currentVelocity.x = vel.x;
358
+ this._currentVelocity.y = vel.y;
359
+ this._currentVelocity.z = vel.z;
360
+ return this._currentVelocity;
361
+ }
362
+
346
363
  public setTorque(x: number | Vector3, y: number, z: number) {
347
364
  this.setAngularVelocity(x, y, z);
348
365
  }
@@ -6,6 +6,9 @@ export class RGBAColor extends Color {
6
6
 
7
7
  get isRGBAColor() { return true; }
8
8
 
9
+ set a(val: number) { this.alpha = val; }
10
+ get a() { return this.alpha; }
11
+
9
12
  constructor(r: number, g: number, b: number, a: number) {
10
13
  super(r, g, b);
11
14
  this.alpha = a;