Needle Engine

Changes between version 3.37.10-alpha and 3.37.10-alpha.1
Files changed (2) hide show
  1. src/engine-components/ContactShadows.ts +11 -5
  2. src/engine/engine_element.ts +3 -0
src/engine-components/ContactShadows.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  import { getParam } from "../engine/engine_utils.js"
11
11
  import { setCustomVisibility } from "../engine/js-extensions/Layers.js";
12
12
  import { Behaviour } from "./Component.js";
13
+ import { setAutoFitEnabled } from "../engine/engine_camera.js";
13
14
 
14
15
  const debug = getParam("debugcontactshadows");
15
16
 
@@ -81,6 +82,7 @@
81
82
  */
82
83
  fitShadows() {
83
84
  if (debug) console.log("Fitting shadows to scene");
85
+ setAutoFitEnabled(this.gameObject, false);
84
86
  const box = getBoundingBox(this.context.scene.children, [this.gameObject]);
85
87
  if (debug) Gizmos.DrawWireBox3(box, 0xffff00, 1);
86
88
  const min = box.min;
@@ -89,6 +91,11 @@
89
91
  this.gameObject.scale.multiplyScalar(1.5);
90
92
  }
91
93
 
94
+ awake() {
95
+ // ignore self for autofitting
96
+ setAutoFitEnabled(this.gameObject, false);
97
+ }
98
+
92
99
  /** @internal */
93
100
  start(): void {
94
101
  if (debug) console.log("Create ContactShadows on " + this.gameObject.name, this)
@@ -155,7 +162,7 @@
155
162
  this.shadowGroup.add(this.blurPlane);
156
163
 
157
164
  // max. ground distance is controlled via object scale
158
- this.shadowCamera = new OrthographicCamera(-1 /2, 1/2, 1/2, -1/2, 0, 1.0);
165
+ this.shadowCamera = new OrthographicCamera(-1 / 2, 1 / 2, 1 / 2, -1 / 2, 0, 1.0);
159
166
  this.shadowCamera.rotation.x = Math.PI / 2; // get the camera to look up
160
167
  this.shadowGroup.add(this.shadowCamera);
161
168
 
@@ -190,7 +197,6 @@
190
197
  this.verticalBlurMaterial.depthTest = false;
191
198
 
192
199
  this.shadowGroup.visible = false;
193
-
194
200
  if (this.autoFit) this.fitShadows();
195
201
  }
196
202
 
@@ -218,7 +224,7 @@
218
224
  !this.depthMaterial || !this.shadowCamera ||
219
225
  !this.blurPlane || !this.shadowGroup || !this.plane ||
220
226
  !this.horizontalBlurMaterial || !this.verticalBlurMaterial) {
221
- if(debug)
227
+ if (debug)
222
228
  console.error("ContactShadows: not initialized yet");
223
229
  return;
224
230
  }
@@ -261,7 +267,7 @@
261
267
 
262
268
  const prevXRState = renderer.xr.enabled;
263
269
  renderer.xr.enabled = false;
264
-
270
+
265
271
  const list = renderer.renderLists.get(scene, 0);
266
272
  const prev = list.transparent;
267
273
  list.transparent = [];
@@ -273,7 +279,7 @@
273
279
  renderer.render(scene, this.shadowCamera);
274
280
 
275
281
  list.transparent = prev;
276
-
282
+
277
283
  // for the shearing idea
278
284
  // this.shadowCamera.projectionMatrix.copy(mat);
279
285
 
src/engine/engine_element.ts CHANGED
@@ -687,6 +687,9 @@
687
687
 
688
688
 
689
689
  function getDisplayName(str: string) {
690
+ if (str.startsWith("blob:")) {
691
+ return "blob";
692
+ }
690
693
  const parts = str.split("/");
691
694
  let name = parts[parts.length - 1];
692
695
  // Remove params