@needle-tools/engine 4.8.8-next.c758977 → 4.8.8-next.e80f4d7

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.
@@ -1765,9 +1765,9 @@ fo('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUIL
1765
1765
  fo('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";');
1766
1766
  fo('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.8.8";');
1767
1767
  fo('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');
1768
- fo('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Sep 04 2025 08:27:15 GMT+0000 (Coordinated Universal Time)";');
1768
+ fo('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Fri Sep 05 2025 10:35:01 GMT+0000 (Coordinated Universal Time)";');
1769
1769
  fo('globalThis["__NEEDLE_PUBLIC_KEY__"] = "' + NEEDLE_PUBLIC_KEY + '";');
1770
- const En = "4.8.8", Cm = "undefined", Gb = "Thu Sep 04 2025 08:27:15 GMT+0000 (Coordinated Universal Time)";
1770
+ const En = "4.8.8", Cm = "undefined", Gb = "Fri Sep 05 2025 10:35:01 GMT+0000 (Coordinated Universal Time)";
1771
1771
  Hb && console.log(`Engine version: ${En} (generator: ${Cm})
1772
1772
  Project built at ${Gb}`);
1773
1773
  const bl = NEEDLE_PUBLIC_KEY, oo = "needle_isActiveInHierarchy", Br = "builtin_components", Mh = "needle_editor_guid";
@@ -4240,7 +4240,7 @@ class Oa {
4240
4240
  return this.applyDefaultObjectOptions(n, e), n;
4241
4241
  }
4242
4242
  static applyDefaultObjectOptions(e, t) {
4243
- e.receiveShadow = !0, e.castShadow = !0, t?.name && (e.name = t.name), t?.position && (Array.isArray(t.position) ? e.position.set(t.position[0], t.position[1], t.position[2]) : e.position.set(t.position.x, t.position.y, t.position.z)), t?.rotation && (Array.isArray(t.rotation) ? e.rotation.set(t.rotation[0], t.rotation[1], t.rotation[2]) : e.rotation.set(t.rotation.x, t.rotation.y, t.rotation.z)), t?.scale && (typeof t.scale == "number" ? e.scale.set(t.scale, t.scale, t.scale) : Array.isArray(t.scale) ? e.scale.set(t.scale[0], t.scale[1], t.scale[2]) : e.scale.set(t.scale.x, t.scale.y, t.scale.z)), t?.receiveShadow != null && (e.receiveShadow = t.receiveShadow), t?.castShadow != null && (e.castShadow = t.castShadow), t?.parent && t.parent.add(e);
4243
+ e.receiveShadow = !0, e.castShadow = !0, t?.name && (e.name = t.name), t?.position && (Array.isArray(t.position) ? e.position.set(t.position[0], t.position[1], t.position[2]) : e.position.set(t.position.x || 0, t.position.y || 0, t.position.z || 0)), t?.rotation && (Array.isArray(t.rotation) ? e.rotation.set(t.rotation[0], t.rotation[1], t.rotation[2]) : e.rotation.set(t.rotation.x || 0, t.rotation.y || 0, t.rotation.z || 0)), t?.scale && (typeof t.scale == "number" ? e.scale.set(t.scale, t.scale, t.scale) : Array.isArray(t.scale) ? e.scale.set(t.scale[0], t.scale[1], t.scale[2]) : e.scale.set(t.scale.x || 1, t.scale.y || 1, t.scale.z || 1)), t?.receiveShadow != null && (e.receiveShadow = t.receiveShadow), t?.castShadow != null && (e.castShadow = t.castShadow), t?.parent && t.parent.add(e);
4244
4244
  }
4245
4245
  }
4246
4246
  function P1(s, e, t, i, n) {
@@ -11184,13 +11184,25 @@ Possible solutions:
11184
11184
  * Set a rect or dom element. The camera center will be moved to the center of the rect.
11185
11185
  * This is useful if you have Needle Engine embedded in a HTML layout and while you want the webgl background to fill e.g. the whole screen you want to move the camera center to free space.
11186
11186
  * For that you can simply pass in the rect or HMTL div that you want the camera to center on.
11187
+ * @param rect The focus rect or null to disable
11188
+ * @param settings Optional settings for the focus rect. These will override the `focusRectSettings` property
11187
11189
  */
11188
- setCameraFocusRect(e) {
11189
- this._focusRect = e;
11190
+ setCameraFocusRect(e, t) {
11191
+ this._focusRect = e, t && Object.assign(this.focusRectSettings, t);
11190
11192
  }
11191
11193
  get focusRect() {
11192
11194
  return this._focusRect;
11193
11195
  }
11196
+ /** Settings when a focus rect is set. Use `setCameraFocusRect(...)` to do so.
11197
+ * This can be used to offset the renderer center e.g. to a specific DOM element.
11198
+ */
11199
+ focusRectSettings = {
11200
+ /** Controls how fast the rect is centered. Smaller values mean the rect is centered faster.
11201
+ * A minimum value of 0 means the rect is centered instantly.
11202
+ * @default .05
11203
+ */
11204
+ damping: 0.05
11205
+ };
11194
11206
  _focusRect = null;
11195
11207
  _lastTimestamp = 0;
11196
11208
  _accumulatedTime = 0;
@@ -11264,7 +11276,11 @@ Possible solutions:
11264
11276
  2
11265
11277
  /* LateUpdate */
11266
11278
  ), this.physicsSteps === void 0 && (this.physicsSteps = 1), this.physics.engine && this.physicsSteps > 0 && this.internalUpdatePhysics(this.physicsSteps), this.isVisibleToUser || this.runInBackground) {
11267
- this._focusRect && this.mainCamera instanceof me && CC(this._focusRect, this.time.deltaTime / 0.05, this.mainCamera, this.renderer), this._currentFrameEvent = 3;
11279
+ if (this._focusRect && this.mainCamera instanceof me) {
11280
+ const n = this.focusRectSettings, o = n.damping > 0 ? this.time.deltaTime / n.damping : 1;
11281
+ CC(this._focusRect, o, this.mainCamera, this.renderer);
11282
+ }
11283
+ this._currentFrameEvent = 3;
11268
11284
  for (let n = 0; n < this.scripts_onBeforeRender.length; n++) {
11269
11285
  const o = this.scripts_onBeforeRender[n];
11270
11286
  o.activeAndEnabled && o.onBeforeRender !== void 0 && (U.Current = this, o.onBeforeRender(t));
@@ -16332,9 +16348,9 @@ class ye extends T {
16332
16348
  }
16333
16349
  t || (t = {});
16334
16350
  const { immediate: r = !1, centerCamera: a, cameraNearFar: l = "auto", fitOffset: c = 1.1, fov: h = n?.fov } = t, d = new b(), f = new b(), p = _i(i, void 0, this._camera?.threeCamera?.layers), g = p.clone();
16335
- n.updateMatrixWorld(), n.updateProjectionMatrix(), p.getCenter(f);
16351
+ p.getCenter(f);
16336
16352
  const _ = new b();
16337
- if (p.getSize(_), p.applyMatrix4(n.matrixWorldInverse), p.getSize(d), p.setFromCenterAndSize(f, d), Number.isNaN(d.x) || Number.isNaN(d.y) || Number.isNaN(d.z)) {
16353
+ if (p.getSize(_), n.updateMatrixWorld(), p.applyMatrix4(n.matrixWorldInverse), p.getSize(d), p.setFromCenterAndSize(f, d), Number.isNaN(d.x) || Number.isNaN(d.y) || Number.isNaN(d.z)) {
16338
16354
  console.warn("Camera fit size resultet in NaN", n, p, [...i]);
16339
16355
  return;
16340
16356
  }
@@ -16347,10 +16363,10 @@ class ye extends T {
16347
16363
  const O = 0.05, k = f.clone();
16348
16364
  if (k.y -= d.y * O, t.targetOffset && (t.targetOffset.x !== void 0 && (k.x += t.targetOffset.x), t.targetOffset.y !== void 0 && (k.y += t.targetOffset.y), t.targetOffset.z !== void 0 && (k.z += t.targetOffset.z)), t.relativeTargetOffset && (t.relativeTargetOffset.x !== void 0 && (k.x += t.relativeTargetOffset.x * d.x), t.relativeTargetOffset.y !== void 0 && (k.y += t.relativeTargetOffset.y * d.y), t.relativeTargetOffset.z !== void 0 && (k.z += t.relativeTargetOffset.z * d.z)), this.setLookTargetPosition(k, r), this.setFieldOfView(t.fov, r), l == null || l == "auto") {
16349
16365
  const W = S.findObjectOfType(Ms), X = W ? W.radius : 0, A = Math.max(_.x, _.y, _.z, X);
16350
- n.near = I / 100, n.far = A + I * 10, W && (this.maxZoom = Math.max(Math.min(this.maxZoom, X * 0.5), I));
16366
+ n.near = I / 100, n.far = A + I * 10, n.updateProjectionMatrix(), W && (this.maxZoom = Math.max(Math.min(this.maxZoom, X * 0.5), I));
16351
16367
  }
16352
16368
  const E = o.getDistance();
16353
- E < this.minZoom && (this.minZoom = E * 0.9), E > this.maxZoom && (this.maxZoom = E * 1.1), n.updateMatrixWorld(), n.updateProjectionMatrix();
16369
+ E < this.minZoom && (this.minZoom = E * 0.9), E > this.maxZoom && (this.maxZoom = E * 1.1);
16354
16370
  const B = f.clone();
16355
16371
  t.fitDirection ? B.sub(new b().copy(t.fitDirection).multiplyScalar(1e6)) : B.sub(n.worldPosition), a === "y" && (B.y = 0), B.normalize(), B.multiplyScalar(I), a === "y" && (B.y += -O * 4 * I);
16356
16372
  let L = f.clone().sub(B);
@@ -20590,7 +20606,7 @@ class Fp extends T {
20590
20606
  }
20591
20607
  } else
20592
20608
  this._ambientLightObj && this._ambientLightObj.removeFromParent(), this._hemisphereLightObj && this._hemisphereLightObj.removeFromParent();
20593
- this.sourceId && this.context.sceneLighting.internalEnableReflection(this.sourceId);
20609
+ this.sourceId && (this.context.domElement.getAttribute("environment-image") || this.context.sceneLighting.internalEnableReflection(this.sourceId));
20594
20610
  }
20595
20611
  onDisable() {
20596
20612
  Nr && console.warn("💡⚫ <<< Disable lighting:", this.sourceId, this), this._ambientLightObj && this._ambientLightObj.removeFromParent(), this._hemisphereLightObj && this._hemisphereLightObj.removeFromParent(), this.sourceId && this.context.sceneLighting.internalDisableReflection(this.sourceId);